diff --git a/source/GM-TE/GMTEEditor.class.st b/source/GM-TE/GMTEEditor.class.st index ffcb6884..337b734d 100644 --- a/source/GM-TE/GMTEEditor.class.st +++ b/source/GM-TE/GMTEEditor.class.st @@ -14,7 +14,8 @@ Class { 'inspector', 'morphBuilders', 'backgroundTile', - 'tileMap' + 'tileMap', + 'associatedMorph' ], #category : #'GM-TE-UI' } @@ -105,6 +106,15 @@ GMTEEditor class >> register [ TheWorldMenu registerOpenCommand: {'TileMap Editor'. {GMTEEditor. #new}} ] +{ + #category : #constants, + #'squeak_changestamp' : 'TW 6/25/2024 15:53' +} +GMTEEditor class >> singleLayerActionNames [ + + ^ {'buttonMoveLayerDown' . 'buttonMoveLayerUp' . 'buttonRenameLayer'} +] + { #category : #constants, #'squeak_changestamp' : 'jj 6/23/2024 17:33' @@ -172,6 +182,24 @@ GMTEEditor >> anyLayerSelected [ ^ (self selectedLayers size > 0) ] +{ + #category : #accessing, + #'squeak_changestamp' : 'TW 6/25/2024 15:55' +} +GMTEEditor >> associatedMorph [ + + ^ associatedMorph +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'TW 6/25/2024 15:55' +} +GMTEEditor >> associatedMorph: anObject [ + + associatedMorph := anObject. +] + { #category : #accessing, #'squeak_changestamp' : 'jj 6/22/2024 21:51' @@ -215,7 +243,7 @@ GMTEEditor >> blendSelectedLayers [ { #category : #building, - #'squeak_changestamp' : 'jj 6/23/2024 17:29' + #'squeak_changestamp' : 'TW 6/25/2024 15:56' } GMTEEditor >> buildWith: builder [ "builds the editor with ToolBuilder" @@ -262,7 +290,9 @@ GMTEEditor >> buildWith: builder [ borderWidth: 2; borderColor: tileStore borderColor. - self initializeDefaultTileMapMatrix. + self + initializeDefaultTileMapMatrix; + associatedMorph: newMorph. ^ newMorph ] @@ -430,7 +460,7 @@ GMTEEditor >> createInspectorSpecWithBuilder: aBuilder [ { #category : #building, - #'squeak_changestamp' : 'jj 6/23/2024 23:48' + #'squeak_changestamp' : 'TW 6/25/2024 15:50' } GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ "creates the spec for layer viewer" @@ -448,6 +478,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ (aBuilder pluggableImageButtonSpec new) model:self; action: #addLayer; + name: 'buttonAddLayer'; frame: (LayoutFrame fractions: (0 @ 0 corner: 1 @ 0.125)); project: 'GameMecha'; path: '/GMTEIcons/add.png'. @@ -455,6 +486,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ (aBuilder pluggableImageButtonSpec new) model:self; action: #moveLayerDown; + name: 'buttonMoveLayerDown'; frame: (LayoutFrame fractions: (0 @ 0.125 corner: 1 @ 0.25)); project: 'GameMecha'; path: '/GMTEIcons/up.png'. @@ -462,6 +494,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ (aBuilder pluggableImageButtonSpec new) model:self; action: #moveLayerUp; + name: 'buttonMoveLayerUp'; frame: (LayoutFrame fractions: (0 @ 0.25 corner: 1 @ 0.375)); project: 'GameMecha'; path: '/GMTEIcons/down.png'. @@ -469,6 +502,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ (aBuilder pluggableImageButtonSpec new) model: self; action: #renameLayer; + name: 'buttonRenameLayer'; frame: (LayoutFrame fractions: (0 @ 0.375 corner: 1 @ 0.5)); project: 'GameMecha'; path: '/GMTEIcons/rename.png'. @@ -476,6 +510,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ (aBuilder pluggableImageButtonSpec new) model:self; action:#resetSelectedLayers; + name: 'buttonResetLayers'; frame: (LayoutFrame fractions: (0 @ 0.5 corner: 1 @ 0.625)); project: 'GameMecha'; path: '/GMTEIcons/broom.png'. @@ -483,6 +518,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ (aBuilder pluggableImageButtonSpec new) model:self; action: #blendSelectedLayers; + name: 'buttonBlendLayers'; frame: (LayoutFrame fractions: (0 @ 0.625 corner: 1 @ 0.75)); project: 'GameMecha'; path: '/GMTEIcons/merge.png'. @@ -490,6 +526,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ (aBuilder pluggableImageButtonSpec new) model:self; action: #deleteSelectedLayers; + name: 'buttonDeleteLayers'; frame: (LayoutFrame fractions: (0 @ 0.75 corner: 1 @ 0.875)); project: 'GameMecha'; path: '/GMTEIcons/trash.png'. @@ -497,6 +534,7 @@ GMTEEditor >> createLayersSpecWithBuilder: aBuilder [ (aBuilder pluggableImageButtonSpec new) model:self; action: #toggleSelectedLayerVisibility; + name: 'buttonToggleVisibilityLayers'; frame: (LayoutFrame fractions: (0 @ 0.875 corner: 1 @ 1)); project: 'GameMecha'; path: '/GMTEIcons/eye.png'}. @@ -626,7 +664,7 @@ GMTEEditor >> deselectAllLayers [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 20:47' + #'squeak_changestamp' : 'TW 6/25/2024 16:02' } GMTEEditor >> deselectLayer: anIndex [ "deletes the layer with the provided index" @@ -636,6 +674,7 @@ GMTEEditor >> deselectLayer: anIndex [ (self selectedLayers includes: anIndex) ifTrue: [ self selectedLayers remove: anIndex. + self singleLayerSelected ifTrue: [self enableSingleLayerButtons]. self changed: #selectedLayers; changed: #layerAt:] @@ -654,6 +693,24 @@ GMTEEditor >> deselectTile [ self tileMap tileSelectionSet highlightImage: nil ] +{ + #category : #'as yet unclassified', + #'squeak_changestamp' : 'TW 6/25/2024 15:57' +} +GMTEEditor >> disableSingleLayerButtons [ + + GMTEEditor singleLayerActionNames do: [:aString | (self associatedMorph submorphNamed: aString) enabled: false ] +] + +{ + #category : #'as yet unclassified', + #'squeak_changestamp' : 'TW 6/25/2024 15:57' +} +GMTEEditor >> enableSingleLayerButtons [ + + GMTEEditor singleLayerActionNames do: [:aString | (self associatedMorph submorphNamed: aString) enabled: true ] +] + { #category : #'menu button functions', #'squeak_changestamp' : 'jj 6/22/2024 20:48' @@ -894,7 +951,7 @@ GMTEEditor >> importMenu [ { #category : #initialization, - #'squeak_changestamp' : 'TW 6/23/2024 20:14' + #'squeak_changestamp' : 'TW 6/25/2024 15:45' } GMTEEditor >> initialize [ "starts the tile editor" @@ -1309,12 +1366,15 @@ GMTEEditor >> selectAllLayers [ { #category : #accessing, - #'squeak_changestamp' : 'jj 6/22/2024 21:33' + #'squeak_changestamp' : 'TW 6/25/2024 17:01' } GMTEEditor >> selectLayer: anIndex [ "select the layer with anIndex" self selectedLayers add: anIndex. + self singleLayerSelected + ifTrue: [self enableSingleLayerButtons] + ifFalse: [self disableSingleLayerButtons]. self changed: #selectedLayers; changed: #layerAt: diff --git a/source/GM-TE/GMTEImageButton.class.st b/source/GM-TE/GMTEImageButton.class.st index 2584394b..106ab4ae 100644 --- a/source/GM-TE/GMTEImageButton.class.st +++ b/source/GM-TE/GMTEImageButton.class.st @@ -11,7 +11,8 @@ Class { 'actionSelector', 'arguments', 'linkedButtons', - 'stateSprites' + 'stateSprites', + 'enabled' ], #category : #'GM-TE-UI', #'squeak_changestamp' : '' @@ -55,6 +56,15 @@ GMTEImageButton >> arguments: aCollection [ arguments := aCollection asArray copy ] +{ + #category : #accessing, + #'squeak_changestamp' : 'TW 6/25/2024 15:28' +} +GMTEImageButton >> basicEnabled: anObject [ + + enabled := anObject +] + { #category : #accessing, #'squeak_changestamp' : 'jj 6/22/2024 16:48' @@ -102,6 +112,31 @@ GMTEImageButton >> dyeSprite: anImage with: aColor [ yourself ] +{ + #category : #accessing, + #'squeak_changestamp' : 'TW 6/25/2024 15:23' +} +GMTEImageButton >> enabled [ + + ^ enabled +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'TW 6/25/2024 15:33' +} +GMTEImageButton >> enabled: aBoolean [ + + aBoolean + ifTrue: [ + self basicEnabled: true. + self setImageMode: 'unpressed'] + ifFalse: [ + self basicEnabled: false. + self setImageMode: 'disabled'] + +] + { #category : #'event handling', #'squeak_changestamp' : 'jj 6/22/2024 16:48' @@ -131,7 +166,7 @@ GMTEImageButton >> handlesMouseOver: anEvent [ { #category : #initialization, - #'squeak_changestamp' : 'TW 6/22/2024 01:13' + #'squeak_changestamp' : 'TW 6/25/2024 15:39' } GMTEImageButton >> initialize [ @@ -160,10 +195,12 @@ GMTEImageButton >> linkedButtons: aCollection [ { #category : #'event handling', - #'squeak_changestamp' : 'jj 6/22/2024 16:49' + #'squeak_changestamp' : 'TW 6/25/2024 15:42' } GMTEImageButton >> mouseDown: anEvent [ + self enabled ifFalse: [^ nil]. + super mouseDown: anEvent. anEvent yellowButtonPressed ifTrue: [^ self]. @@ -172,28 +209,34 @@ GMTEImageButton >> mouseDown: anEvent [ { #category : #'event handling', - #'squeak_changestamp' : 'Alex M 6/21/2024 20:38' + #'squeak_changestamp' : 'TW 6/25/2024 15:41' } GMTEImageButton >> mouseLeave: anEvent [ + self enabled ifFalse: [^ nil]. + self updateVisualState: anEvent ] { #category : #'event handling', - #'squeak_changestamp' : 'Alex M 6/21/2024 20:34' + #'squeak_changestamp' : 'TW 6/25/2024 15:41' } GMTEImageButton >> mouseMove: anEvent [ + self enabled ifFalse: [^ nil]. + self updateVisualState: anEvent ] { #category : #'event handling', - #'squeak_changestamp' : 'Alex M 6/21/2024 20:41' + #'squeak_changestamp' : 'TW 6/25/2024 15:42' } GMTEImageButton >> mouseUp: anEvent [ + self enabled ifFalse: [^ nil]. + (self containsPoint: anEvent cursorPoint) ifTrue: [self doButtonAction] ifFalse: [self mouseLeave: anEvent]. @@ -213,22 +256,11 @@ GMTEImageButton >> select [ { #category : #accessing, - #'squeak_changestamp' : 'TW 6/23/2024 18:47' + #'squeak_changestamp' : 'TW 6/25/2024 15:39' } GMTEImageButton >> setImageMode: aString [ - (aString == #pressed) - ifTrue: [ - self fullResolutionSprite: (self stateSprites at: 'pressed')] - ifFalse: [ - (aString == #unpressed) - ifTrue: [ - self fullResolutionSprite: (self stateSprites at: 'unpressed')] - ifFalse: [ - (aString == #hovered) - ifTrue: [self fullResolutionSprite: (self stateSprites at: 'hovered')] - ifFalse: [^ nil]]]. - + self fullResolutionSprite: (self stateSprites at: aString). self extent: self extent ] @@ -271,13 +303,13 @@ GMTEImageButton >> target: anObject [ { #category : #'visual properties', - #'squeak_changestamp' : 'Alex M 6/22/2024 01:44' + #'squeak_changestamp' : 'TW 6/25/2024 15:41' } GMTEImageButton >> updateVisualState: anEvent [ (self containsPoint: Sensor cursorPoint) ifTrue: [ anEvent redButtonPressed - ifTrue: [self setImageMode: #pressed] - ifFalse:[self setImageMode: #hovered]] - ifFalse: [self setImageMode: #unpressed] + ifTrue: [self setImageMode: 'pressed'] + ifFalse:[self setImageMode: 'hovered']] + ifFalse: [self setImageMode: 'unpressed'] ] diff --git a/source/GM-TE/GMTETileVisual.class.st b/source/GM-TE/GMTETileHighlighting.class.st similarity index 100% rename from source/GM-TE/GMTETileVisual.class.st rename to source/GM-TE/GMTETileHighlighting.class.st diff --git a/source/GM-TE/GMTETileMap.class.st b/source/GM-TE/GMTETileMap.class.st index fb6ef2f8..9b045f94 100644 --- a/source/GM-TE/GMTETileMap.class.st +++ b/source/GM-TE/GMTETileMap.class.st @@ -363,6 +363,20 @@ GMTETileMap >> generateBackgroundTiles [ tile applyTileSprite: self backgroundTiles] +] + +{ + #category : #initialization, + #'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:27' +} +GMTETileMap >> generateHighlightingTiles [ + "Fill the highlighting matrix stack with tiles automatically" + + self tileMatrixStackHighlighting doTilesXYLindex: [:x :y :l | + "It is assumed that the visual stack consists of only one layer" + self generateTileAtlayer: l x: x y: y stack: self tileMatrixStackHighlighting tileType: GMTETileHighlighting] + + ] { @@ -420,20 +434,6 @@ GMTETileMap >> generateTileAtlayer: aLayer x: x y: y stack: aStack tileType: aTi -] - -{ - #category : #initialization, - #'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:27' -} -GMTETileMap >> generateHighlightingTiles [ - "Fill the highlighting matrix stack with tiles automatically" - - self tileMatrixStackHighlighting doTilesXYLindex: [:x :y :l | - "It is assumed that the visual stack consists of only one layer" - self generateTileAtlayer: l x: x y: y stack: self tileMatrixStackHighlighting tileType: GMTETileHighlighting] - - ] { @@ -475,6 +475,20 @@ GMTETileMap >> hideHighlightingLayer [ ] +{ + #category : #accessing, + #'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:08' +} +GMTETileMap >> highlightingTileFromPosition: aPoint [ + "Answer the sender with a highlighting tile at aPoint if present" + + | index | + index := self tileIndexFromPosition: aPoint. + index ifNil: [^ nil]. + + ^ self tileMatrixStackHighlighting layer: 1 at: index y at: index x +] + { #category : #initialization, #'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 23:32' @@ -944,20 +958,6 @@ GMTETileMap >> tileSizeWidth: anObject [ tileSizeWidth := anObject ] -{ - #category : #accessing, - #'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:08' -} -GMTETileMap >> highlightingTileFromPosition: aPoint [ - "Answer the sender with a highlighting tile at aPoint if present" - - | index | - index := self tileIndexFromPosition: aPoint. - index ifNil: [^ nil]. - - ^ self tileMatrixStackHighlighting layer: 1 at: index y at: index x -] - { #category : #accessing, #'squeak_changestamp' : 'Ivo Zilkenat 5/19/2024 15:57' diff --git a/source/ToolBuilder-Morphic/MorphicToolBuilder.class.st b/source/ToolBuilder-Morphic/MorphicToolBuilder.class.st index db0f230c..fc702b69 100644 --- a/source/ToolBuilder-Morphic/MorphicToolBuilder.class.st +++ b/source/ToolBuilder-Morphic/MorphicToolBuilder.class.st @@ -362,16 +362,19 @@ MorphicToolBuilder >> buildPluggableDropDownList: spec [ { #category : #'widgets required', - #'squeak_changestamp' : 'Alex M 6/21/2024 18:55' + #'squeak_changestamp' : 'TW 6/25/2024 15:28' } MorphicToolBuilder >> buildPluggableImageButton: aSpec [ - | widget project | + | widget project enabled | project := aSpec project. widget := GMTEImageButton new target: aSpec model; actionSelector: aSpec action; createStateImagesFrom: ((GitAssetLoader for: project) loadForm: aSpec path) copy. + enabled := aSpec enabled. + enabled isSymbol ifFalse: [widget enabled:enabled]. + self register: widget id: aSpec name. widget setImageMode: #unpressed. @@ -381,7 +384,7 @@ MorphicToolBuilder >> buildPluggableImageButton: aSpec [ self setFrame: aSpec frame in: widget. self setLayoutHintsFor: widget spec: aSpec. parent ifNotNil:[self add: widget to: parent]. - ^widget + ^ widget ] {