# HG changeset patch # User Claus Gittinger # Date 1036441087 -3600 # Node ID 80586cf27eb84b05bcf76df98b24d8c972a4e02a # Parent d88ec57772845b3a735d1505f959c75c4bec5745 added changeHue diff -r d88ec5777284 -r 80586cf27eb8 ImageEditor.st --- a/ImageEditor.st Mon Nov 04 17:07:37 2002 +0100 +++ b/ImageEditor.st Mon Nov 04 21:18:07 2002 +0100 @@ -908,6 +908,101 @@ ) ! +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." @@ -985,7 +1080,7 @@ ) #(#ArrowButtonSpec #name: 'ArrowButton1' - #layout: #(#LayoutFrame 105 0 67 0 127 0 89 0) + #layout: #(#LayoutFrame 105 0 63 0 127 0 85 0) #model: #shiftUpNow #isTriggerOnDown: true #actionValue: '' @@ -993,7 +1088,7 @@ ) #(#ArrowButtonSpec #name: 'ArrowButton2' - #layout: #(#LayoutFrame 88 0 86 0 110 0 108 0) + #layout: #(#LayoutFrame 84 0 86 0 106 0 108 0) #model: #shiftLeftNow #isTriggerOnDown: true #actionValue: '' @@ -1001,7 +1096,7 @@ ) #(#ArrowButtonSpec #name: 'ArrowButton3' - #layout: #(#LayoutFrame 122 0 86 0 144 0 108 0) + #layout: #(#LayoutFrame 126 0 86 0 148 0 108 0) #model: #shiftRightNow #isTriggerOnDown: true #actionValue: '' @@ -1009,7 +1104,7 @@ ) #(#ArrowButtonSpec #name: 'ArrowButton4' - #layout: #(#LayoutFrame 105 0 103 0 127 0 125 0) + #layout: #(#LayoutFrame 105 0 107 0 127 0 129 0) #model: #shiftDownNow #isTriggerOnDown: true #actionValue: '' @@ -1740,145 +1835,188 @@ #(#Menu #( #(#MenuItem - #activeHelpKey: #colorMap8 - #label: '8-Plane' - #itemValue: #colorMapMode: - #translateLabel: true - #argument: '8-plane' - #choice: #colorMapMode - #choiceValue: '8-plane' - ) - #(#MenuItem - #activeHelpKey: #colorMap4 - #label: '4-Plane' - #itemValue: #colorMapMode: - #translateLabel: true - #argument: '4-plane' - #choice: #colorMapMode - #choiceValue: '4-plane' - ) - #(#MenuItem - #activeHelpKey: #colorMap2 - #label: '2-Plane' - #itemValue: #colorMapMode: - #translateLabel: true - #argument: '2-plane' - #choice: #colorMapMode - #choiceValue: '2-plane' - ) - #(#MenuItem - #activeHelpKey: #colorMap1 - #label: '1-Plane' - #itemValue: #colorMapMode: + #label: 'Depth' #translateLabel: true - #argument: '1-plane' - #choice: #colorMapMode - #choiceValue: '1-plane' - ) - #(#MenuItem - #label: '-' - ) - #(#MenuItem - #activeHelpKey: #colorMap8M - #label: '8-Plane + Mask' - #itemValue: #colorMapMode: - #translateLabel: true - #argument: '8-plane + mask' - #choice: #colorMapMode - #choiceValue: '8-plane + mask' - ) - #(#MenuItem - #activeHelpKey: #colorMap4M - #label: '4-Plane + Mask' - #itemValue: #colorMapMode: - #translateLabel: true - #argument: '4-plane + mask' - #choice: #colorMapMode - #choiceValue: '4-plane + mask' - ) - #(#MenuItem - #activeHelpKey: #colorMap2M - #label: '2-Plane + Mask' - #itemValue: #colorMapMode: - #translateLabel: true - #argument: '2-plane + mask' - #choice: #colorMapMode - #choiceValue: '2-plane + mask' + #submenu: + #(#Menu + #( + #(#MenuItem + #activeHelpKey: #colorMap8 + #label: '8-Plane' + #itemValue: #colorMapMode: + #translateLabel: true + #argument: '8-plane' + #choice: #colorMapMode + #choiceValue: '8-plane' + ) + #(#MenuItem + #activeHelpKey: #colorMap4 + #label: '4-Plane' + #itemValue: #colorMapMode: + #translateLabel: true + #argument: '4-plane' + #choice: #colorMapMode + #choiceValue: '4-plane' + ) + #(#MenuItem + #activeHelpKey: #colorMap2 + #label: '2-Plane' + #itemValue: #colorMapMode: + #translateLabel: true + #argument: '2-plane' + #choice: #colorMapMode + #choiceValue: '2-plane' + ) + #(#MenuItem + #activeHelpKey: #colorMap1 + #label: '1-Plane' + #itemValue: #colorMapMode: + #translateLabel: true + #argument: '1-plane' + #choice: #colorMapMode + #choiceValue: '1-plane' + ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem + #activeHelpKey: #colorMap8M + #label: '8-Plane + Mask' + #itemValue: #colorMapMode: + #translateLabel: true + #argument: '8-plane + mask' + #choice: #colorMapMode + #choiceValue: '8-plane + mask' + ) + #(#MenuItem + #activeHelpKey: #colorMap4M + #label: '4-Plane + Mask' + #itemValue: #colorMapMode: + #translateLabel: true + #argument: '4-plane + mask' + #choice: #colorMapMode + #choiceValue: '4-plane + mask' + ) + #(#MenuItem + #activeHelpKey: #colorMap2M + #label: '2-Plane + Mask' + #itemValue: #colorMapMode: + #translateLabel: true + #argument: '2-plane + mask' + #choice: #colorMapMode + #choiceValue: '2-plane + mask' + ) + #(#MenuItem + #activeHelpKey: #colorMap1M + #label: '1-Plane + Mask' + #itemValue: #colorMapMode: + #translateLabel: true + #argument: '1-plane + mask' + #choice: #colorMapMode + #choiceValue: '1-plane + mask' + ) + ) + nil + nil + ) ) #(#MenuItem - #activeHelpKey: #colorMap1M - #label: '1-Plane + Mask' - #itemValue: #colorMapMode: + #label: 'Colors' #translateLabel: true - #argument: '1-plane + mask' - #choice: #colorMapMode - #choiceValue: '1-plane + mask' - ) - #(#MenuItem - #label: '-' - ) - #(#MenuItem - #activeHelpKey: #compressColormap - #enabled: #hasColormap - #label: 'Compress Colormap' - #itemValue: #compressColorMap - #translateLabel: true - ) - #(#MenuItem - #enabled: #hasColormap - #label: 'Sort Colormap' - #itemValue: #sortColorMap - #translateLabel: true - ) - #(#MenuItem - #label: 'Reduce Number of Colors...' - #itemValue: #reduceNumberOfColors - #translateLabel: true - ) - #(#MenuItem - #label: '-' + #submenu: + #(#Menu + #( + #(#MenuItem + #activeHelpKey: #compressColormap + #enabled: #hasColormap + #label: 'Compress Colormap' + #itemValue: #compressColorMap + #translateLabel: true + ) + #(#MenuItem + #enabled: #hasColormap + #label: 'Sort Colormap' + #itemValue: #sortColorMap + #translateLabel: true + ) + #(#MenuItem + #label: 'Reduce Number of Colors...' + #itemValue: #reduceNumberOfColors + #translateLabel: true + ) + ) + nil + nil + ) ) #(#MenuItem - #label: 'Make GrayScale' - #itemValue: #makeGrayScale - #translateLabel: true - ) - #(#MenuItem - #label: 'Make Brighter' - #itemValue: #makeBrighter + #label: 'Process' #translateLabel: true - ) - #(#MenuItem - #label: 'Make Darker' - #itemValue: #makeDarker - #translateLabel: true - ) - #(#MenuItem - #label: 'Make Inverse' - #itemValue: #makeInverse - #translateLabel: true + #submenu: + #(#Menu + #( + #(#MenuItem + #label: 'Make GrayScale' + #itemValue: #makeGrayScale + #translateLabel: true + ) + #(#MenuItem + #label: 'Make Brighter' + #itemValue: #makeBrighter + #translateLabel: true + ) + #(#MenuItem + #label: 'Make Darker' + #itemValue: #makeDarker + #translateLabel: true + ) + #(#MenuItem + #label: 'Make Inverse' + #itemValue: #makeInverse + #translateLabel: true + ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem + #label: 'Change Hue...' + #itemValue: #changeHue + #translateLabel: true + ) + ) + nil + nil + ) ) #(#MenuItem - #label: '-' - ) - #(#MenuItem - #activeHelpKey: #copyMask - #enabled: #hasMask - #label: 'Copy Mask' - #itemValue: #copyMask + #label: 'Mask' #translateLabel: true - ) - #(#MenuItem - #activeHelpKey: #pasteMask - #enabled: #hasMask - #label: 'Paste Mask' - #itemValue: #pasteMask - #translateLabel: true - ) - #(#MenuItem - #label: 'Clear Masked Pixels' - #itemValue: #clearMaskedPixels - #translateLabel: true + #submenu: + #(#Menu + #( + #(#MenuItem + #activeHelpKey: #copyMask + #enabled: #hasMask + #label: 'Copy Mask' + #itemValue: #copyMask + #translateLabel: true + ) + #(#MenuItem + #activeHelpKey: #pasteMask + #enabled: #hasMask + #label: 'Paste Mask' + #itemValue: #pasteMask + #translateLabel: true + ) + #(#MenuItem + #label: 'Clear Masked Pixels' + #itemValue: #clearMaskedPixels + #translateLabel: true + ) + ) + nil + nil + ) ) ) nil @@ -3073,6 +3211,46 @@ "Modified: / 16.3.1999 / 21:57:26 / cg" ! +changeHue + "let user specify amount and shift" + + |bindings shiftAmount originalColormap img firstChange shiftAction acceptChannel hueColorHolder| + + originalColormap := imageEditView image colorMap copy. + + acceptChannel := TriggerValue new. + + firstChange := true. + + shiftAction := + [ + acceptChannel value:true. + + firstChange ifTrue:[ + imageEditView makeUndo. + firstChange := false. + ]. + hueColorHolder value:(Color hue:shiftAmount value light:50 saturation:100). + imageEditView image colorMap:originalColormap copy. + imageEditView image colorMapProcessing:[:clr | Color hue:((clr hue) ? 0+shiftAmount value) light:clr light saturation:clr saturation]. + self updateImage. + self updateInfoLabel. + ]. + + bindings := IdentityDictionary new. + bindings at:#hueShiftAmount put:(shiftAmount := 0 asValue). + (bindings at:#hueShiftAmount) onChangeEvaluate:shiftAction. + bindings at:#acceptChannel put:acceptChannel. + bindings at:#hueColor put:(hueColorHolder := Color white asValue). + + (self openDialogInterface:#hueShiftDialogSpec withBindings:bindings) + ifFalse:[ + firstChange ~~ true ifTrue:[ + imageEditView undo + ] + ]. +! + clearMaskedPixels "clear all masked pixels (to pixelValue 0)"