#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Mon, 11 Sep 2017 09:08:17 +0200
changeset 3489 ed003c06c33b
parent 3488 e9655ba452c7
child 3490 e3b6106384a8
#FEATURE by cg class: ImageEditor added: #changePreviewImageMagnification #previewMagnificationHolder changed: #processEvent: #update:with:from: (send #magnification: instead of #magnificationFactor:) class: ImageEditor class changed: #previewMenu
ImageEditor.st
--- a/ImageEditor.st	Tue Sep 05 16:46:03 2017 +0200
+++ b/ImageEditor.st	Mon Sep 11 09:08:17 2017 +0200
@@ -3879,6 +3879,7 @@
     "Do not manually edit this!! If it is corrupted,
      the MenuEditor may not be able to read the specification."
 
+
     "
      MenuEditor new openOnClass:ImageEditor andSelector:#previewMenu
      (Menu new fromLiteralArrayEncoding:(ImageEditor previewMenu)) startUp
@@ -3891,7 +3892,6 @@
         (
          (MenuItem
             label: 'TileMode'
-            translateLabel: true
             indication: tileModeHolder
           )
          (MenuItem
@@ -3899,25 +3899,20 @@
           )
          (MenuItem
             label: 'Background Color'
-            translateLabel: true
             submenu: 
            (Menu
               (
                (MenuItem
                   label: 'Gray'
-                  translateLabel: true
                   choice: previewBackgroundColorHolder
-                  choiceValue: nil
                 )
                (MenuItem
                   label: 'Black'
-                  translateLabel: true
                   choice: previewBackgroundColorHolder
                   choiceValue: black
                 )
                (MenuItem
                   label: 'White'
-                  translateLabel: true
                   choice: previewBackgroundColorHolder
                   choiceValue: white
                 )
@@ -3926,19 +3921,16 @@
                 )
                (MenuItem
                   label: 'Red'
-                  translateLabel: true
                   choice: previewBackgroundColorHolder
                   choiceValue: red
                 )
                (MenuItem
                   label: 'Green'
-                  translateLabel: true
                   choice: previewBackgroundColorHolder
                   choiceValue: green
                 )
                (MenuItem
                   label: 'Blue'
-                  translateLabel: true
                   choice: previewBackgroundColorHolder
                   choiceValue: blue
                 )
@@ -3947,12 +3939,62 @@
               nil
             )
           )
+         (MenuItem
+            label: '-'
+          )
+         (MenuItem
+            label: 'Magnification'
+            submenu: 
+           (Menu
+              (
+               (MenuItem
+                  label: '0.1'
+                  choice: previewMagnificationHolder
+                  choiceValue: 0.1
+                )
+               (MenuItem
+                  label: '0.25'
+                  choice: previewMagnificationHolder
+                  choiceValue: 0.25
+                )
+               (MenuItem
+                  label: '0.5'
+                  choice: previewMagnificationHolder
+                  choiceValue: 0.5
+                )
+               (MenuItem
+                  label: '1'
+                  choice: previewMagnificationHolder
+                  choiceValue: 1
+                )
+               (MenuItem
+                  label: '2'
+                  choice: previewMagnificationHolder
+                  choiceValue: 2
+                )
+               (MenuItem
+                  label: '4'
+                  choice: previewMagnificationHolder
+                  choiceValue: 4
+                )
+               (MenuItem
+                  label: '-'
+                )
+               (MenuItem
+                  label: 'Choose...'
+                  itemValue: changePreviewImageMagnification
+                )
+               )
+              nil
+              nil
+            )
+          )
          )
         nil
         nil
       )
 
-    "Modified: / 04-07-2010 / 10:20:09 / cg"
+    "Modified: / 10-09-2017 / 14:54:41 / cg"
 !
 
 toolsMenuToolbar
@@ -4780,6 +4822,18 @@
     "Created: / 04-07-2010 / 10:19:34 / cg"
 !
 
+previewMagnificationHolder
+    |holder|
+
+    (holder := builder bindingAt:#previewMagnificationHolder) isNil ifTrue:[
+        builder aspectAt:#previewMagnificationHolder put:(holder := 1 asValue).
+        holder addDependent:self.
+    ].
+    ^ holder
+
+    "Created: / 10-09-2017 / 14:10:07 / cg"
+!
+
 readOnly
     ^ false
 !
@@ -4849,6 +4903,19 @@
 
 !ImageEditor methodsFor:'change & update'!
 
+changePreviewImageMagnification
+    |mag|
+
+    mag := Dialog request:'Magnification?' initialAnswer:self imagePreView magnificationFactor.
+    mag isEmptyOrNil ifTrue:[^ self].
+    mag := Number readFrom:mag onError:nil.
+    mag isNil ifTrue:[^ self].
+
+    self previewMagnificationHolder value:mag
+
+    "Created: / 10-09-2017 / 14:52:52 / cg"
+!
+
 colorCropTabSelectionIndexChanged
     |selIndex sym|
 
@@ -4974,6 +5041,7 @@
             invalidate.
         ^ self
     ].
+    
     changedObject == self previewBackgroundColorHolder ifTrue:[
         clr := changedObject value isNil 
                     ifTrue:[imageEditView viewBackground]
@@ -4984,7 +5052,15 @@
             invalidate.
         ^ self
     ].
-
+    changedObject == self previewMagnificationHolder ifTrue:[
+        imagePreView 
+            magnificationFactor:(self previewMagnificationHolder value);
+            clear; 
+            invalidate;
+            yourself.
+        ^ self.    
+    ].
+    
     changedObject == self listOfColors ifTrue:[
         something == #at: ifTrue:[
             "/ colormap entry changed at aParameter
@@ -5073,7 +5149,7 @@
 
     super update:something with:aParameter from:changedObject
 
-    "Modified: / 05-09-2017 / 09:04:21 / cg"
+    "Modified: / 10-09-2017 / 14:56:00 / cg"
 !
 
 updateAfterImageChange
@@ -5383,10 +5459,11 @@
         view == self imagePreView ifTrue:[
             ((anEvent isButtonPressEvent and:[ anEvent button == 1 ])
             or:[ anEvent isButtonMotionEvent and:[ anEvent hasButton1 ]])  ifTrue:[
-                p := anEvent x @ anEvent y.
+                p := anEvent x @ anEvent y.                
                 (transformation := view transformation) notNil ifTrue:[
                     p := transformation applyInverseTo:p.
                 ].
+                p := p / self previewMagnificationHolder value.
                 self imageEditView scrollToMakeVisible:p.    
                 ^ true.
             ].
@@ -5408,8 +5485,7 @@
     ].
     ^ false.
 
-    "Modified: / 04-04-2011 / 13:50:09 / cg"
-    "Modified (format): / 16-02-2017 / 09:54:01 / cg"
+    "Modified: / 10-09-2017 / 16:40:13 / cg"
 ! !
 
 !ImageEditor methodsFor:'help'!