#UI_ENHANCEMENT by cg
authorClaus Gittinger <cg@exept.de>
Tue, 27 Mar 2018 13:42:15 +0200
changeset 3550 b31b44c04a3e
parent 3549 e0d71b4fe967
child 3551 94a23bbd725b
#UI_ENHANCEMENT by cg class: ImageEditor class definition changed: #doMagnifyImage #doMagnifyImageBy remember user's last choice of magnification and smoothing
ImageEditor.st
--- a/ImageEditor.st	Mon Mar 19 17:56:07 2018 +0100
+++ b/ImageEditor.st	Tue Mar 27 13:42:15 2018 +0200
@@ -20,7 +20,8 @@
 		allowedToChangeImageDimensionAndDepth savedImage savedFile'
 	classVariableNames:'DefaultRelativeSizes LastColormapMode LastDirectory
 		LastSizeString LastURL MaskClipboard LastDepth
-		LastNumThresholdGrayColors'
+		LastNumThresholdGrayColors LastMagnifyTo LastMagnifyBy
+		LastMagnifySmoothing'
 	poolDictionaries:''
 	category:'Interface-UIPainter'
 !
@@ -8333,14 +8334,14 @@
 
     |box newSize image antiAliased|
 
-    antiAliased := false asValue.
+    antiAliased := (LastMagnifySmoothing ? false) asValue.
     image := imageEditView image.
 
     box := EnterBox new.
     box title:(resources string:'Images new size:').
     box okText:(resources string:'OK').
     box abortText:(resources string:'Cancel').
-    box initialText:image extent printString.
+    box initialText:(LastMagnifyTo ? image extent) printString.
     box verticalPanel add:(CheckBox label:(resources string:'Antialias/Smooth') model:antiAliased).
     box showAtPointer.
     
@@ -8351,6 +8352,8 @@
             self warn:'Please enter the new size as ''x @ y''.'.
             ^ self.    
         ].
+        LastMagnifyTo := newSize.
+        LastMagnifySmoothing := antiAliased value.
         antiAliased value ifTrue:[
             ((newSize x < image width) or:[(newSize y < image height)]) ifTrue:[
                 imageEditView magnifySmoothingTo:newSize.    
@@ -8370,21 +8373,20 @@
 doMagnifyImageBy
     "magnifies the current image (by a scale)"
 
-    |oldSize newSize scaleString scale image antiAliased smoothing|
+    |oldSize newSize scaleString scale image smoothing|
 
     image := imageEditView image.
     oldSize := image extent.
 
-    antiAliased := false asValue.
-    smoothing := false asValue.
+    smoothing := (LastMagnifySmoothing ? false) asValue.
     
     Dialog modifyingBoxWith:[:box |
-        box verticalPanel add:(CheckBox label:(resources string:'Antialias/Smooth') model:antiAliased).
+        box verticalPanel add:(CheckBox label:(resources string:'Antialias/Smooth') model:smoothing).
         "/ box verticalPanel add:(CheckBox label:(resources string:'Smoothing') model:smoothing).
     ] do:[
         scaleString := Dialog 
                    request:(resources string:'Scale factor (<1 to shrink; >1 to magnify):') 
-                   initialAnswer:'1'
+                   initialAnswer:(LastMagnifyBy ? 1) printString
                    list:#('0.1' '0.25' '0.3' '0.5' '1.5' '2' '3' '4').     
     ].
     scaleString isNil ifTrue:[^ self].
@@ -8396,8 +8398,12 @@
             self warn:'please enter a scale factor (<1 to shrink; >1 to magnify).'.
             ^ self.    
         ].
+
+        LastMagnifyBy := scale.
+        LastMagnifySmoothing := smoothing value.
+
         newSize := oldSize * scale.
-        antiAliased value ifTrue:[
+        smoothing value ifTrue:[
             scale < 1 ifTrue:[
                 imageEditView magnifySmoothingBy:scale.
             ] ifFalse:[