diff -r 80586cf27eb8 -r cb63d6bf76c1 ImageEditor.st --- a/ImageEditor.st Mon Nov 04 21:18:07 2002 +0100 +++ b/ImageEditor.st Mon Nov 04 21:34:41 2002 +0100 @@ -647,6 +647,155 @@ !ImageEditor class methodsFor:'interface specs'! +changeHLSDialogSpec + "This resource specification was automatically generated + by the UIPainter of ST/X." + + "Do not manually edit this!! If it is corrupted, + the UIPainter may not be able to read the specification." + + " + UIPainter new openOnClass:ImageEditor andSelector:#changeHLSDialogSpec + ImageEditor new openInterface:#changeHLSDialogSpec + " + + + + ^ + #(#FullSpec + #name: #changeHLSDialogSpec + #window: + #(#WindowSpec + #label: 'Shift Hue' + #name: 'Shift Hue' + #min: #(#Point 10 10) + #max: #(#Point 800 478) + #bounds: #(#Rectangle 16 46 328 229) + ) + #component: + #(#SpecCollection + #collection: #( + #(#LabelSpec + #label: 'Hue-Shift:' + #name: 'HueLabel' + #layout: #(#LayoutFrame 14 0 21 0 90 0 43 0) + #translateLabel: true + #adjust: #right + ) + #(#InputFieldSpec + #name: 'HueShiftEntryField' + #layout: #(#LayoutFrame 95 0 21 0 138 0 43 0) + #tabable: true + #model: #hueShiftAmount + #type: #numberInRange + #minValue: 0 + #maxValue: 360 + #acceptChannel: #acceptChannel + #acceptOnPointerLeave: false + ) + #(#ThumbWheelSpec + #name: 'HueWheel' + #layout: #(#LayoutFrame 152 0 22 0 269 0 42 0) + #model: #hueShiftAmount + #orientation: #horizontal + #step: 1 + #endlessRotation: true + ) + #(#LabelSpec + #label: 'Light:' + #name: 'LightLabel' + #layout: #(#LayoutFrame 14 0 50 0 90 0 72 0) + #translateLabel: true + #adjust: #right + ) + #(#InputFieldSpec + #name: 'LightEntryField' + #layout: #(#LayoutFrame 95 0 50 0 138 0 72 0) + #tabable: true + #model: #lightAmount + #type: #numberInRange + #minValue: 0 + #maxValue: 1000 + #acceptChannel: #acceptChannel + #acceptOnPointerLeave: false + ) + #(#ThumbWheelSpec + #name: 'LightWheel' + #layout: #(#LayoutFrame 152 0 51 0 269 0 71 0) + #model: #lightAmount + #orientation: #horizontal + #stop: 1000 + #step: 1 + ) + #(#LabelSpec + #label: 'Saturation:' + #name: 'SaturationLabel' + #layout: #(#LayoutFrame 14 0 79 0 90 0 101 0) + #translateLabel: true + #adjust: #right + ) + #(#InputFieldSpec + #name: 'SaturationEntryField' + #layout: #(#LayoutFrame 95 0 79 0 138 0 101 0) + #tabable: true + #model: #saturationAmount + #type: #numberInRange + #minValue: 0 + #maxValue: 1000 + #acceptChannel: #acceptChannel + #acceptOnPointerLeave: false + ) + #(#ThumbWheelSpec + #name: 'SaturationWheel' + #layout: #(#LayoutFrame 152 0 80 0 269 0 100 0) + #model: #saturationAmount + #orientation: #horizontal + #stop: 1000 + #step: 1 + ) + #(#LabelSpec + #name: 'HueColorLabel' + #layout: #(#LayoutFrame 10 0.0 109 0 -10 1.0 148 0) + #translateLabel: true + #backgroundChannel: #hueColor + ) + #(#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) + ) + ) + + ) + ) + ) + + ) + ) +! + dialogSpecForNewImage "This resource specification was automatically generated by the UIPainter of ST/X." @@ -908,101 +1057,6 @@ ) ! -hueShiftDialogSpec - "This resource specification was automatically generated - by the UIPainter of ST/X." - - "Do not manually edit this!! If it is corrupted, - the UIPainter may not be able to read the specification." - - " - UIPainter new openOnClass:ImageEditor andSelector:#hueShiftDialogSpec - ImageEditor new openInterface:#hueShiftDialogSpec - " - - - - ^ - #(#FullSpec - #name: #hueShiftDialogSpec - #window: - #(#WindowSpec - #label: 'Shift Hue' - #name: 'Shift Hue' - #min: #(#Point 10 10) - #max: #(#Point 800 478) - #bounds: #(#Rectangle 16 46 261 229) - ) - #component: - #(#SpecCollection - #collection: #( - #(#LabelSpec - #label: 'Hue-Shift:' - #name: 'HueLabel' - #layout: #(#LayoutFrame 14 0 21 0 90 0 43 0) - #translateLabel: true - #adjust: #right - ) - #(#InputFieldSpec - #name: 'HueShiftEntryField' - #layout: #(#LayoutFrame 95 0 21 0 138 0 43 0) - #tabable: true - #model: #hueShiftAmount - #type: #number - #acceptChannel: #acceptChannel - #acceptOnPointerLeave: false - ) - #(#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 118 22) - ) - #(#ActionButtonSpec - #label: 'OK' - #name: 'Button2' - #translateLabel: true - #tabable: true - #model: #accept - #extent: #(#Point 118 22) - ) - ) - - ) - ) - #(#ThumbWheelSpec - #name: 'ThumbWheel1' - #layout: #(#LayoutFrame 60 0 83 0 177 0 103 0) - #model: #hueShiftAmount - #orientation: #horizontal - #step: 1 - #endlessRotation: true - ) - #(#LabelSpec - #name: 'HueColorLabel' - #layout: #(#LayoutFrame 5 0 109 0 241 0 148 0) - #translateLabel: true - #backgroundChannel: #hueColor - ) - ) - - ) - ) -! - shiftDialogSpec "This resource specification was automatically generated by the UIPainter of ST/X." @@ -1979,8 +2033,8 @@ #label: '-' ) #(#MenuItem - #label: 'Change Hue...' - #itemValue: #changeHue + #label: 'Change HLS...' + #itemValue: #changeHLS #translateLabel: true ) ) @@ -3211,10 +3265,11 @@ "Modified: / 16.3.1999 / 21:57:26 / cg" ! -changeHue - "let user specify amount and shift" - - |bindings shiftAmount originalColormap img firstChange shiftAction acceptChannel hueColorHolder| +changeHLS + "interactive Hue/Light/Saturation editing" + + |bindings hueShift lightValue saturationValue originalColormap firstChange acceptChannel + shiftAction colorHolder| originalColormap := imageEditView image colorMap copy. @@ -3224,26 +3279,43 @@ shiftAction := [ + |hShift lFactor sFactor| + acceptChannel value:true. firstChange ifTrue:[ imageEditView makeUndo. firstChange := false. ]. - hueColorHolder value:(Color hue:shiftAmount value light:50 saturation:100). + + hShift := hueShift value. + lFactor := lightValue value. + sFactor := saturationValue value. + + colorHolder value:(Color hue:hShift light:(lFactor min:100) saturation:(sFactor min:100)). imageEditView image colorMap:originalColormap copy. - imageEditView image colorMapProcessing:[:clr | Color hue:((clr hue) ? 0+shiftAmount value) light:clr light saturation:clr saturation]. + imageEditView image colorMapProcessing:[:clr | Color + hue:((clr hue) ? 0 + hShift) + light:((clr light * lFactor / 100) min:100) + saturation:((clr saturation * sFactor / 100) min:100)]. self updateImage. self updateInfoLabel. ]. bindings := IdentityDictionary new. - bindings at:#hueShiftAmount put:(shiftAmount := 0 asValue). + bindings at:#hueShiftAmount put:(hueShift := 0 asValue). (bindings at:#hueShiftAmount) onChangeEvaluate:shiftAction. + + bindings at:#lightAmount put:(lightValue := 100 asValue). + (bindings at:#lightAmount) onChangeEvaluate:shiftAction. + + bindings at:#saturationAmount put:(saturationValue := 100 asValue). + (bindings at:#saturationAmount) onChangeEvaluate:shiftAction. + bindings at:#acceptChannel put:acceptChannel. - bindings at:#hueColor put:(hueColorHolder := Color white asValue). - - (self openDialogInterface:#hueShiftDialogSpec withBindings:bindings) + bindings at:#hueColor put:(colorHolder := Color white asValue). + + (self openDialogInterface:#changeHLSDialogSpec withBindings:bindings) ifFalse:[ firstChange ~~ true ifTrue:[ imageEditView undo