#REFACTORING by cg draft
authorClaus Gittinger <cg@exept.de>
Mon, 20 Feb 2017 18:09:07 +0100
changeset 3417 4960f19dca36
parent 3416 9d51a45479e3
child 3418 8d56341c2706
#REFACTORING by cg class: ImageEditor added: #autoCropAll #autoCropBottom #autoCropLeft #autoCropRight #autoCropTop #cropSubImageIcon removed: #doCropAll #doCropBottom #doCropLeft #doCropRight #doCropTop changed: #cropSpec #helpPairs #menuEdit
ImageEditor.st
--- a/ImageEditor.st	Mon Feb 20 16:43:16 2017 +0100
+++ b/ImageEditor.st	Mon Feb 20 18:09:07 2017 +0100
@@ -291,6 +291,21 @@
 
     ^ #(
 
+#autoCropAll
+'Find and remove all borders'
+
+#autoCropBottom
+'Find and remove bottom border'
+
+#autoCropLeft
+'Find and remove left border'
+
+#autoCropRight
+'Find and remove right border'
+
+#autoCropTop
+'Find and remove top border'
+
 #colorMap
 'ColorMap functions'
 
@@ -331,22 +346,28 @@
 'Remove unneeded entries from the colorMap'
 
 #cropAll
-'Find and remove all borders'
+'Crop (cut off) all four sides by the amounts entered into the above fields.'
 
 #cropBottom
-'Find and remove bottom border'
+'Cut off the specified number of pixels at the bottom'
+
+#cropBySelectingArea
+'Select new area in the right detail view.'
 
 #cropLeft
-'Find and remove left border'
+'Cut off the specified number of pixels at the left'
 
 #cropManual
 'Specify border(s) to remove.'
 
 #cropRight
-'Find and remove right border'
+'Cut off the specified number of pixels at the right'
 
 #cropTop
-'Find and remove top border'
+'Cut off the specified number of pixels at the top'
+
+#cropubImage
+'Select a subarea as the image''s new dimension'
 
 #drawModeBox
 'Rectangle Drawing Mode'
@@ -439,10 +460,10 @@
 'Paste the image in the clipboard as a mask. Must be a depth-1 image'
 
 #filePrint
-'Print'
+'Print the image on a postscript printer'
 
 #filePrint
-'Print the image on a postscript printer'
+'Print'
 
 #fileSave
 'Save the image'
@@ -465,21 +486,6 @@
 #floodFillMaxError
 'Specify the max. allowed deviation from the clicked pixel in a flood-fill operation.\Pixels where the hue/light values differ less than that fraction\will be included in the fill.\The range must be between 0 and 1. With 0, only areas with exactly the same pixel will be filled.\With 1, every other pixel is included.\\When filling gradiented areas, start with small values, such as 0.05, and increase slowly.'
 
-#cropAll
-'Crop (cut off) all four sides by the amounts entered into the above fields.'
-
-#cropBottom
-'Cut off the specified number of pixels at the bottom'
-
-#cropLeft
-'Cut off the specified number of pixels at the left'
-
-#cropRight
-'Cut off the specified number of pixels at the right'
-
-#cropTop
-'Cut off the specified number of pixels at the top'
-
 #magnificationNumber
 'Shows the current magnification'
 
@@ -554,7 +560,7 @@
 
 )
 
-    "Modified: / 19-02-2017 / 15:10:03 / cg"
+    "Modified: / 20-02-2017 / 18:07:43 / cg"
 !
 
 helpSpec
@@ -641,6 +647,28 @@
         ]
 !
 
+cropSubImageIcon
+    "This resource specification was automatically generated
+     by the ImageEditor of ST/X."
+
+    "Do not manually edit this!! If it is corrupted,
+     the ImageEditor may not be able to read the specification."
+
+    "
+     self cropSubImageIcon inspect
+     ImageEditor openOnClass:self andSelector:#cropSubImageIcon
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'ImageEditor class cropSubImageIcon'
+        ifAbsentPut:[(Depth2Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@J**@@BUU @@%UX@@IUV@@BUU @@%UX@@J**@@@@@@@@@@@@@@@@@@b')
+            colorMapFromArray:#[0 0 0 255 255 255 127 127 127 0 255 0]
+            mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'??2@AH@D OR_=I?4''?R_9K?$/>R?9K0D @S??@@a'); yourself); yourself]
+!
+
 defaultIcon
     <resource: #programImage>
 
@@ -1493,7 +1521,7 @@
           (ActionButtonSpec
              label: 'Crop Now'
              name: 'CropLeftNowButton'
-             layout: (LayoutFrame 133 0 21 0 232 0 50 0)
+             layout: (LayoutFrame 133 0 21 0 229 0 50 0)
              activeHelpKey: cropLeft
              translateLabel: true
              resizeForLabel: true
@@ -1502,6 +1530,18 @@
              autoRepeat: true
              usePreferredWidth: true
            )
+          (ActionButtonSpec
+             label: 'Auto'
+             name: 'Button6'
+             layout: (LayoutFrame 236 0 21 0 289 0 50 0)
+             activeHelpKey: autoCropLeft
+             translateLabel: true
+             resizeForLabel: true
+             tabable: true
+             model: autoCropLeft
+             autoRepeat: true
+             usePreferredWidth: true
+           )
           (LabelSpec
              label: 'Right:'
              name: 'CropRightLabel'
@@ -1523,7 +1563,7 @@
           (ActionButtonSpec
              label: 'Crop Now'
              name: 'CropRightButton'
-             layout: (LayoutFrame 133 0 51 0 232 0 80 0)
+             layout: (LayoutFrame 133 0 51 0 229 0 80 0)
              activeHelpKey: cropRight
              translateLabel: true
              resizeForLabel: true
@@ -1532,6 +1572,18 @@
              autoRepeat: true
              usePreferredWidth: true
            )
+          (ActionButtonSpec
+             label: 'Auto'
+             name: 'Button7'
+             layout: (LayoutFrame 236 0 51 0 289 0 80 0)
+             activeHelpKey: autoCropRight
+             translateLabel: true
+             resizeForLabel: true
+             tabable: true
+             model: autoCropRight
+             autoRepeat: true
+             usePreferredWidth: true
+           )
           (LabelSpec
              label: 'Top:'
              name: 'CropTopLabel'
@@ -1553,7 +1605,7 @@
           (ActionButtonSpec
              label: 'Crop Now'
              name: 'CropTopButton'
-             layout: (LayoutFrame 133 0 81 0 232 0 110 0)
+             layout: (LayoutFrame 133 0 81 0 229 0 110 0)
              activeHelpKey: cropTop
              translateLabel: true
              resizeForLabel: true
@@ -1562,6 +1614,18 @@
              autoRepeat: true
              usePreferredWidth: true
            )
+          (ActionButtonSpec
+             label: 'Auto'
+             name: 'Button8'
+             layout: (LayoutFrame 236 0 81 0 289 0 110 0)
+             activeHelpKey: autoCropTop
+             translateLabel: true
+             resizeForLabel: true
+             tabable: true
+             model: autoCropTop
+             autoRepeat: true
+             usePreferredWidth: true
+           )
           (LabelSpec
              label: 'Bottom:'
              name: 'CropBottomLabel'
@@ -1583,7 +1647,7 @@
           (ActionButtonSpec
              label: 'Crop Now'
              name: 'CropBottomButton'
-             layout: (LayoutFrame 133 0 111 0 232 0 140 0)
+             layout: (LayoutFrame 133 0 111 0 229 0 140 0)
              activeHelpKey: cropBottom
              translateLabel: true
              resizeForLabel: true
@@ -1593,9 +1657,21 @@
              usePreferredWidth: true
            )
           (ActionButtonSpec
-             label: 'Crop All'
+             label: 'Auto'
+             name: 'Button9'
+             layout: (LayoutFrame 236 0 111 0 289 0 140 0)
+             activeHelpKey: autoCropBottom
+             translateLabel: true
+             resizeForLabel: true
+             tabable: true
+             model: autoCropBottom
+             autoRepeat: true
+             usePreferredWidth: true
+           )
+          (ActionButtonSpec
+             label: 'All'
              name: 'Button4'
-             layout: (LayoutFrame 133 0 148 0 268 0 176 0)
+             layout: (LayoutFrame 133 0 148 0 229 0 176 0)
              activeHelpKey: cropAll
              translateLabel: true
              resizeForLabel: true
@@ -1645,6 +1721,16 @@
               
              )
            )
+          (ActionButtonSpec
+             label: 'All'
+             name: 'Button10'
+             layout: (LayoutFrame 236 0 148 0 289 0 176 0)
+             activeHelpKey: autoCropAll
+             translateLabel: true
+             resizeForLabel: true
+             tabable: true
+             model: autoCropAll
+           )
           )
         
        )
@@ -3013,32 +3099,32 @@
                   isVisible: false
                 )
                (MenuItem
-                  activeHelpKey: cropAll
+                  activeHelpKey: autoCropAll
                   label: 'All'
-                  itemValue: doCropAll
+                  itemValue: autoCropAll
                 )
                (MenuItem
                   label: '-'
                 )
                (MenuItem
-                  activeHelpKey: cropLeft
+                  activeHelpKey: autoCropLeft
                   label: 'Left'
-                  itemValue: doCropLeft
+                  itemValue: autoCropLeft
                 )
                (MenuItem
-                  activeHelpKey: cropRight
+                  activeHelpKey: autoCropRight
                   label: 'Right'
-                  itemValue: doCropRight
+                  itemValue: autoCropRight
                 )
                (MenuItem
-                  activeHelpKey: cropTop
+                  activeHelpKey: autoCropTop
                   label: 'Top'
-                  itemValue: doCropTop
+                  itemValue: autoCropTop
                 )
                (MenuItem
-                  activeHelpKey: cropBottom
+                  activeHelpKey: autoCropBottom
                   label: 'Bottom'
-                  itemValue: doCropBottom
+                  itemValue: autoCropBottom
                 )
                )
               nil
@@ -3107,6 +3193,8 @@
         nil
         nil
       )
+
+    "Modified: / 20-02-2017 / 18:05:19 / cg"
 !
 
 menuFile
@@ -7023,6 +7111,51 @@
 
 !ImageEditor methodsFor:'user actions-editing'!
 
+autoCropAll
+    "find all borders and cut them off"
+
+    imageEditView autoCropLeft:true right:true top:true bottom:true.   
+    self updateInfoLabel
+
+    "Created: / 20-02-2017 / 18:05:38 / cg"
+!
+
+autoCropBottom
+    "find a bottom border and cut it off"
+
+    imageEditView autoCropLeft:false right:false top:false bottom:true.   
+    self updateInfoLabel
+
+    "Created: / 20-02-2017 / 18:05:45 / cg"
+!
+
+autoCropLeft
+    "find a left border and cut it off"
+
+    imageEditView autoCropLeft:true right:false top:false bottom:false.   
+    self updateInfoLabel
+
+    "Created: / 20-02-2017 / 18:05:52 / cg"
+!
+
+autoCropRight
+    "find a right border and cut it off"
+
+    imageEditView autoCropLeft:false right:true top:false bottom:false.   
+    self updateInfoLabel
+
+    "Created: / 20-02-2017 / 18:04:20 / cg"
+!
+
+autoCropTop
+    "find a top border and cut it off"
+
+    imageEditView autoCropLeft:false right:false top:true bottom:false.   
+    self updateInfoLabel
+
+    "Created: / 20-02-2017 / 18:06:03 / cg"
+!
+
 do3DProjection
     |box dx1 dx2 image|
 
@@ -7077,36 +7210,6 @@
     imageEditView copyImageToClipboard.
 !
 
-doCropAll
-    "find all borders and cut them off"
-
-    imageEditView cropLeft:true right:true top:true bottom:true.   
-    self updateInfoLabel
-
-    "Modified: / 7.9.1998 / 14:26:23 / cg"
-    "Created: / 7.9.1998 / 16:33:43 / cg"
-!
-
-doCropBottom
-    "find a bottom border and cut it off"
-
-    imageEditView cropLeft:false right:false top:false bottom:true.   
-    self updateInfoLabel
-
-    "Created: / 7.9.1998 / 13:00:20 / cg"
-    "Modified: / 7.9.1998 / 14:26:23 / cg"
-!
-
-doCropLeft
-    "find a left border and cut it off"
-
-    imageEditView cropLeft:true right:false top:false bottom:false.   
-    self updateInfoLabel
-
-    "Created: / 7.9.1998 / 13:00:14 / cg"
-    "Modified: / 7.9.1998 / 14:26:34 / cg"
-!
-
 doCropManual
     "let user specify borders and cut them off"
 
@@ -7171,26 +7274,6 @@
     "Modified: / 19-02-2017 / 15:43:50 / cg"
 !
 
-doCropRight
-    "find a right border and cut it off"
-
-    imageEditView cropLeft:false right:true top:false bottom:false.   
-    self updateInfoLabel
-
-    "Created: / 7.9.1998 / 13:00:14 / cg"
-    "Modified: / 7.9.1998 / 14:26:44 / cg"
-!
-
-doCropTop
-    "find a top border and cut it off"
-
-    imageEditView cropLeft:false right:false top:true bottom:false.   
-    self updateInfoLabel
-
-    "Created: / 7.9.1998 / 13:00:19 / cg"
-    "Modified: / 7.9.1998 / 14:26:52 / cg"
-!
-
 doDarkenImage
     imageEditView darkenImage.
     self listOfColors removeAll.