#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Sun, 27 May 2018 15:01:39 +0200
changeset 3562 dc310a9c9b19
parent 3561 b309d1d1b45c
child 3563 9d419a3f766a
#FEATURE by cg class: ImageEditor changed: #changeHLS class: ImageEditor class comment/format in: #helpPairs changed: #changeHLSDialogSpec
ImageEditor.st
--- a/ImageEditor.st	Sun May 27 11:33:44 2018 +0200
+++ b/ImageEditor.st	Sun May 27 15:01:39 2018 +0200
@@ -324,15 +324,6 @@
 
     ^ #(
 
-#drawingColor1
-'The color associated to the left mouse button.\Also the color used in fill operations'
-
-#drawingColor2
-'The color associated to the right mouse button.\Also the second color used in gradient fill operations'
-
-#drawingAlpha
-'The alpha value (in percent) to be used in edit operations.\If the "mask"-color is selected, only the alpha value will be changed.\Otherwise, the selected color plus this alpha value will be used for drawing'
-
 #autoCropAll
 'Find and remove all borders'
 
@@ -441,12 +432,12 @@
 #drawModePaste
 'Paste-Over Mode (only paste pixels; keep mask as is)'
 
+#drawModePasteMasked
+'Paste-Under Mode (only paste previously masked pixels)'
+
 #drawModePasteUnder
 'Paste-Under Mode (only paste previously masked pixels where the new pixel is also masked)'
 
-#drawModePasteMasked
-'Paste-Under Mode (only paste previously masked pixels)'
-
 #drawModePasteWithMask
 'Paste-with-Mask Mode (both pixel and mask are pasted)'
 
@@ -459,6 +450,15 @@
 #drawModeSpray
 'Spray Drawing Mode'
 
+#drawingAlpha
+'The alpha value (in percent) to be used in edit operations.\If the "mask"-color is selected, only the alpha value will be changed.\Otherwise, the selected color plus this alpha value will be used for drawing'
+
+#drawingColor1
+'The color associated to the left mouse button.\Also the color used in fill operations'
+
+#drawingColor2
+'The color associated to the right mouse button.\Also the second color used in gradient fill operations'
+
 #edit3DProjection
 'Generate a 3D projection'
 
@@ -534,6 +534,12 @@
 #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 (undo and try with higher value).\This is especially useful when masking background areas from screenshots.'
 
+#hueShift
+''
+
+#lightFactor
+''
+
 #magnificationNumber
 'Shows the current magnification'
 
@@ -555,6 +561,18 @@
 #previousImageInSequence
 'Go to the previous image in the animated gif image sequence.'
 
+#resetHueShift
+'Reset the hue shift to zero (for unchanged hue)'
+
+#resetLightFactor
+'Reset the light factor to 1 (for unchanged brightness)'
+
+#resetSaturationFactor
+'Reset the saturation factor to 1 (for unchanged saturation)'
+
+#saturationFactor
+''
+
 #settingsGridMagnification
 'Change the grid magnification of the edit view'
 
@@ -608,8 +626,7 @@
 
 )
 
-    "Modified: / 07-12-2017 / 15:32:58 / cg"
-    "Modified: / 27-05-2018 / 10:44:41 / Claus Gittinger"
+    "Modified: / 27-05-2018 / 12:16:51 / Claus Gittinger"
 !
 
 helpSpec
@@ -1506,10 +1523,12 @@
     ^ 
     #(FullSpec
        name: changeHLSDialogSpec
+       uuid: 'b5dfeb64-6197-11e8-a86d-b8f6b1108e05'
        window: 
       (WindowSpec
          label: 'HLS Edit Dialog'
          name: 'HLS Edit Dialog'
+         uuid: '3787f3b8-6194-11e8-a86d-b8f6b1108e05'
          min: (Point 10 10)
          bounds: (Rectangle 0 0 378 312)
        )
@@ -1519,90 +1538,136 @@
           (LabelSpec
              label: 'Hue-Shift:'
              name: 'HueLabel'
-             layout: (LayoutFrame 20 0 21 0 187 0 43 0)
+             layout: (LayoutFrame 4 0 21 0 171 0 43 0)
+             activeHelpKey: hueShift
+             uuid: '3787f638-6194-11e8-a86d-b8f6b1108e05'
              translateLabel: true
              adjust: right
            )
           (InputFieldSpec
              name: 'HueShiftEntryField'
-             layout: (LayoutFrame 194 0 21 0 237 0 43 0)
+             layout: (LayoutFrame 172 0 21 0 243 0 43 0)
+             activeHelpKey: hueShift
+             uuid: '3787f84a-6194-11e8-a86d-b8f6b1108e05'
              tabable: true
-             model: hueShiftAmount
+             model: hueShiftHolder
              type: numberInRange
              minValue: 0
              maxValue: 360
              acceptChannel: acceptChannel
-             acceptOnPointerLeave: false
+             acceptOnPointerLeave: true
            )
           (ThumbWheelSpec
              name: 'HueWheel'
              layout: (LayoutFrame 246 0 22 0 363 0 42 0)
-             model: hueShiftAmount
+             activeHelpKey: hueShift
+             uuid: '3787fafc-6194-11e8-a86d-b8f6b1108e05'
+             model: hueShiftHolder
              orientation: horizontal
              step: 1
              endlessRotation: true
            )
+          (ActionButtonSpec
+             name: 'resetHueShift'
+             layout: (LayoutFrame -10 1 27 0 0 1 37 0)
+             activeHelpKey: resetHueShift
+             uuid: 'e8c1e754-6196-11e8-a86d-b8f6b1108e05'
+             translateLabel: true
+             model: resetHueShift
+           )
           (LabelSpec
              label: 'Light Factor:'
              name: 'LightLabel'
-             layout: (LayoutFrame 20 0 50 0 187 0 72 0)
+             layout: (LayoutFrame 4 0 50 0 171 0 72 0)
+             activeHelpKey: lightFactor
+             uuid: '3787fda4-6194-11e8-a86d-b8f6b1108e05'
              translateLabel: true
              adjust: right
            )
           (InputFieldSpec
              name: 'LightEntryField'
-             layout: (LayoutFrame 194 0 50 0 237 0 72 0)
+             layout: (LayoutFrame 172 0 50 0 243 0 72 0)
+             activeHelpKey: lightFactor
+             uuid: '3787feee-6194-11e8-a86d-b8f6b1108e05'
              tabable: true
-             model: lightAmount
+             model: lightFactorHolder
              type: numberInRange
-             minValue: 0
-             maxValue: 1000
+             minValue: 0.0
+             maxValue: 10.0
              acceptChannel: acceptChannel
-             acceptOnPointerLeave: false
+             acceptOnPointerLeave: true
            )
           (ThumbWheelSpec
              name: 'LightWheel'
              layout: (LayoutFrame 246 0 51 0 363 0 71 0)
-             model: lightAmount
+             activeHelpKey: lightFactor
+             uuid: '378800d8-6194-11e8-a86d-b8f6b1108e05'
+             model: lightFactorHolder
              orientation: horizontal
-             stop: 1000
-             step: 1
+             start: 0.0
+             stop: 10.0
+             step: 0.001
+           )
+          (ActionButtonSpec
+             name: 'Button3'
+             layout: (LayoutFrame -10 1 56 0 0 1 66 0)
+             activeHelpKey: resetLightFactor
+             uuid: 'e8c1eb50-6196-11e8-a86d-b8f6b1108e05'
+             translateLabel: true
+             model: resetLightFactor
            )
           (LabelSpec
              label: 'Saturation Factor:'
              name: 'SaturationLabel'
-             layout: (LayoutFrame 20 0 79 0 187 0 101 0)
+             layout: (LayoutFrame 4 0 79 0 171 0 101 0)
+             activeHelpKey: saturationFactor
+             uuid: '3788022c-6194-11e8-a86d-b8f6b1108e05'
              translateLabel: true
              adjust: right
            )
           (InputFieldSpec
              name: 'SaturationEntryField'
-             layout: (LayoutFrame 194 0 79 0 237 0 101 0)
+             layout: (LayoutFrame 172 0 79 0 243 0 101 0)
+             activeHelpKey: saturationFactor
+             uuid: '37880358-6194-11e8-a86d-b8f6b1108e05'
              tabable: true
-             model: saturationAmount
+             model: saturationFactorHolder
              type: numberInRange
-             minValue: 0
-             maxValue: 1000
+             minValue: 0.0
+             maxValue: 10.0
              acceptChannel: acceptChannel
-             acceptOnPointerLeave: false
+             acceptOnPointerLeave: true
            )
           (ThumbWheelSpec
              name: 'SaturationWheel'
              layout: (LayoutFrame 246 0 80 0 363 0 100 0)
-             model: saturationAmount
+             activeHelpKey: saturationFactor
+             uuid: '3788051a-6194-11e8-a86d-b8f6b1108e05'
+             model: saturationFactorHolder
              orientation: horizontal
-             stop: 1000
-             step: 1
+             start: 0.0
+             stop: 10.0
+             step: 0.001
+           )
+          (ActionButtonSpec
+             name: 'Button4'
+             layout: (LayoutFrame -10 1 85 0 0 1 95 0)
+             activeHelpKey: resetSaturationFactor
+             uuid: 'e8c1efce-6196-11e8-a86d-b8f6b1108e05'
+             translateLabel: true
+             model: resetSaturationFactor
            )
           (LabelSpec
              label: 'Color Shift'
              name: 'Label2'
              layout: (LayoutFrame 5 0 127 0 -15 0.5 149 0)
+             uuid: '37880650-6194-11e8-a86d-b8f6b1108e05'
              translateLabel: true
            )
           (LabelSpec
              name: 'HueColorLabel'
              layout: (LayoutFrame 18 0.0 150 0 -41 0.5 234 0)
+             uuid: '37880768-6194-11e8-a86d-b8f6b1108e05'
              level: -1
              backgroundChannel: hlsColor
              translateLabel: true
@@ -1611,18 +1676,21 @@
              label: 'Preview'
              name: 'Label3'
              layout: (LayoutFrame 5 0.5 127 0 -5 1 149 0)
+             uuid: '37880894-6194-11e8-a86d-b8f6b1108e05'
              translateLabel: true
            )
           (LabelSpec
              name: 'PreviewLabel'
              layout: (LayoutFrame 36 0.5 150 0 -23 1.0 234 0)
+             uuid: '378809ac-6194-11e8-a86d-b8f6b1108e05'
              level: -1
              translateLabel: true
              labelChannel: previewImageHolder
            )
           (HorizontalPanelViewSpec
              name: 'HorizontalPanel1'
-             layout: (LayoutFrame 0 0.0 -30 1 0 1.0 0 1)
+             layout: (LayoutFrame 0 0.0 -30 1 -16 1.0 0 1)
+             uuid: '37880ace-6194-11e8-a86d-b8f6b1108e05'
              horizontalLayout: fitSpace
              verticalLayout: center
              horizontalSpace: 3
@@ -1634,18 +1702,20 @@
                 (ActionButtonSpec
                    label: 'Cancel'
                    name: 'Button1'
+                   uuid: '37880cd6-6194-11e8-a86d-b8f6b1108e05'
                    translateLabel: true
                    tabable: true
                    model: cancel
-                   extent: (Point 183 28)
+                   extent: (Point 175 28)
                  )
                 (ActionButtonSpec
                    label: 'OK'
                    name: 'Button2'
+                   uuid: '37880ee8-6194-11e8-a86d-b8f6b1108e05'
                    translateLabel: true
                    tabable: true
                    model: accept
-                   extent: (Point 183 28)
+                   extent: (Point 175 28)
                  )
                 )
               
@@ -1656,6 +1726,8 @@
         
        )
      )
+
+    "Modified: / 27-05-2018 / 12:27:58 / Claus Gittinger"
 !
 
 cropSpec
@@ -6575,7 +6647,7 @@
 changeHLS
     "interactive Hue/Light/Saturation editing with thumbWheels"
 
-    |bindings hueShift lightValue saturationValue originalColormap firstChange acceptChannel 
+    |bindings hueShiftHolder lightFactorHolder saturationFactorHolder originalColormap firstChange acceptChannel 
      shiftAction originalAvgColor avgColorHolder avgColor shiftedColor shiftProcess readySema
      originalPixels p previewImage previewImageHolder originalPreviewColormap originalPreviewPixels
      anyChange |
@@ -6614,8 +6686,8 @@
     shiftedColor := [:clr :hShift :lFactor :sFactor |
                         Color 
                                 hue:((clr hue) ? 0 + hShift) 
-                                light:((clr light * (lFactor/100)) min:100)
-                                saturation:((clr saturation * (sFactor/100)) min:100)].
+                                light:(((clr light * (lFactor)) min:100) max:0)
+                                saturation:(((clr saturation * (sFactor)) min:100) max:0)].
 
     shiftAction := 
         [
@@ -6630,9 +6702,9 @@
             ].
             readySema notNil ifTrue:[readySema wait. readySema := nil].
 
-            hShift := hueShift value.
-            lFactor := lightValue value.
-            sFactor := saturationValue value.
+            hShift := hueShiftHolder value.
+            lFactor := lightFactorHolder value.
+            sFactor := saturationFactorHolder value.
 
             avgColorHolder value:(shiftedColor value:originalAvgColor value:hShift value:lFactor value:sFactor).
 
@@ -6664,19 +6736,23 @@
         ].
 
     bindings := IdentityDictionary new.
-    bindings at:#hueShiftAmount put:(hueShift := 0 asValue).
-    hueShift onChangeEvaluate:shiftAction.
-
-    bindings at:#lightAmount put:(lightValue := 100 asValue).
-    lightValue onChangeEvaluate:shiftAction.
-
-    bindings at:#saturationAmount put:(saturationValue := 100 asValue).
-    saturationValue onChangeEvaluate:shiftAction.
+    bindings at:#hueShiftHolder put:(hueShiftHolder := 0 asValue).
+    hueShiftHolder onChangeEvaluate:shiftAction.
+
+    bindings at:#lightFactorHolder put:(lightFactorHolder := 1.0 asValue).
+    lightFactorHolder onChangeEvaluate:shiftAction.
+
+    bindings at:#saturationFactorHolder put:(saturationFactorHolder := 1.0 asValue).
+    saturationFactorHolder onChangeEvaluate:shiftAction.
 
     bindings at:#acceptChannel put:acceptChannel.
     bindings at:#hlsColor put:avgColorHolder.
     bindings at:#previewImageHolder put:previewImageHolder.
 
+    bindings at:#resetHueShift put:[hueShiftHolder value:0].
+    bindings at:#resetLightFactor put:[lightFactorHolder value:1.0].
+    bindings at:#resetSaturationFactor put:[saturationFactorHolder value:1.0].
+    
     (self openDialogInterface:#changeHLSDialogSpec withBindings:bindings) 
     ifFalse:[ 
         anyChange ifTrue:[
@@ -6694,6 +6770,7 @@
     ].
 
     "Modified: / 28-08-2017 / 13:05:35 / cg"
+    "Modified: / 27-05-2018 / 12:26:50 / Claus Gittinger"
 !
 
 changeHLSOfColors:colorsToShift