# HG changeset patch # User Claus Gittinger # Date 998509190 -7200 # Node ID 43c18932d2e80f8bb49abaa362d3a2a921a1506e # Parent 18f7b6cc2514023f3960a0eaf3e0b11ab9e375dc *** empty log message *** diff -r 18f7b6cc2514 -r 43c18932d2e8 ImageEditor.st --- a/ImageEditor.st Wed Aug 22 18:39:03 2001 +0200 +++ b/ImageEditor.st Wed Aug 22 21:39:50 2001 +0200 @@ -15,7 +15,7 @@ ToolApplicationModel subclass:#ImageEditor instanceVariableNames:'imageEditView colorMapMode editMode mouseKeyColorMode selectedColorIndex postOpenAction imageSeqNr' - classVariableNames:'LastDirectory' + classVariableNames:'LastDirectory MaskClipboard' poolDictionaries:'' category:'Interface-UIPainter' ! @@ -503,7 +503,7 @@ #name: #gropDialogSpec #window: #(#WindowSpec - #label: 'Crop Borders' + #label: 'Crop Border(s)' #name: 'Crop Borders' #min: #(#Point 10 10) #max: #(#Point 800 478) @@ -603,6 +603,125 @@ ) ! +ungropDialogSpec + "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:#ungropDialogSpec + ImageEditor new openInterface:#ungropDialogSpec + " + + + + ^ + #(#FullSpec + #name: #ungropDialogSpec + #window: + #(#WindowSpec + #label: 'Add Border(s)' + #name: 'Add Borders' + #min: #(#Point 10 10) + #max: #(#Point 800 478) + #bounds: #(#Rectangle 16 46 261 229) + ) + #component: + #(#SpecCollection + #collection: #( + #(#LabelSpec + #label: 'Left:' + #name: 'Label1' + #layout: #(#LayoutFrame 14 0 21 0 90 0 43 0) + #translateLabel: true + #adjust: #right + ) + #(#InputFieldSpec + #name: 'EntryField1' + #layout: #(#LayoutFrame 95 0 21 0 132 0 43 0) + #model: #left + #type: #number + #acceptOnPointerLeave: false + ) + #(#LabelSpec + #label: 'Right:' + #name: 'Label2' + #layout: #(#LayoutFrame 14 0 51 0 90 0 73 0) + #translateLabel: true + #adjust: #right + ) + #(#InputFieldSpec + #name: 'EntryField2' + #layout: #(#LayoutFrame 95 0 51 0 132 0 73 0) + #model: #right + #type: #number + #acceptOnPointerLeave: false + ) + #(#LabelSpec + #label: 'Top:' + #name: 'Label3' + #layout: #(#LayoutFrame 14 0 81 0 90 0 103 0) + #translateLabel: true + #adjust: #right + ) + #(#InputFieldSpec + #name: 'EntryField3' + #layout: #(#LayoutFrame 95 0 81 0 132 0 103 0) + #model: #top + #type: #number + #acceptOnPointerLeave: false + ) + #(#LabelSpec + #label: 'Bottom:' + #name: 'Label4' + #layout: #(#LayoutFrame 14 0 111 0 90 0 133 0) + #translateLabel: true + #adjust: #right + ) + #(#InputFieldSpec + #name: 'EntryField4' + #layout: #(#LayoutFrame 95 0 111 0 132 0 133 0) + #model: #bottom + #type: #number + #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 + #model: #cancel + #extent: #(#Point 118 22) + ) + #(#ActionButtonSpec + #label: 'OK' + #name: 'Button2' + #translateLabel: true + #model: #accept + #extent: #(#Point 118 22) + ) + ) + + ) + ) + ) + + ) + ) +! + windowSpec "This resource specification was automatically generated by the UIPainter of ST/X." @@ -1137,6 +1256,12 @@ nil ) ) + #(#MenuItem + #label: 'Ungrop (Add Border)...' + #translateLabel: true + #value: #doUnCropManual + #activeHelpKey: #uncropManual + ) ) nil nil @@ -1259,6 +1384,23 @@ #translateLabel: true #value: #makeGrayScale ) + #(#MenuItem + #label: '-' + ) + #(#MenuItem + #label: 'Copy mask' + #translateLabel: true + #value: #copyMask + #activeHelpKey: #copyMask + #enabled: #hasMask + ) + #(#MenuItem + #label: 'Paste mask' + #translateLabel: true + #value: #pasteMask + #activeHelpKey: #pasteMask + #enabled: #hasMask + ) ) nil nil @@ -2516,6 +2658,13 @@ "Modified: / 15.9.1998 / 17:53:32 / cg" ! +copyMask + |mask| + + mask := self image mask. + MaskClipboard := mask subImageIn: (0@0 extent:mask extent). +! + fetchImageData |image| @@ -2614,6 +2763,26 @@ "Modified: / 16.3.1999 / 21:57:26 / cg" ! +pasteMask + |img mask| + + imageEditView makeUndo. + + img := self image. + mask := img mask. + + mask + copyFrom:MaskClipboard + x:0 y:0 + toX:0 y:0 + width:(mask width min:MaskClipboard width) + height:(mask height min:MaskClipboard height). + img mask:mask. + (imageEditView image:img copy) notNil ifTrue:[ + self fetchImageData. + ] +! + reduceNumberOfColors |s n anyChange img| @@ -2975,6 +3144,35 @@ ]. ! +doUnCropManual + "let user specify borders and add them" + + |bindings left top right bottom img| + + bindings := IdentityDictionary new. + bindings at:#left put:(left := 0 asValue). + bindings at:#right put:(right := 0 asValue). + bindings at:#top put:(top := 0 asValue). + bindings at:#bottom put:(bottom := 0 asValue). + (self openDialogInterface:#ungropDialogSpec withBindings:bindings) + ifTrue:[ + left := left value. + right := right value. + top := top value. + bottom := bottom value. + img := imageEditView image. + + imageEditView + makeBorderedImageX:left y:top + width:(img width + left + right) + height:(img height + top + bottom). + self updateInfoLabel + ]. + + "Created: / 7.9.1998 / 18:16:07 / cg" + "Modified: / 7.9.1998 / 18:20:42 / cg" +! + doUndo "reverses last edit action"