ImageEditor.st
changeset 1652 d6d40619e21a
parent 1651 577ddbd9fb26
child 1656 f5c0716efd78
--- a/ImageEditor.st	Mon Nov 04 21:57:39 2002 +0100
+++ b/ImageEditor.st	Tue Nov 05 15:24:24 2002 +0100
@@ -3269,12 +3269,17 @@
     "interactive Hue/Light/Saturation editing"
 
     |bindings hueShift lightValue saturationValue originalColormap firstChange acceptChannel 
-     shiftAction colorHolder avgColor shiftedColor|
-
-    originalColormap := imageEditView image colorMap copy.
-    avgColor := imageEditView image averageColor.
+     shiftAction avgColorHolder avgColor shiftedColor shiftProcess readySema|
+
+    readySema := Semaphore new.
+    [
+        originalColormap := imageEditView image colorMap copy.
+        avgColor := imageEditView image averageColor.
+        readySema signal.
+    ] forkAt:7.
 
     acceptChannel := TriggerValue new.
+    avgColorHolder := avgColor asValue.
 
     firstChange := true.
 
@@ -3283,6 +3288,7 @@
                                 hue:((clr hue) ? 0 + hShift) 
                                 light:((clr light * lFactor / 100) min:100)
                                 saturation:((clr saturation * sFactor / 100) min:100)].
+
     shiftAction := 
         [
             |hShift lFactor sFactor|
@@ -3293,16 +3299,28 @@
                 imageEditView makeUndo.
                 firstChange := false.
             ].
+            readySema notNil ifTrue:[readySema wait. readySema := nil].
 
             hShift := hueShift value.
             lFactor := lightValue value.
             sFactor := saturationValue value.
 
-            colorHolder value:(shiftedColor value:avgColor value:hShift value:lFactor value:sFactor).
-            imageEditView image colorMap:originalColormap copy.
-            imageEditView image colorMapProcessing:[:clr | shiftedColor value:clr value:hShift value:lFactor value:sFactor].
-            self updateImage.
-            self updateInfoLabel.
+            avgColorHolder value:(shiftedColor value:avgColor value:hShift value:lFactor value:sFactor).
+
+            shiftProcess notNil ifTrue:[
+                shiftProcess terminate.
+                shiftProcess waitUntilTerminated.
+                shiftProcess := nil.
+            ].
+            shiftProcess := 
+                [
+                    [
+                        imageEditView image colorMap:originalColormap copy.
+                        imageEditView image colorMapProcessing:[:clr | shiftedColor value:clr value:hShift value:lFactor value:sFactor].
+                        self updateImage.
+                        self updateInfoLabel.
+                    ] ensure:[ shiftProcess := nil ].    
+                ] forkAt:7.
         ].
 
     bindings := IdentityDictionary new.
@@ -3316,7 +3334,7 @@
     (bindings at:#saturationAmount) onChangeEvaluate:shiftAction.
 
     bindings at:#acceptChannel put:acceptChannel.
-    bindings at:#hlsColor put:(colorHolder := avgColor asValue).
+    bindings at:#hlsColor put:avgColorHolder.
 
     (self openDialogInterface:#changeHLSDialogSpec withBindings:bindings) 
     ifFalse:[