#UI_ENHANCEMENT by cg
authorClaus Gittinger <cg@exept.de>
Wed, 22 Feb 2017 19:56:19 +0100
changeset 3418 8d56341c2706
parent 3417 4960f19dca36
child 3419 dda4a17fdefc
#UI_ENHANCEMENT by cg class: ImageEditor added: #emptyIcon #emptyIcon2 #fillDiagonalGradientRectIcon changed: #fillHorizontalGradientRectIcon #fillVerticalGradientRectIcon #modeMenu #processSelectedColorsWith:
ImageEditor.st
--- a/ImageEditor.st	Mon Feb 20 18:09:07 2017 +0100
+++ b/ImageEditor.st	Wed Feb 22 19:56:19 2017 +0100
@@ -675,6 +675,54 @@
     ^ ToolbarIconLibrary startImageEditorIcon
 !
 
+emptyIcon
+    "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 emptyIcon inspect
+     ImageEditor openOnClass:self andSelector:#emptyIcon
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'ImageEditor class emptyIcon'
+        ifAbsentPut:[(Depth4Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+@@@@@@@@@@@b')
+            colorMapFromArray:#[0 0 0]
+            mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a'); yourself); yourself]
+!
+
+emptyIcon2
+    "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 emptyIcon2 inspect
+     ImageEditor openOnClass:self andSelector:#emptyIcon2
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'ImageEditor class emptyIcon2'
+        ifAbsentPut:[(Depth4Image width:28 height:14) bits:(ByteArray fromPackedString:'
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+@@@@@@@@@@@@@@@@@@@@@@@a')
+            colorMapFromArray:#[0 0 0]
+            mask:((Depth1Image width:28 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b'); yourself); yourself]
+!
+
 fillCircleIcon
     "This resource specification was automatically generated
      by the ImageEditor of ST/X."
@@ -697,6 +745,29 @@
             mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@N@C>@_<A?0O? ?>C?8G?@_<@? @8@@@@@a'); yourself); yourself]
 !
 
+fillDiagonalGradientRectIcon
+    "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 fillDiagonalGradientRectIcon inspect
+     ImageEditor openOnClass:self andSelector:#fillDiagonalGradientRectIcon
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'ImageEditor class fillDiagonalGradientRectIcon'
+        ifAbsentPut:[(Depth4Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@QDQDQD@@@DQDQDQ@@@ADH"H"H@@@QBH"H"@@@DP"L3L0@@ADH#L3L@@@QBH3DQ@@@DP"L1DP@@ADH#LQD@@@@@@@@@
+@@@@@@@@@@@b')
+            colorMapFromArray:#[0 0 0 255 0 0 127 0 0 191 0 0 91 0 0]
+            mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@C?0O?@?<C?0O?@?<C?0O?@?<C?0@@@@@@@a'); yourself); yourself]
+!
+
 fillGradientRectIcon
     <resource: #image>
     "This resource specification was automatically generated
@@ -731,36 +802,26 @@
 !
 
 fillHorizontalGradientRectIcon
-    <resource: #image>
     "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 fillHorizontalGradientRectIcon inspect
      ImageEditor openOnClass:self andSelector:#fillHorizontalGradientRectIcon
-     Icon flushCachedIcons"
-    
-    ^ Icon constantNamed:'ImageEditor class fillHorizontalGradientRectIcon'
-        ifAbsentPut:[
-            (Depth4Image new)
-                width:14;
-                height:14;
-                photometric:(#palette);
-                bitsPerSample:(#[ 4 ]);
-                samplesPerPixel:(1);
-                bits:(ByteArray 
-                            fromPackedString:'@@@@@@@@@@@@@@@@@@@@@DP"L1D@@@ADH#LQ@@@@QBH3DP@@@DP"L1D@@@ADH#LQ@@@@QBH3DP@@@DP"L1D@@@ADH#LQ@@@@QBH3DP@@@DP"L1D@@@@@@@@@
-@@@@@@@@@@@b');
-                colorMapFromArray:#[ 0 0 0 255 0 0 127 0 0 191 0 0 63 0 0 ];
-                mask:((ImageMask new)
-                            width:14;
-                            height:14;
-                            bits:(ByteArray 
-                                        fromPackedString:'@@@@@C?0O?@?<C?0O?@?<C?0O?@?<C?0@@@@@@@a');
-                            yourself);
-                yourself
-        ]
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'ImageEditor class fillHorizontalGradientRectIcon'
+        ifAbsentPut:[(Depth4Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@ADH#LQD@@@QBH3DQ@@@DP"L1DP@@ADH#LQD@@@QBH3DQ@@@DP"L1DP@@ADH#LQD@@@QBH3DQ@@@DP"L1DP@@ADH#LQD@@@@@@@@@
+@@@@@@@@@@@b')
+            colorMapFromArray:#[0 0 0 255 0 0 127 0 0 191 0 0 91 0 0]
+            mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@C?0O?@?<C?0O?@?<C?0O?@?<C?0@@@@@@@a'); yourself); yourself]
 !
 
 fillIcon
@@ -828,38 +889,26 @@
 !
 
 fillVerticalGradientRectIcon
-    <resource: #image>
     "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 fillGradientRectIcon inspect
-     ImageEditor openOnClass:self andSelector:#fillGradientRectIcon
-     Icon flushCachedIcons"
-    
-    ^ Icon constantNamed:'ImageEditor class fillGradientRectIcon'
-        ifAbsentPut:[
-            (Depth4Image new)
-                width:14;
-                height:14;
-                photometric:(#palette);
-                bitsPerSample:(#[ 4 ]);
-                samplesPerPixel:(1);
-                bits:(ByteArray 
-                            fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ADQDQDQ@@@QDQDQDP@@BH"H"H"@@@"H"H"H @@L3L3L3L@@CL3L3L3@@@QDQDQDP@@DQDQDQD@@@@@@@@@
-@@@@@@@@@@@b');
-                colorMapFromArray:#[ 0 0 0 255 0 0 127 0 0 191 0 0 63 0 0 ];
-                mask:((ImageMask new)
-                            width:14;
-                            height:14;
-                            bits:(ByteArray 
-                                        fromPackedString:'@@@@@C?0O?@?<C?0O?@?<C?0O?@?<C?0@@@@@@@a');
-                            yourself);
-                yourself
-        ]
-
-    "Created: / 19-01-2012 / 13:44:51 / cg"
+     self fillVerticalGradientRectIcon inspect
+     ImageEditor openOnClass:self andSelector:#fillVerticalGradientRectIcon
+     Icon flushCachedIcons
+    "
+
+    <resource: #image>
+
+    ^Icon
+        constantNamed:'ImageEditor class fillVerticalGradientRectIcon'
+        ifAbsentPut:[(Depth4Image width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@DQDQDQD@@ADQDQDQ@@@H"H"H"H@@BH"H"H"@@@3L3L3L0@@L3L3L3L@@ADQDQDQ@@@QDQDQDP@@DQDQDQD@@@@@@@@@
+@@@@@@@@@@@b')
+            colorMapFromArray:#[0 0 0 255 0 0 127 0 0 191 0 0 91 0 0]
+            mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'@@@@@C?0O?@?<C?0O?@?<C?0O?@?<C?0@@@@@@@a'); yourself); yourself]
 !
 
 flipHorizontalIcon
@@ -3723,6 +3772,42 @@
             choiceValue: fill
           )
          (MenuItem
+            enabled: imageIsLoadedHolder
+            label: 'Gradient Fill'
+            isVisible: false
+            submenu: 
+           (Menu
+              (
+               (MenuItem
+                  activeHelpKey: drawModeFill
+                  enabled: imageIsLoadedHolder
+                  label: 'Horizontal'
+                  labelImage: (ResourceRetriever ImageEditor fillHorizontalGradientRectIcon 'Horizontal')
+                  choice: editMode
+                  choiceValue: fillHorizontalGradient
+                )
+               (MenuItem
+                  activeHelpKey: drawModeFill
+                  enabled: imageIsLoadedHolder
+                  label: 'Vertical'
+                  labelImage: (ResourceRetriever ImageEditor fillVerticalGradientRectIcon 'Vertical')
+                  choice: editMode
+                  choiceValue: fillVerticalGradient
+                )
+               (MenuItem
+                  activeHelpKey: drawModeFill
+                  enabled: imageIsLoadedHolder
+                  label: 'Diagonal'
+                  labelImage: (ResourceRetriever ImageEditor fillDiagonalGradientRectIcon 'Diagonal')
+                  choice: editMode
+                  choiceValue: fillDiagonalGradient
+                )
+               )
+              nil
+              nil
+            )
+          )
+         (MenuItem
             label: '-'
           )
          (MenuItem
@@ -6820,18 +6905,22 @@
         maskOffset := 0.
     ].
     cMap := img colorMap.
-    (cMap isNil or:[cMap isMappedPalette or:[cMap isFixedPalette]]) ifTrue:[
+    (cMap isNil) ifTrue:[
         oldColors := drawingColormap
     ] ifFalse:[    
-        oldColors := selectedColorIndices collect:[:idx | cMap at:idx-maskOffset].
+        (cMap isMappedPalette or:[cMap isFixedPalette]) ifTrue:[
+            oldColors := cMap asArray
+        ] ifFalse:[    
+            oldColors := selectedColorIndices collect:[:idx | cMap at:idx-maskOffset].
+        ].
     ].
     imageEditView makeUndo.
 
     modifiedColormap := cMap asNewArray.
 
     newColors := oldColors collect:aBlock.
-    selectedColorIndices with:newColors do:[:idx :newColor | 
-        modifiedColormap at:idx-maskOffset put:newColor
+    selectedColorIndices do:[:idx |
+        modifiedColormap at:idx-maskOffset put:(newColors at:idx)
     ].
 
     newImage := img species new
@@ -6840,10 +6929,11 @@
                     depth:img depth
                     fromArray:img bits.
 
-    (cMap isNil or:[cMap isMappedPalette or:[cMap isFixedPalette]]) ifTrue:[
+    (cMap isNil) ifTrue:[
         "/ only a dummy...
     ] ifFalse:[    
         newImage colorMap:modifiedColormap.  
+        newImage photometric:#palette.  
     ].
     newImage fileName:img fileName.
     newImage mask:(img mask copy).
@@ -6853,7 +6943,7 @@
     ].
     self selectedColors value:selectedColorIndices.
 
-    "Modified: / 03-02-2017 / 22:05:33 / cg"
+    "Modified: / 22-02-2017 / 19:45:29 / cg"
 !
 
 reduceNumberOfColors