#FEATURE by cg
class: ImageView
added: #adjustHolder
comment/format in: #magnificationFactor:
changed:
#adjust:
#middleButtonMenu
--- a/ImageView.st Fri Jan 20 10:22:57 2017 +0100
+++ b/ImageView.st Fri Jan 20 10:39:47 2017 +0100
@@ -122,12 +122,13 @@
(
(MenuItem
label: 'Size to Fit'
- choice: adjust
+ choice: adjustHolder
choiceValue: fitBig
)
(MenuItem
label: 'Original Size'
- choice: adjust
+ choice: adjustHolder
+ choiceValue: #topLeft
)
)
nil
@@ -308,18 +309,31 @@
#fitBig - big images are shrunk to make it fit the view
#fitSmall - small images are magnified to make it fit the view,
#fit - all images are magnified to fit the view
+ #topLeftNoZoom - image is displayed as usual, and magnification is reset
"
- adjust ~= layoutSymbol ifTrue:[
- adjust := layoutSymbol.
+ |layoutUsed|
+
+ layoutUsed := layoutSymbol.
+ layoutUsed == #topLeftNoZoom ifTrue:[
+ layoutUsed := #topLeft
+ ].
+ self magnificationFactor ~= 1 ifTrue:[
+ self magnificationFactor:1
+ ].
+
+ adjust ~= layoutUsed ifTrue:[
+ adjust := layoutUsed.
adjustHolder notNil ifTrue:[
- adjustHolder value:layoutSymbol withoutNotifying:self
+ adjustHolder value:layoutUsed withoutNotifying:self
].
magnifiedImage := nil.
shown ifTrue:[
image notNil ifTrue:[
- self generateMagnifiedImage.
+ self magnificationFactor ~= 1 ifTrue:[
+ self generateMagnifiedImage.
+ ].
self clear.
self scrollToTopLeft.
self invalidate.
@@ -329,6 +343,26 @@
].
!
+adjustHolder
+ "get a valeHolder for the adjust (how the image is displayed);
+ currently, only support #topLeft, #center, #fitBig, #fitSmall and #fit:
+ #topLeft - image is displayed as usual
+ #center - image is shown centered
+ #fitBig - big images are shrunk to make it fit the view
+ #fitSmall - small images are magnified to make it fit the view,
+ #fit - all images are magnified to fit the view
+ "
+
+ adjustHolder isNil ifTrue:[
+ adjustHolder := self adjust asValue.
+ adjustHolder
+ onChangeEvaluate:[
+ self adjust:(adjustHolder value).
+ ]
+ ].
+ ^ adjustHolder
+!
+
image
"return the image"
@@ -368,10 +402,10 @@
magnificationFactor:aNumber
magnificationFactor ~= aNumber ifTrue:[
magnificationFactor := aNumber.
- "/ magnificationFactor fractionPart < 0.1 ifTrue:[
- "/ "magnifying by integer factor is faster"
- "/ magnificationFactor := magnificationFactor truncated.
- "/ ].
+ "/ magnificationFactor fractionPart < 0.1 ifTrue:[
+ "/ "magnifying by integer factor is faster"
+ "/ magnificationFactor := magnificationFactor truncated.
+ "/ ].
magnifiedImage := nil.
magnificationFactor = 1 ifTrue:[
self contentsChanged.