# HG changeset patch # User Claus Gittinger # Date 1527413624 -7200 # Node ID b309d1d1b45c7fb0400cb0c7a36a95629e011d49 # Parent 8e0d01180c6ea98f17aef00dc1ab2e3b9e8ee197 #FEATURE by cg class: ImageEditor window title; new paste mode added: #constructWindowTitle comment/format in: #menu_pasteMask #updateForNoImage changed: #postOpenWith: #processSelectedColorsWith: #updateAfterImageChange class: ImageEditor class added: #pasteMaskedIcon changed: #helpPairs #modeMenu #pasteIcon #pasteUnderIcon #pasteWithMaskIcon #toolsMenuToolbar diff -r 8e0d01180c6e -r b309d1d1b45c ImageEditor.st --- a/ImageEditor.st Thu May 24 16:34:42 2018 +0200 +++ b/ImageEditor.st Sun May 27 11:33:44 2018 +0200 @@ -442,6 +442,9 @@ 'Paste-Over Mode (only paste pixels; keep mask as is)' #drawModePasteUnder +'Paste-Under Mode (only paste previously masked pixels where the new pixel is also masked)' + +#drawModePasteMasked 'Paste-Under Mode (only paste previously masked pixels)' #drawModePasteWithMask @@ -606,6 +609,7 @@ ) "Modified: / 07-12-2017 / 15:32:58 / cg" + "Modified: / 27-05-2018 / 10:44:41 / Claus Gittinger" ! helpSpec @@ -1152,102 +1156,103 @@ ! pasteIcon - "This resource specification was automatically generated by the ImageEditor of ST/X." + "Do not manually edit this!! If it is corrupted, the ImageEditor may not be able to read the specification." + " self pasteIcon inspect ImageEditor openOnClass:self andSelector:#pasteIcon - Icon flushCachedIcons" - - ^ Icon constantNamed:'ImageEditor class pasteIcon' - ifAbsentPut:[ - (Depth4Image new) - width:14; - height:14; - photometric:(#palette); - bitsPerSample:(#( 4 )); - samplesPerPixel:(1); - bits:(ByteArray - fromPackedString:'@@@@@@@@@@@@AU@@@@@CHE@E@2@@@ QDQD@0@@L@@@@@H@@BL#H2L#@@@QDQDQL @@D3L@@@@@@AL3A&Y&X@@SL0Y A&@@D3LF@@A @AL3A&@FX@@QDPY&Y& -@@@@@@@@@@@b'); - colorMapFromArray:#[ 0 0 0 0 0 128 128 128 0 128 128 128 212 208 200 255 255 0 255 255 255 ]; - mask:((ImageMask new) - width:14; - height:14; - bits:(ByteArray - fromPackedString:'C0A?8O?0??C?O?8??#?>O?8_? G>@@a'); - yourself); - yourself - ] + Icon flushCachedIcons + " + + + + ^Icon + constantNamed:'ImageEditor class pasteIcon' + ifAbsentPut:[(Depth8Image width:14 height:14) bits:(ByteArray fromPackedString:' +:N#(:N#(:N#(:N#(:N#(:N#(:O#8:N#(:N#(:N#5>^#8:N#8:OW9:N#(:O''(=/[6=/[6:OW(:N#(=^#(:N#(:N#(>^#(:N#9=_''5>_W9=_''5:N#(:@DA@PDA +@PDA=_''(@@C(@_[6= @@@@@@@@@@@N A=/[6@@XFA XFA @@:@G6=/X@A X@@@XF@@C(@_[6= @F@@@@@@X@@N A=/[6@@XF@@@FA @@@@DA@PD@A XFA XF +@@@@@@@@@@@@@@@@@@@@@@@a') + colorMapFromArray:#[0 0 0 0 0 128 128 128 0 128 128 128 212 208 200 255 255 0 255 255 255 0 0 51 0 0 102 0 0 153 0 0 204 0 0 255 0 51 0 0 51 51 0 51 102 0 51 153 0 51 204 0 51 255 0 102 0 0 102 51 0 102 102 0 102 153 0 102 204 0 102 255 0 153 0 0 153 51 0 153 102 0 153 153 0 153 204 0 153 255 0 204 0 0 204 51 0 204 102 0 204 153 0 204 204 0 204 255 0 255 0 0 255 51 0 255 102 0 255 153 0 255 204 0 255 255 51 0 0 51 0 51 51 0 102 51 0 153 51 0 204 51 0 255 51 51 0 51 51 51 51 51 102 51 51 153 51 51 204 51 51 255 51 102 0 51 102 51 51 102 102 51 102 153 51 102 204 51 102 255 51 153 0 51 153 51 51 153 102 51 153 153 51 153 204 51 153 255 51 204 0 51 204 51 51 204 102 51 204 153 51 204 204 51 204 255 51 255 0 51 255 51 51 255 102 51 255 153 51 255 204 51 255 255 102 0 0 102 0 51 102 0 102 102 0 153 102 0 204 102 0 255 102 51 0 102 51 51 102 51 102 102 51 153 102 51 204 102 51 255 102 102 0 102 102 51 102 102 102 102 102 153 102 102 204 102 102 255 102 153 0 102 153 51 102 153 102 102 153 153 102 153 204 102 153 255 102 204 0 102 204 51 102 204 102 102 204 153 102 204 204 102 204 255 102 255 0 102 255 51 102 255 102 102 255 153 102 255 204 102 255 255 153 0 0 153 0 51 153 0 102 153 0 153 153 0 204 153 0 255 153 51 0 153 51 51 153 51 102 153 51 153 153 51 204 153 51 255 153 102 0 153 102 51 153 102 102 153 102 153 153 102 204 153 102 255 153 153 0 153 153 51 153 153 102 153 153 153 153 153 204 153 153 255 153 204 0 153 204 51 153 204 102 153 204 153 153 204 204 153 204 255 153 255 0 153 255 51 153 255 102 153 255 153 153 255 204 153 255 255 204 0 0 204 0 51 204 0 102 204 0 153 204 0 204 204 0 255 204 51 0 204 51 51 204 51 102 204 51 153 204 51 204 204 51 255 204 102 0 204 102 51 204 102 102 204 102 153 204 102 204 204 102 255 204 153 0 204 153 51 204 153 102 204 153 153 204 153 204 204 153 255 204 204 0 204 204 51 204 204 102 204 204 153 204 204 204 204 204 255 204 255 0 204 255 51 204 255 102 204 255 153 204 255 204 204 255 255 255 0 0 255 0 51 255 0 102 255 0 153 255 0 204 255 0 255 255 51 0 255 51 51 255 51 102 255 51 153 255 51 204 255 51 255 255 102 0 255 102 51 255 102 102 255 102 153 255 102 204 255 102 255 255 153 0 255 153 51 255 153 102 255 153 153 255 153 204 255 153 255 255 204 0 255 204 51 255 204 102 255 204 153 255 204 204 255 204 255 255 255 51 255 255 102 255 255 153 255 255 204 9 9 9 19 19 19 29 29 29 39 39 39 49 49 49 58 58 58 68 68 68 78 78 78 88 88 88 98 98 98 107 107 107 117 117 117 127 127 127 137 137 137 147 147 147 156 156 156 166 166 166 176 176 176 186 186 186 196 196 196 205 205 205 215 215 215 225 225 225 235 235 235 245 245 245 191 191 191 233 231 227 127 127 127 255 255 127 191 191 127] + mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'C0A?8O?0??C?O?8??#?>O?8_? G>@@a'); yourself); yourself] +! + +pasteMaskedIcon + "This resource specification was automatically generated + by the ImageEditor of ST/X." + + "Do not manually edit this!! If it is corrupted, + the ImageEditor may not be able to read the specification." + + " + self pasteMaskedIcon inspect + ImageEditor openOnClass:self andSelector:#pasteMaskedIcon + Icon flushCachedIcons + " + + + + ^Icon + constantNamed:'ImageEditor class pasteMaskedIcon' + ifAbsentPut:[(Depth8Image width:14 height:14) bits:(ByteArray fromPackedString:' +:N#(:N#(:N#(:N#(:N#(:N#(:O#8:N#(:N#(:N#5>^#8:N#8:OW9:N#(:O''(=/[6=/[6:OW(:N#(=^#(:N#(:N#(>^#(:N#9=_''5>_W9=_''5:N#(:@DA@PDA +@PDA=_''(@@C(@_[6=/[6= D@@@@@@N A=/[6= XFA XFA @@:@G6=/[6A X@@@XF@@C(@_[6=/XF= @@@@X@@N A=/[6= XF@@@FA @@@@DA@PDA@PDAA XF +@@@@@@@@@@@@@@@@@@@@@@@a') + colorMapFromArray:#[0 0 0 0 0 128 128 128 0 128 128 128 212 208 200 255 255 0 255 255 255 0 0 51 0 0 102 0 0 153 0 0 204 0 0 255 0 51 0 0 51 51 0 51 102 0 51 153 0 51 204 0 51 255 0 102 0 0 102 51 0 102 102 0 102 153 0 102 204 0 102 255 0 153 0 0 153 51 0 153 102 0 153 153 0 153 204 0 153 255 0 204 0 0 204 51 0 204 102 0 204 153 0 204 204 0 204 255 0 255 0 0 255 51 0 255 102 0 255 153 0 255 204 0 255 255 51 0 0 51 0 51 51 0 102 51 0 153 51 0 204 51 0 255 51 51 0 51 51 51 51 51 102 51 51 153 51 51 204 51 51 255 51 102 0 51 102 51 51 102 102 51 102 153 51 102 204 51 102 255 51 153 0 51 153 51 51 153 102 51 153 153 51 153 204 51 153 255 51 204 0 51 204 51 51 204 102 51 204 153 51 204 204 51 204 255 51 255 0 51 255 51 51 255 102 51 255 153 51 255 204 51 255 255 102 0 0 102 0 51 102 0 102 102 0 153 102 0 204 102 0 255 102 51 0 102 51 51 102 51 102 102 51 153 102 51 204 102 51 255 102 102 0 102 102 51 102 102 102 102 102 153 102 102 204 102 102 255 102 153 0 102 153 51 102 153 102 102 153 153 102 153 204 102 153 255 102 204 0 102 204 51 102 204 102 102 204 153 102 204 204 102 204 255 102 255 0 102 255 51 102 255 102 102 255 153 102 255 204 102 255 255 153 0 0 153 0 51 153 0 102 153 0 153 153 0 204 153 0 255 153 51 0 153 51 51 153 51 102 153 51 153 153 51 204 153 51 255 153 102 0 153 102 51 153 102 102 153 102 153 153 102 204 153 102 255 153 153 0 153 153 51 153 153 102 153 153 153 153 153 204 153 153 255 153 204 0 153 204 51 153 204 102 153 204 153 153 204 204 153 204 255 153 255 0 153 255 51 153 255 102 153 255 153 153 255 204 153 255 255 204 0 0 204 0 51 204 0 102 204 0 153 204 0 204 204 0 255 204 51 0 204 51 51 204 51 102 204 51 153 204 51 204 204 51 255 204 102 0 204 102 51 204 102 102 204 102 153 204 102 204 204 102 255 204 153 0 204 153 51 204 153 102 204 153 153 204 153 204 204 153 255 204 204 0 204 204 51 204 204 102 204 204 153 204 204 204 204 204 255 204 255 0 204 255 51 204 255 102 204 255 153 204 255 204 204 255 255 255 0 0 255 0 51 255 0 102 255 0 153 255 0 204 255 0 255 255 51 0 255 51 51 255 51 102 255 51 153 255 51 204 255 51 255 255 102 0 255 102 51 255 102 102 255 102 153 255 102 204 255 102 255 255 153 0 255 153 51 255 153 102 255 153 153 255 153 204 255 153 255 255 204 0 255 204 51 255 204 102 255 204 153 255 204 204 255 204 255 255 255 51 255 255 102 255 255 153 255 255 204 9 9 9 19 19 19 29 29 29 39 39 39 49 49 49 58 58 58 68 68 68 78 78 78 88 88 88 98 98 98 107 107 107 117 117 117 127 127 127 137 137 137 147 147 147 156 156 156 166 166 166 176 176 176 186 186 186 196 196 196 205 205 205 215 215 215 225 225 225 235 235 235 245 245 245 191 191 191 233 231 227 127 127 127 255 255 127 191 191 127] + mask:((ImageMask width:14 height:14) bits:(ByteArray fromPackedString:'C0A?8O?0??C?O?8??#?>O?8_? G>@@a'); yourself); yourself] ! pasteUnderIcon - "This resource specification was automatically generated by the ImageEditor of ST/X." + "Do not manually edit this!! If it is corrupted, the ImageEditor may not be able to read the specification." + " self pasteUnderIcon inspect ImageEditor openOnClass:self andSelector:#pasteUnderIcon - Icon flushCachedIcons" - - ^ Icon constantNamed:'ImageEditor class pasteUnderIcon' - ifAbsentPut:[ - (Depth4Image new) - width:14; - height:14; - photometric:(#palette); - bitsPerSample:(#( 4 )); - samplesPerPixel:(1); - bits:(ByteArray - fromPackedString:'@@@@@@@@@@@@AU@@@@@CHE@E@2@@@ QDQD@0@@L@@@@@H@@BL#H2L#@@@QDQDQL @@D3L3LP@@@AL3L3E&X@@SL3L0A&@@D3L3@@A @AL3L3@FX@@QDQDQY& -@@@@@@@@@@@b'); - colorMapFromArray:#[ 0 0 0 0 0 128 128 128 0 128 128 128 212 208 200 255 255 0 255 255 255 ]; - mask:((ImageMask new) - width:14; - height:14; - bits:(ByteArray - fromPackedString:'C0A?8O?0??C?O?8??#?>O?8_? G>@@a'); - yourself); - yourself - ] + Icon flushCachedIcons + " + + + + ^Icon + constantNamed:'ImageEditor class pasteUnderIcon' + ifAbsentPut:[(Depth8Image width:14 height:14) bits:(ByteArray fromPackedString:' +:N#(:N#(:N#(:N#(:N#(:N#(:O#8:N#(:N#(:N#5>^#8:N#8:OW9:N#(:O''(=/[6=/[6:OW(:N#(=^#(:N#(:N#(>^#(:N#9=_''5>_W9=_''5:N#(:@DA@PDA +@PDA=_''(@@C(@_K2O?8??#?>O?8_? G>@@a'); yourself); yourself] ! pasteWithMaskIcon - "This resource specification was automatically generated by the ImageEditor of ST/X." + "Do not manually edit this!! If it is corrupted, the ImageEditor may not be able to read the specification." + " self pasteWithMaskIcon inspect ImageEditor openOnClass:self andSelector:#pasteWithMaskIcon - Icon flushCachedIcons" - - ^ Icon constantNamed:'ImageEditor class pasteWithMaskIcon' - ifAbsentPut:[ - (Depth4Image new) - width:14; - height:14; - photometric:(#palette); - bitsPerSample:(#( 4 )); - samplesPerPixel:(1); - bits:(ByteArray - fromPackedString:'@@@@@@@@@@@@AU@@@@@CHE@E@2@@@ QDQD@0@@L@@@@@H@@BL#H2L#@@@QDQDQL @@D3L@@@@@@AL3@3M&X@@SL0L3A&@@D3LCL0A @AL3@3LFX@@QDPY&Y& -@@@@@@@@@@@b'); - colorMapFromArray:#[ 0 0 0 0 0 128 128 128 0 128 128 128 212 208 200 255 255 0 255 255 255 ]; - mask:((ImageMask new) - width:14; - height:14; - bits:(ByteArray - fromPackedString:'C0A?8O?0??C?O?8??#?>O?8_? G>@@a'); - yourself); - yourself - ] + Icon flushCachedIcons + " + + + + ^Icon + constantNamed:'ImageEditor class pasteWithMaskIcon' + ifAbsentPut:[(Depth8Image width:14 height:14) bits:(ByteArray fromPackedString:' +:N#(:N#(:N#(:N#(:N#(:N#(:O#8:N#(:N#(:N#5>^#8:N#8:OW9:N#(:O''(=/[6=/[6:OW(:N#(=^#(:N#(:N#(>^#(:N#9=_''5>_W9=_''5:N#(:@DA@PDA +@PDA=_''(@@C(@_C0O?8??#?>O?8_? G>@@a'); yourself); yourself] ! pointIcon @@ -4060,11 +4065,19 @@ activeHelpKey: drawModePaste enabled: imageIsLoadedHolder label: 'Paste Over' - labelImage: (ResourceRetriever ImageEditor pasteIcon 'Paste') + labelImage: (ResourceRetriever ImageEditor pasteIcon 'Paste Over') choice: editMode choiceValue: paste ) (MenuItem + activeHelpKey: drawModePasteMasked + enabled: imageIsLoadedHolder + label: 'Paste Masked' + labelImage: (ResourceRetriever ImageEditor pasteIcon 'Paste Masked') + choice: editMode + choiceValue: pasteMasked + ) + (MenuItem activeHelpKey: drawModePasteUnder enabled: imageIsLoadedHolder label: 'Paste Under' @@ -4089,6 +4102,7 @@ ) "Modified: / 07-12-2017 / 15:30:46 / cg" + "Modified: / 27-05-2018 / 10:41:20 / Claus Gittinger" ! previewMenu @@ -4317,7 +4331,7 @@ (MenuItem activeHelpKey: drawModePaste enabled: imageIsLoadedAndNotReadonlyHolder - label: 'Paste' + label: 'Paste Over' translateLabel: true isButton: true labelImage: (ResourceRetriever ImageEditor pasteIcon) @@ -4325,6 +4339,16 @@ choiceValue: paste ) (MenuItem + activeHelpKey: drawModePasteMasked + enabled: imageIsLoadedAndNotReadonlyHolder + label: 'Paste Masked' + translateLabel: true + isButton: true + labelImage: (ResourceRetriever ImageEditor pasteMaskedIcon) + choice: editMode + choiceValue: pasteMasked + ) + (MenuItem activeHelpKey: drawModePasteUnder enabled: imageIsLoadedAndNotReadonlyHolder label: 'Paste Under' @@ -4360,6 +4384,7 @@ ) "Modified: / 24-08-2017 / 20:53:02 / cg" + "Modified: / 27-05-2018 / 10:45:31 / Claus Gittinger" ! ! !ImageEditor class methodsFor:'tableColumns specs'! @@ -5395,12 +5420,14 @@ self imageHasImageSequenceHolder value:(self imageHasImageSequence). self imageHasNextImageHolder value:(self imageHasNextImage). self imageHasPreviousImageHolder value:(self imageHasPreviousImage). - self alphaVisibleHolder value:(img hasAlphaChannel) + self alphaVisibleHolder value:(img hasAlphaChannel). ] ifFalse:[ self updateForNoImage - ] + ]. + self window label:(self constructWindowTitle). "Modified: / 05-09-2017 / 00:44:10 / cg" + "Modified: / 27-05-2018 / 11:32:01 / Claus Gittinger" ! updateColorsFromImage:image @@ -5443,6 +5470,7 @@ self alphaVisibleHolder value:false. "Modified: / 05-09-2017 / 00:44:20 / cg" + "Modified: / 27-05-2018 / 11:32:06 / Claus Gittinger" ! updateLabelsAndHistory @@ -5718,6 +5746,37 @@ !ImageEditor methodsFor:'help'! +constructWindowTitle + |resourceClass resourceSelector img| + + resourceClass := imageEditView resourceClass. + resourceClass notNil ifTrue:[ + resourceSelector := imageEditView resourceSelector. + resourceSelector notNil ifTrue:[ + ^ resources + string:(self modified + ifTrue:['ImageEditor (modified): %1 » %2'] + ifFalse:['ImageEditor: %1 » %2']) + with:resourceClass name + with:resourceSelector + ]. + ]. + + (img := imageEditView image) notNil ifTrue:[ + img fileName notNil ifTrue:[ + ^ resources + string:(self modified + ifTrue:['ImageEditor (modified): %1'] + ifFalse:['ImageEditor: %1']) + with:(img fileName asFilename baseName). + ]. + ^ resources string:'ImageEditor: some image.' + ]. + ^ resources string:'ImageEditor: << no image >>.' + + "Created: / 27-05-2018 / 11:31:20 / Claus Gittinger" +! + defaultInfoLabel "returns the text shown in the info label, when the mouse is NOT over some widget with a help text." @@ -6322,8 +6381,10 @@ self drawingColor1Holder valueHolder:(imageEditView drawingColorHolders at:1). self drawingColor2Holder valueHolder:(imageEditView drawingColorHolders at:2). imageEditView drawingAlpha:(self alphaHolder value). + self updateAfterImageChange. "Modified (format): / 05-09-2017 / 10:40:10 / cg" + "Modified: / 27-05-2018 / 11:20:57 / Claus Gittinger" ! ! !ImageEditor methodsFor:'user actions-colormap'! @@ -7392,6 +7453,8 @@ ! menu_pasteMask + "paste a mask from the clipboard" + |img mask| imageEditView makeUndo. @@ -7409,6 +7472,8 @@ (imageEditView image:img copy) notNil ifTrue:[ self fetchImageData. ] + + "Modified (comment): / 27-05-2018 / 11:11:54 / Claus Gittinger" ! menu_sortColorMap @@ -7499,7 +7564,7 @@ oldColors := drawingColormap. processingSubset := false. ] ifFalse:[ - (cMap isMappedPalette or:[cMap isFixedPalette]) ifTrue:[ + ("cMap isMappedPalette or:["cMap isFixedPalette"]") ifTrue:[ oldColors := cMap asArray. processingSubset := false. ] ifFalse:[ @@ -7549,6 +7614,7 @@ self selectedColors value:selectedColorIndices. "Modified: / 08-10-2017 / 09:20:13 / cg" + "Modified: / 27-05-2018 / 10:34:25 / Claus Gittinger" ! reduceNumberOfColors