Skip to content

Commit

Permalink
Merge origin/tmm-dev into tmm-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
RedToxyl committed Jul 11, 2024
2 parents 8f15160 + 4a35958 commit 9b27151
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 19 deletions.
29 changes: 25 additions & 4 deletions source/GM-TE/GMTEEditorTileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ GMTEEditorTileMap >> handlesMouseMove: anEvent [
^ true
]

{
#category : #'event handling',
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 17:14'
}
GMTEEditorTileMap >> handlesMouseOver: anEvent [

^ true
]

{
#category : #initialization,
#'squeak_changestamp' : 'Alex M 6/28/2024 20:24'
Expand Down Expand Up @@ -131,7 +140,18 @@ GMTEEditorTileMap >> mouseDown: anEvent [

{
#category : #'event handling',
#'squeak_changestamp' : 'JS 7/11/2024 14:01'
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 17:18'
}
GMTEEditorTileMap >> mouseLeave: anEvent [

self tileSelectionSet clearAllHighlightings.

^ true
]

{
#category : #'event handling',
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 17:01'
}
GMTEEditorTileMap >> mouseMove: anEvent [
"Implements highlighting of tiles when hovering"
Expand All @@ -146,9 +166,10 @@ GMTEEditorTileMap >> mouseMove: anEvent [

selectedCoordinates ifNil: [^ nil].

(selectedCoordinates select: [:c | (self tileMatrixStack layer: activeLayer) inBounds: c]) do: [:t|
hoveredTileHighlighting := self highlightingTileFromIndex: t.
hoveredTileHighlighting ifNotNil: [self tileSelectionSet highlightTile: hoveredTileHighlighting]]
(selectedCoordinates select: [:c |
(self tileMatrixStack layer: activeLayer) inBounds: c]) do: [:t |
hoveredTileHighlighting := self highlightingTileFromIndex: t.
hoveredTileHighlighting ifNotNil: [self tileSelectionSet highlightTile: hoveredTileHighlighting]]
]

{
Expand Down
98 changes: 86 additions & 12 deletions source/GM-TE/GMTETileMap.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ GMTETileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPadding siz
tileSizeRatio: aRatio
]

{
#category : #'view-conversion',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 22:20'
}
GMTETileMap >> absPointToViewCenter: aPoint [

^ (self absPointToViewFraction: aPoint) - (self view extent / 2)
]

{
#category : #'view-conversion',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 22:19'
}
GMTETileMap >> absPointToViewFraction: aPoint [

^aPoint / self extent
]

{
#category : #accessing,
#'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 22:28'
Expand Down Expand Up @@ -193,6 +211,17 @@ GMTETileMap >> borderTileWidth: anObject [
borderTileWidth := anObject
]

{
#category : #view,
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 00:08'
}
GMTETileMap >> centerViewAt: aPoint [
"Note: center must induce legal view (non-overlapping)"

self view moveTo: (self inViewPointToViewCenter: aPoint).
self updateMap
]

{
#category : #conversion,
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:09'
Expand Down Expand Up @@ -477,9 +506,36 @@ GMTETileMap >> highlightingTileFromIndex: anIndex [
^ self tileMatrixStackHighlighting layer: 1 at: anIndex y at: anIndex x
]

{
#category : #'view-conversion',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 22:58'
}
GMTETileMap >> inViewPointToAbs: aPoint [

^ (self viewOriginInPxl - self topLeft) + (aPoint / self viewScaleFactor)
]

{
#category : #'view-conversion',
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 00:01'
}
GMTETileMap >> inViewPointToViewCenter: aPoint [

^ (self inViewPointToViewFraction: aPoint) - (self view extent / 2)
]

{
#category : #'view-conversion',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 22:30'
}
GMTETileMap >> inViewPointToViewFraction: aPoint [

^ self absPointToViewFraction: (self inViewPointToAbs: aPoint)
]

{
#category : #initialization,
#'squeak_changestamp' : 'Ivo Zilkenat 7/9/2024 11:47'
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:15'
}
GMTETileMap >> initialize [

Expand All @@ -488,7 +544,7 @@ GMTETileMap >> initialize [
color: Color lightGray;
clipSubmorphs: true;
forceMapSizeRatio: false;
view: (GMTEView origin: 0 @ 0 extent: 1 @ 1);
view: GMTEView new;

"TODO: spike solution. Size 1@1 sets quadratic base image. Generic resizing not working yet"
"TODO: default background tiles (must not exist but practical as a visual indicator)"
Expand Down Expand Up @@ -690,6 +746,16 @@ GMTETileMap >> rescaleMatrixStacks [
self generateHighlightingTiles]
]

{
#category : #view,
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:47'
}
GMTETileMap >> resetView [

self view reset.
self updateMap
]

{
#category : #conversion,
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:11'
Expand Down Expand Up @@ -721,7 +787,7 @@ GMTETileMap >> revertCorrectedTilePositionMap: aPoint [
]

{
#category : #view,
#category : #'view-conversion',
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:49'
}
GMTETileMap >> revertViewCorrectedTilePosition: aPoint [
Expand All @@ -731,7 +797,7 @@ GMTETileMap >> revertViewCorrectedTilePosition: aPoint [
]

{
#category : #view,
#category : #'view-conversion',
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:47'
}
GMTETileMap >> revertViewCorrectedTilePositionMap: aPoint [
Expand Down Expand Up @@ -1193,7 +1259,7 @@ GMTETileMap >> view: anObject [
]

{
#category : #view,
#category : #'view-conversion',
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:36'
}
GMTETileMap >> viewCorrectedTileExtent: anExtent [
Expand All @@ -1203,7 +1269,7 @@ GMTETileMap >> viewCorrectedTileExtent: anExtent [
]

{
#category : #view,
#category : #'view-conversion',
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:36'
}
GMTETileMap >> viewCorrectedTilePosition: aPoint [
Expand All @@ -1213,22 +1279,20 @@ GMTETileMap >> viewCorrectedTilePosition: aPoint [
]

{
#category : #view,
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:36'
#category : #'view-conversion',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 17:50'
}
GMTETileMap >> viewOriginInPxl [

"Note: given that view has same ratio as tileMap"

^ self extent * self view origin + self topLeft
]

{
#category : #view,
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 19:47'
#category : #'view-conversion',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 17:50'
}
GMTETileMap >> viewScaleFactor [

"Note: given that view has same ratio as tileMap"

^ 1 / (self view extent x)
Expand All @@ -1253,3 +1317,13 @@ GMTETileMap >> vigenerateBackgroundTiles [


]

{
#category : #view,
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 00:33'
}
GMTETileMap >> zoomInAt: aPoint [

self view shrinkBy: 0.1.
self centerViewAt: aPoint
]
80 changes: 77 additions & 3 deletions source/GM-TE/GMTEView.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ Class {
#category : #'GM-TE-TileMap'
}

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:17'
}
GMTEView >> enlargeBy: aFloat [

| newExtent |
newExtent := (self extent + (aFloat@aFloat)).

self flag: 'magic number'.
((newExtent x > 1) or: [newExtent y > 1]) ifTrue: [^ nil].
(self isOverlappingOrigin: self origin withExtent: newExtent) ifTrue: [^ nil].

self extent: newExtent
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:20'
Expand All @@ -15,22 +31,80 @@ GMTEView >> extent: anExtent [

{
#category : #initialization,
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 19:41'
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:15'
}
GMTEView >> initialize [

"Note: Viewport origin & extent interpreted as fraction of reference view (e.g. Morph)"

super initialize.
self reset


]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:14'
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:05'
}
GMTEView >> isOverlappingOrigin: anOrigin withExtent: anExtent [

| corner |
corner := anOrigin + anExtent.
^ (corner x > 1) or: [corner y > 1]
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:20'
}
GMTEView >> moveTo: anOrigin [
"Set origin but also respect view not overlapping reference view"

(self isOverlappingOrigin: anOrigin withExtent: self extent) ifTrue: [^ nil].

self origin: anOrigin
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:33'
}
GMTEView >> origin: aPoint [

self setOrigin: aPoint corner: self corner
self setOrigin: aPoint corner: (aPoint + self corner)
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:33'
}
GMTEView >> reset [

self setOrigin: 0 @ 0 corner: 1 @ 1.

]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:16'
}
GMTEView >> shrinkBy: aFloat [

| newExtent |
newExtent := (self extent - (aFloat@aFloat)).

self flag: 'magic number'.
((newExtent x <= 0.1) or: [newExtent y <= 0.1]) ifTrue: [^ nil].

self extent: newExtent
]

{
#category : #'as yet unclassified',
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 22:53'
}
GMTEView >> size: aFraction [

self extent: (aFraction @ aFraction)
]

0 comments on commit 9b27151

Please sign in to comment.