Skip to content

Commit

Permalink
Added visibility toggle for layers
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivo Zilkenat committed Jun 18, 2024
1 parent 9705aa8 commit d88206c
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 60 deletions.
4 changes: 2 additions & 2 deletions source/GM-TE/GMTEEditor.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -990,15 +990,15 @@ GMTEEditor >> openTileMapInEditor: aTileMap [

{
#category : #'button functions',
#'squeak_changestamp' : 'Alex M 6/14/2024 13:10'
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:31'
}
GMTEEditor >> openTileMapInWorld [
"open the current tileMap into world"

(GMTETileMap newFrom: (self tileMapMatrix copy))
position: 0@0;
openInWorld;
disableVisualLayer
hideVisualLayer
]

{
Expand Down
6 changes: 3 additions & 3 deletions source/GM-TE/GMTEImageMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ GMTEImageMorph >> fullResolutionSprite: anObject [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'TW 5/22/2024 23:32'
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 09:50'
}
GMTEImageMorph >> setPlaceholderColor: aColor [
GMTEImageMorph >> setPlaceholderWithColor: aColor [

| placeholderForm |
placeholderForm := Form extent: self extent depth: 32.
Expand All @@ -96,7 +96,7 @@ GMTEImageMorph >> setPlaceholderWithExtent: anExtent color: aColor [
]

{
#category : #'as yet unclassified',
#category : #updating,
#'squeak_changestamp' : 'TW 5/22/2024 17:18'
}
GMTEImageMorph >> updateSprite: anImage [
Expand Down
4 changes: 2 additions & 2 deletions source/GM-TE/GMTETile.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ GMTETile class >> position: aPoint extent: anExtent [

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 22:22'
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 09:50'
}
GMTETile >> setToPlaceholder [

self setPlaceholderColor: GMTETile placeHolderColor
self setPlaceholderWithColor: GMTETile placeHolderColor
]
75 changes: 26 additions & 49 deletions source/GM-TE/GMTETileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ Class {
'tileCornerOffset',
'mapPaddedHeight',
'tileMatrixStack',
'tileMatrixStackVisual',
'visualLayerEnabled'
'tileMatrixStackVisual'
],
#category : #'GM-TE-Core'
}
Expand Down Expand Up @@ -121,28 +120,6 @@ GMTETileMap >> correctedTilePosition: aPoint [
^ (self tileCornerOffset + aPoint + self topLeft) floor
]

{
#category : #updating,
#'squeak_changestamp' : 'Alex M 6/13/2024 14:57'
}
GMTETileMap >> disableVisualLayer [

self tileMatrixStackVisual doTiles: [ :aTile | aTile removeBorderHighlighting].
self visualLayerEnabled: false.

]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/14/2024 18:59'
}
GMTETileMap >> enableVisualLayer [

self tileMatrixStackVisual doTiles: [ :aTile | aTile applyBorderHighlighting].
"self rescaleMap."
self visualLayerEnabled: true
]

{
#category : #'import/export',
#'squeak_changestamp' : 'Ivo Zilkenat 5/20/2024 20:54'
Expand Down Expand Up @@ -206,14 +183,13 @@ GMTETileMap >> fullGridSizeWidth: anObject [

{
#category : #initialization,
#'squeak_changestamp' : 'Ivo Zilkenat 6/12/2024 14:26'
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:20'
}
GMTETileMap >> generateMatrixStacks [

self tileMatrixStack: (GMTETileMatrixStack fromWidth: self tileWidth height: self tileHeight).
self tileMatrixStackVisual: (GMTETileMatrixStack fromWidth: self tileWidth height: self tileHeight morphicLayerOffset: 10). "TODO: Number ?"
self generateVisualTiles.
self enableVisualLayer
]

{
Expand Down Expand Up @@ -280,6 +256,16 @@ GMTETileMap >> getTileFromLayer: aLayer x: x y: y stack: aStack [



]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:16'
}
GMTETileMap >> hideVisualLayer [

self tileMatrixStackVisual hideLayer: 1.

]

{
Expand Down Expand Up @@ -472,7 +458,7 @@ GMTETileMap >> rescaleMapWidth: aWidth height: aHeigth padding: aPadding [

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/11/2024 18:37'
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:20'
}
GMTETileMap >> rescaleMatrixStacks [

Expand All @@ -484,8 +470,7 @@ GMTETileMap >> rescaleMatrixStacks [
(self tileMatrixStackVisual) ifNotNil: [
self tileMatrixStackVisual rescaleToWidth: self mapTileWidth height: self mapTileHeight.
self tileMatrixStackVisual reset.
self generateVisualTiles.
self enableVisualLayer] "TODO: make "
self generateVisualTiles] "TODO: make "
]

{
Expand All @@ -511,6 +496,16 @@ GMTETileMap >> setDimensionsWidth: aWidth height: aHeigth padding: aPadding [
mapPadding: aPadding
]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:16'
}
GMTETileMap >> showVisualLayer [

self tileMatrixStackVisual showLayer: 1.
"self rescaleMap."
]

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 5/19/2024 15:57'
Expand Down Expand Up @@ -710,13 +705,11 @@ GMTETileMap >> tileWidth: anObject [

{
#category : #updating,
#'squeak_changestamp' : 'Alex M 6/13/2024 14:58'
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:36'
}
GMTETileMap >> toggleVisualLayer [

visualLayerEnabled
ifTrue: [self disableVisualLayer]
ifFalse: [self enableVisualLayer]
self tileMatrixStackVisual toggleLayerVisibility: 1.
]

{
Expand Down Expand Up @@ -815,19 +808,3 @@ GMTETileMap >> updateTiles [
self updateTileMatrixStack: self tileMatrixStack.
self updateTileMatrixStack: self tileMatrixStackVisual
]

{
#category : #accessing,
#'squeak_changestamp' : 'Alex M 6/13/2024 14:56'
}
GMTETileMap >> visualLayerEnabled [
^ visualLayerEnabled
]

{
#category : #accessing,
#'squeak_changestamp' : 'Alex M 6/13/2024 14:56'
}
GMTETileMap >> visualLayerEnabled: anObject [
visualLayerEnabled := anObject
]
45 changes: 41 additions & 4 deletions source/GM-TE/GMTETileMatrixLayer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Class {
#name : #GMTETileMatrixLayer,
#superclass : #GMTEStaticCoordinateMatrix,
#instVars : [
'layerIdx'
'layerIdx',
'visible'
],
#category : #'GM-TE-Core'
}
Expand Down Expand Up @@ -30,12 +31,13 @@ GMTETileMatrixLayer >> aboveLayer: aLayer [

{
#category : #adding,
#'squeak_changestamp' : 'Ivo Zilkenat 6/11/2024 19:16'
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:41'
}
GMTETileMatrixLayer >> addTile: aTile at: x at: y [

aTile ifNotNil: [
aTile morphicLayerNumber: self layerIdx].
aTile morphicLayerNumber: self layerIdx.
aTile visible: self visible].
^self at: x at: y put: aTile
]

Expand Down Expand Up @@ -69,10 +71,13 @@ GMTETileMatrixLayer >> belowLayer: aLayer [

{
#category : #enumerating,
#'squeak_changestamp' : 'Valentin Teutschbein 6/7/2024 20:55'
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:29'
}
GMTETileMatrixLayer >> doTiles: aBlock [

"Instance variable must be used here"
(contents) ifNil: [^nil].

self contents do: [ :tile |
tile ifNotNil: [aBlock value: tile]]
]
Expand All @@ -89,6 +94,17 @@ GMTETileMatrixLayer >> free [
self setNil
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:25'
}
GMTETileMatrixLayer >> initialize [

super initialize.

self visible: true
]

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/11/2024 19:09'
Expand Down Expand Up @@ -128,3 +144,24 @@ GMTETileMatrixLayer >> updateLayerIdx: anIdx [
self doTiles: [ :tile |
tile morphicLayerNumber: self layerIdx]
]

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:17'
}
GMTETileMatrixLayer >> visible [

^ visible
]

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:18'
}
GMTETileMatrixLayer >> visible: aBool [

visible := aBool.

self doTiles: [ :tile |
tile visible: aBool]
]
39 changes: 39 additions & 0 deletions source/GM-TE/GMTETileMatrixStack.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ GMTETileMatrixStack >> height: anObject [
height := anObject.
]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:09'
}
GMTETileMatrixStack >> hideLayer: anIdx [

(self layer: anIdx) visible: false
]

{
#category : #initilization,
#'squeak_changestamp' : 'Ivo Zilkenat 6/12/2024 14:25'
Expand All @@ -120,6 +129,15 @@ GMTETileMatrixStack >> initialize [
"TODO: no base layer created"
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:34'
}
GMTETileMatrixStack >> isVisible: anIdx [

^(self layer: anIdx) visible
]

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/12/2024 18:28'
Expand Down Expand Up @@ -248,6 +266,15 @@ GMTETileMatrixStack >> reset [
(self layer: 1) free
]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:09'
}
GMTETileMatrixStack >> showLayer: anIdx [

(self layer: anIdx) visible: true
]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/11/2024 19:33'
Expand All @@ -267,6 +294,18 @@ GMTETileMatrixStack >> swapLayer: anIdx1 with: anIdx2 [

]

{
#category : #updating,
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:36'
}
GMTETileMatrixStack >> toggleLayerVisibility: anIdx [

(self isVisible: anIdx)
ifTrue: [self hideLayer: anIdx]
ifFalse: [self showLayer: anIdx]

]

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 22:05'
Expand Down
10 changes: 10 additions & 0 deletions source/GM-TE/GMTETileVisual.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ GMTETileVisual >> decorationMorph: anObject [
decorationMorph := anObject.
]

{
#category : #initialization,
#'squeak_changestamp' : 'Ivo Zilkenat 6/18/2024 10:14'
}
GMTETileVisual >> initialize [

super initialize.
self applyBorderHighlighting
]

{
#category : #highlighting,
#'squeak_changestamp' : 'Ivo Zilkenat 6/7/2024 21:25'
Expand Down

0 comments on commit d88206c

Please sign in to comment.