#BUGFIX by cg draft
authorClaus Gittinger <cg@exept.de>
Mon, 28 Aug 2017 13:06:26 +0200
changeset 3468 2cf3a445a2f6
parent 3467 2f9054aca4c6
child 3469 52837773925b
#BUGFIX by cg class: ImageEditor comment/format in: #changeHLSOfColors: changed: #changeHLS class: ImageEditor class changed: #changeHLSDialogSpec
ImageEditor.st
--- a/ImageEditor.st	Mon Aug 28 12:57:54 2017 +0200
+++ b/ImageEditor.st	Mon Aug 28 13:06:26 2017 +0200
@@ -1507,157 +1507,158 @@
     <resource: #canvas>
 
     ^ 
-     #(FullSpec
-        name: changeHLSDialogSpec
-        window: 
-       (WindowSpec
-          label: 'HLS Edit Dialog'
-          name: 'HLS Edit Dialog'
-          min: (Point 10 10)
-          bounds: (Rectangle 0 0 312 258)
-        )
-        component: 
-       (SpecCollection
-          collection: (
-           (LabelSpec
-              label: 'Hue-Shift:'
-              name: 'HueLabel'
-              layout: (LayoutFrame 20 0 21 0 120 0 43 0)
-              translateLabel: true
-              adjust: right
-            )
-           (InputFieldSpec
-              name: 'HueShiftEntryField'
-              layout: (LayoutFrame 123 0 21 0 166 0 43 0)
-              tabable: true
-              model: hueShiftAmount
-              type: numberInRange
-              minValue: 0
-              maxValue: 360
-              acceptChannel: acceptChannel
-              acceptOnPointerLeave: false
-            )
-           (ThumbWheelSpec
-              name: 'HueWheel'
-              layout: (LayoutFrame 180 0 22 0 297 0 42 0)
-              model: hueShiftAmount
-              orientation: horizontal
-              step: 1
-              endlessRotation: true
-            )
-           (LabelSpec
-              label: 'Light Factor:'
-              name: 'LightLabel'
-              layout: (LayoutFrame 18 0 50 0 120 0 72 0)
-              translateLabel: true
-              adjust: right
-            )
-           (InputFieldSpec
-              name: 'LightEntryField'
-              layout: (LayoutFrame 123 0 50 0 166 0 72 0)
-              tabable: true
-              model: lightAmount
-              type: numberInRange
-              minValue: 0
-              maxValue: 1000
-              acceptChannel: acceptChannel
-              acceptOnPointerLeave: false
-            )
-           (ThumbWheelSpec
-              name: 'LightWheel'
-              layout: (LayoutFrame 180 0 51 0 297 0 71 0)
-              model: lightAmount
-              orientation: horizontal
-              stop: 1000
-              step: 1
-            )
-           (LabelSpec
-              label: 'Saturation Factor:'
-              name: 'SaturationLabel'
-              layout: (LayoutFrame 9 0 79 0 120 0 101 0)
-              translateLabel: true
-              adjust: right
-            )
-           (InputFieldSpec
-              name: 'SaturationEntryField'
-              layout: (LayoutFrame 123 0 79 0 166 0 101 0)
-              tabable: true
-              model: saturationAmount
-              type: numberInRange
-              minValue: 0
-              maxValue: 1000
-              acceptChannel: acceptChannel
-              acceptOnPointerLeave: false
-            )
-           (ThumbWheelSpec
-              name: 'SaturationWheel'
-              layout: (LayoutFrame 180 0 80 0 297 0 100 0)
-              model: saturationAmount
-              orientation: horizontal
-              stop: 1000
-              step: 1
-            )
-           (LabelSpec
-              label: 'Color Shift'
-              name: 'Label2'
-              layout: (LayoutFrame 5 0 110 0 -15 0.5 132 0)
-              translateLabel: true
-            )
-           (LabelSpec
-              name: 'HueColorLabel'
-              layout: (LayoutFrame 18 0.0 133 0 -41 0.5 217 0)
-              level: -1
-              backgroundChannel: hlsColor
-              translateLabel: true
-            )
-           (LabelSpec
-              label: 'Preview'
-              name: 'Label3'
-              layout: (LayoutFrame 5 0.5 110 0 -5 1 132 0)
-              translateLabel: true
-            )
-           (LabelSpec
-              name: 'PreviewLabel'
-              layout: (LayoutFrame 36 0.5 133 0 -23 1.0 217 0)
-              level: -1
-              translateLabel: true
-              labelChannel: previewImageHolder
-            )
-           (HorizontalPanelViewSpec
-              name: 'HorizontalPanel1'
-              layout: (LayoutFrame 0 0.0 -30 1 0 1.0 0 1)
-              horizontalLayout: fitSpace
-              verticalLayout: center
-              horizontalSpace: 3
-              verticalSpace: 3
-              reverseOrderIfOKAtLeft: true
-              component: 
-             (SpecCollection
-                collection: (
-                 (ActionButtonSpec
-                    label: 'Cancel'
-                    name: 'Button1'
-                    translateLabel: true
-                    tabable: true
-                    model: cancel
-                    extent: (Point 151 22)
-                  )
-                 (ActionButtonSpec
-                    label: 'OK'
-                    name: 'Button2'
-                    translateLabel: true
-                    tabable: true
-                    model: accept
-                    extent: (Point 152 22)
-                  )
+    #(FullSpec
+       name: changeHLSDialogSpec
+       window: 
+      (WindowSpec
+         label: 'HLS Edit Dialog'
+         name: 'HLS Edit Dialog'
+         min: (Point 10 10)
+         bounds: (Rectangle 0 0 378 312)
+       )
+       component: 
+      (SpecCollection
+         collection: (
+          (LabelSpec
+             label: 'Hue-Shift:'
+             name: 'HueLabel'
+             layout: (LayoutFrame 20 0 21 0 187 0 43 0)
+             translateLabel: true
+             adjust: right
+           )
+          (InputFieldSpec
+             name: 'HueShiftEntryField'
+             layout: (LayoutFrame 194 0 21 0 237 0 43 0)
+             tabable: true
+             model: hueShiftAmount
+             type: numberInRange
+             minValue: 0
+             maxValue: 360
+             acceptChannel: acceptChannel
+             acceptOnPointerLeave: false
+           )
+          (ThumbWheelSpec
+             name: 'HueWheel'
+             layout: (LayoutFrame 246 0 22 0 363 0 42 0)
+             model: hueShiftAmount
+             orientation: horizontal
+             step: 1
+             endlessRotation: true
+           )
+          (LabelSpec
+             label: 'Light Factor:'
+             name: 'LightLabel'
+             layout: (LayoutFrame 20 0 50 0 187 0 72 0)
+             translateLabel: true
+             adjust: right
+           )
+          (InputFieldSpec
+             name: 'LightEntryField'
+             layout: (LayoutFrame 194 0 50 0 237 0 72 0)
+             tabable: true
+             model: lightAmount
+             type: numberInRange
+             minValue: 0
+             maxValue: 1000
+             acceptChannel: acceptChannel
+             acceptOnPointerLeave: false
+           )
+          (ThumbWheelSpec
+             name: 'LightWheel'
+             layout: (LayoutFrame 246 0 51 0 363 0 71 0)
+             model: lightAmount
+             orientation: horizontal
+             stop: 1000
+             step: 1
+           )
+          (LabelSpec
+             label: 'Saturation Factor:'
+             name: 'SaturationLabel'
+             layout: (LayoutFrame 20 0 79 0 187 0 101 0)
+             translateLabel: true
+             adjust: right
+           )
+          (InputFieldSpec
+             name: 'SaturationEntryField'
+             layout: (LayoutFrame 194 0 79 0 237 0 101 0)
+             tabable: true
+             model: saturationAmount
+             type: numberInRange
+             minValue: 0
+             maxValue: 1000
+             acceptChannel: acceptChannel
+             acceptOnPointerLeave: false
+           )
+          (ThumbWheelSpec
+             name: 'SaturationWheel'
+             layout: (LayoutFrame 246 0 80 0 363 0 100 0)
+             model: saturationAmount
+             orientation: horizontal
+             stop: 1000
+             step: 1
+           )
+          (LabelSpec
+             label: 'Color Shift'
+             name: 'Label2'
+             layout: (LayoutFrame 5 0 127 0 -15 0.5 149 0)
+             translateLabel: true
+           )
+          (LabelSpec
+             name: 'HueColorLabel'
+             layout: (LayoutFrame 18 0.0 150 0 -41 0.5 234 0)
+             level: -1
+             backgroundChannel: hlsColor
+             translateLabel: true
+           )
+          (LabelSpec
+             label: 'Preview'
+             name: 'Label3'
+             layout: (LayoutFrame 5 0.5 127 0 -5 1 149 0)
+             translateLabel: true
+           )
+          (LabelSpec
+             name: 'PreviewLabel'
+             layout: (LayoutFrame 36 0.5 150 0 -23 1.0 234 0)
+             level: -1
+             translateLabel: true
+             labelChannel: previewImageHolder
+           )
+          (HorizontalPanelViewSpec
+             name: 'HorizontalPanel1'
+             layout: (LayoutFrame 0 0.0 -30 1 0 1.0 0 1)
+             horizontalLayout: fitSpace
+             verticalLayout: center
+             horizontalSpace: 3
+             verticalSpace: 3
+             reverseOrderIfOKAtLeft: true
+             component: 
+            (SpecCollection
+               collection: (
+                (ActionButtonSpec
+                   label: 'Cancel'
+                   name: 'Button1'
+                   translateLabel: true
+                   tabable: true
+                   model: cancel
+                   extent: (Point 183 28)
                  )
-               
-              )
-            )
+                (ActionButtonSpec
+                   label: 'OK'
+                   name: 'Button2'
+                   translateLabel: true
+                   tabable: true
+                   model: accept
+                   extent: (Point 183 28)
+                 )
+                )
+              
+             )
+             keepSpaceForOSXResizeHandleH: true
            )
-         
-        )
-      )
+          )
+        
+       )
+     )
 !
 
 cropSpec
@@ -6140,17 +6141,19 @@
 !
 
 changeHLS
-    "interactive Hue/Light/Saturation editing"
+    "interactive Hue/Light/Saturation editing with thumbWheels"
 
     |bindings hueShift lightValue saturationValue originalColormap firstChange acceptChannel 
-     shiftAction avgColorHolder avgColor shiftedColor shiftProcess readySema
+     shiftAction originalAvgColor avgColorHolder avgColor shiftedColor shiftProcess readySema
      originalPixels p previewImage previewImageHolder originalPreviewColormap originalPreviewPixels
      anyChange |
 
-    "/ compute the averageColor in the background (while asking user)
     avgColorHolder := nil asValue.
     previewImageHolder := nil asValue.
 
+    "/
+    "/ compute the averageColor in the background (while building dialog and asking user)
+    "/
     readySema := Semaphore new.
     [
         |image|
@@ -6158,10 +6161,12 @@
         image := imageEditView image.
         originalColormap := image colorMap copy.
         originalPixels := image bits.
-        avgColor := image averageColor.
-        avgColorHolder value:avgColor.
 
         previewImage := self image magnifiedPreservingRatioTo:100@100.
+
+        avgColor := originalAvgColor := previewImage "image" averageColor.
+        avgColorHolder value:avgColor.
+
         previewImageHolder value: previewImage.
         originalPreviewColormap := previewImage colorMap copy.
         originalPreviewPixels := previewImage bits.
@@ -6177,8 +6182,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/100)) min:100)
+                                saturation:((clr saturation * (sFactor/100)) min:100)].
 
     shiftAction := 
         [
@@ -6197,7 +6202,7 @@
             lFactor := lightValue value.
             sFactor := saturationValue value.
 
-            avgColorHolder value:(shiftedColor value:avgColor value:hShift value:lFactor value:sFactor).
+            avgColorHolder value:(shiftedColor value:originalAvgColor value:hShift value:lFactor value:sFactor).
 
             previewImage
                 colorMap:originalPreviewColormap copy;
@@ -6255,6 +6260,8 @@
         self updateImage.
         self updateImagePreView.
     ].
+
+    "Modified: / 28-08-2017 / 13:05:35 / cg"
 !
 
 changeHLSOfColors:colorsToShift
@@ -6265,10 +6272,12 @@
      originalPixels p previewImage previewImageHolder originalPreviewColormap originalPreviewPixels
      anyChange |
 
-    "/ compute the averageColor in the background (while asking user)
     avgColorHolder := nil asValue.
     previewImageHolder := nil asValue.
 
+    "/
+    "/ compute the averageColor in the background (while building dialog and asking user)
+    "/
     readySema := Semaphore new.
     [
         |image red green blue|
@@ -6298,8 +6307,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)
+                                saturation:((clr saturation * sFactor) min:100)].
 
     shiftAction := 
         [
@@ -6389,6 +6398,8 @@
         self updateImage.
         self updateImagePreView.
     ].
+
+    "Modified (comment): / 28-08-2017 / 13:04:44 / cg"
 !
 
 clearColormapEntry0AndMaskedPixels