Skip to content

Commit 9b27151

Browse files
committed
Merge origin/tmm-dev into tmm-dev
2 parents 8f15160 + 4a35958 commit 9b27151

File tree

3 files changed

+188
-19
lines changed

3 files changed

+188
-19
lines changed

source/GM-TE/GMTEEditorTileMap.class.st

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ GMTEEditorTileMap >> handlesMouseMove: anEvent [
8080
^ true
8181
]
8282

83+
{
84+
#category : #'event handling',
85+
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 17:14'
86+
}
87+
GMTEEditorTileMap >> handlesMouseOver: anEvent [
88+
89+
^ true
90+
]
91+
8392
{
8493
#category : #initialization,
8594
#'squeak_changestamp' : 'Alex M 6/28/2024 20:24'
@@ -131,7 +140,18 @@ GMTEEditorTileMap >> mouseDown: anEvent [
131140

132141
{
133142
#category : #'event handling',
134-
#'squeak_changestamp' : 'JS 7/11/2024 14:01'
143+
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 17:18'
144+
}
145+
GMTEEditorTileMap >> mouseLeave: anEvent [
146+
147+
self tileSelectionSet clearAllHighlightings.
148+
149+
^ true
150+
]
151+
152+
{
153+
#category : #'event handling',
154+
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 17:01'
135155
}
136156
GMTEEditorTileMap >> mouseMove: anEvent [
137157
"Implements highlighting of tiles when hovering"
@@ -146,9 +166,10 @@ GMTEEditorTileMap >> mouseMove: anEvent [
146166

147167
selectedCoordinates ifNil: [^ nil].
148168

149-
(selectedCoordinates select: [:c | (self tileMatrixStack layer: activeLayer) inBounds: c]) do: [:t|
150-
hoveredTileHighlighting := self highlightingTileFromIndex: t.
151-
hoveredTileHighlighting ifNotNil: [self tileSelectionSet highlightTile: hoveredTileHighlighting]]
169+
(selectedCoordinates select: [:c |
170+
(self tileMatrixStack layer: activeLayer) inBounds: c]) do: [:t |
171+
hoveredTileHighlighting := self highlightingTileFromIndex: t.
172+
hoveredTileHighlighting ifNotNil: [self tileSelectionSet highlightTile: hoveredTileHighlighting]]
152173
]
153174

154175
{

source/GM-TE/GMTETileMap.class.st

Lines changed: 86 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@ GMTETileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPadding siz
9090
tileSizeRatio: aRatio
9191
]
9292

93+
{
94+
#category : #'view-conversion',
95+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 22:20'
96+
}
97+
GMTETileMap >> absPointToViewCenter: aPoint [
98+
99+
^ (self absPointToViewFraction: aPoint) - (self view extent / 2)
100+
]
101+
102+
{
103+
#category : #'view-conversion',
104+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 22:19'
105+
}
106+
GMTETileMap >> absPointToViewFraction: aPoint [
107+
108+
^aPoint / self extent
109+
]
110+
93111
{
94112
#category : #accessing,
95113
#'squeak_changestamp' : 'Ivo Zilkenat 6/19/2024 22:28'
@@ -193,6 +211,17 @@ GMTETileMap >> borderTileWidth: anObject [
193211
borderTileWidth := anObject
194212
]
195213

214+
{
215+
#category : #view,
216+
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 00:08'
217+
}
218+
GMTETileMap >> centerViewAt: aPoint [
219+
"Note: center must induce legal view (non-overlapping)"
220+
221+
self view moveTo: (self inViewPointToViewCenter: aPoint).
222+
self updateMap
223+
]
224+
196225
{
197226
#category : #conversion,
198227
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:09'
@@ -477,9 +506,36 @@ GMTETileMap >> highlightingTileFromIndex: anIndex [
477506
^ self tileMatrixStackHighlighting layer: 1 at: anIndex y at: anIndex x
478507
]
479508

509+
{
510+
#category : #'view-conversion',
511+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 22:58'
512+
}
513+
GMTETileMap >> inViewPointToAbs: aPoint [
514+
515+
^ (self viewOriginInPxl - self topLeft) + (aPoint / self viewScaleFactor)
516+
]
517+
518+
{
519+
#category : #'view-conversion',
520+
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 00:01'
521+
}
522+
GMTETileMap >> inViewPointToViewCenter: aPoint [
523+
524+
^ (self inViewPointToViewFraction: aPoint) - (self view extent / 2)
525+
]
526+
527+
{
528+
#category : #'view-conversion',
529+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 22:30'
530+
}
531+
GMTETileMap >> inViewPointToViewFraction: aPoint [
532+
533+
^ self absPointToViewFraction: (self inViewPointToAbs: aPoint)
534+
]
535+
480536
{
481537
#category : #initialization,
482-
#'squeak_changestamp' : 'Ivo Zilkenat 7/9/2024 11:47'
538+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:15'
483539
}
484540
GMTETileMap >> initialize [
485541

@@ -488,7 +544,7 @@ GMTETileMap >> initialize [
488544
color: Color lightGray;
489545
clipSubmorphs: true;
490546
forceMapSizeRatio: false;
491-
view: (GMTEView origin: 0 @ 0 extent: 1 @ 1);
547+
view: GMTEView new;
492548

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

749+
{
750+
#category : #view,
751+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:47'
752+
}
753+
GMTETileMap >> resetView [
754+
755+
self view reset.
756+
self updateMap
757+
]
758+
693759
{
694760
#category : #conversion,
695761
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:11'
@@ -721,7 +787,7 @@ GMTETileMap >> revertCorrectedTilePositionMap: aPoint [
721787
]
722788

723789
{
724-
#category : #view,
790+
#category : #'view-conversion',
725791
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:49'
726792
}
727793
GMTETileMap >> revertViewCorrectedTilePosition: aPoint [
@@ -731,7 +797,7 @@ GMTETileMap >> revertViewCorrectedTilePosition: aPoint [
731797
]
732798

733799
{
734-
#category : #view,
800+
#category : #'view-conversion',
735801
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:47'
736802
}
737803
GMTETileMap >> revertViewCorrectedTilePositionMap: aPoint [
@@ -1193,7 +1259,7 @@ GMTETileMap >> view: anObject [
11931259
]
11941260

11951261
{
1196-
#category : #view,
1262+
#category : #'view-conversion',
11971263
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:36'
11981264
}
11991265
GMTETileMap >> viewCorrectedTileExtent: anExtent [
@@ -1203,7 +1269,7 @@ GMTETileMap >> viewCorrectedTileExtent: anExtent [
12031269
]
12041270

12051271
{
1206-
#category : #view,
1272+
#category : #'view-conversion',
12071273
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:36'
12081274
}
12091275
GMTETileMap >> viewCorrectedTilePosition: aPoint [
@@ -1213,22 +1279,20 @@ GMTETileMap >> viewCorrectedTilePosition: aPoint [
12131279
]
12141280

12151281
{
1216-
#category : #view,
1217-
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:36'
1282+
#category : #'view-conversion',
1283+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 17:50'
12181284
}
12191285
GMTETileMap >> viewOriginInPxl [
1220-
12211286
"Note: given that view has same ratio as tileMap"
12221287

12231288
^ self extent * self view origin + self topLeft
12241289
]
12251290

12261291
{
1227-
#category : #view,
1228-
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 19:47'
1292+
#category : #'view-conversion',
1293+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 17:50'
12291294
}
12301295
GMTETileMap >> viewScaleFactor [
1231-
12321296
"Note: given that view has same ratio as tileMap"
12331297

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

12541318

12551319
]
1320+
1321+
{
1322+
#category : #view,
1323+
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 00:33'
1324+
}
1325+
GMTETileMap >> zoomInAt: aPoint [
1326+
1327+
self view shrinkBy: 0.1.
1328+
self centerViewAt: aPoint
1329+
]

source/GM-TE/GMTEView.class.st

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ Class {
44
#category : #'GM-TE-TileMap'
55
}
66

7+
{
8+
#category : #'as yet unclassified',
9+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:17'
10+
}
11+
GMTEView >> enlargeBy: aFloat [
12+
13+
| newExtent |
14+
newExtent := (self extent + (aFloat@aFloat)).
15+
16+
self flag: 'magic number'.
17+
((newExtent x > 1) or: [newExtent y > 1]) ifTrue: [^ nil].
18+
(self isOverlappingOrigin: self origin withExtent: newExtent) ifTrue: [^ nil].
19+
20+
self extent: newExtent
21+
]
22+
723
{
824
#category : #'as yet unclassified',
925
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:20'
@@ -15,22 +31,80 @@ GMTEView >> extent: anExtent [
1531

1632
{
1733
#category : #initialization,
18-
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 19:41'
34+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:15'
1935
}
2036
GMTEView >> initialize [
2137

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

2440
super initialize.
41+
self reset
2542

2643

2744
]
2845

2946
{
3047
#category : #'as yet unclassified',
31-
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:14'
48+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:05'
49+
}
50+
GMTEView >> isOverlappingOrigin: anOrigin withExtent: anExtent [
51+
52+
| corner |
53+
corner := anOrigin + anExtent.
54+
^ (corner x > 1) or: [corner y > 1]
55+
]
56+
57+
{
58+
#category : #'as yet unclassified',
59+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:20'
60+
}
61+
GMTEView >> moveTo: anOrigin [
62+
"Set origin but also respect view not overlapping reference view"
63+
64+
(self isOverlappingOrigin: anOrigin withExtent: self extent) ifTrue: [^ nil].
65+
66+
self origin: anOrigin
67+
]
68+
69+
{
70+
#category : #'as yet unclassified',
71+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:33'
3272
}
3373
GMTEView >> origin: aPoint [
3474

35-
self setOrigin: aPoint corner: self corner
75+
self setOrigin: aPoint corner: (aPoint + self corner)
76+
]
77+
78+
{
79+
#category : #'as yet unclassified',
80+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:33'
81+
}
82+
GMTEView >> reset [
83+
84+
self setOrigin: 0 @ 0 corner: 1 @ 1.
85+
86+
]
87+
88+
{
89+
#category : #'as yet unclassified',
90+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:16'
91+
}
92+
GMTEView >> shrinkBy: aFloat [
93+
94+
| newExtent |
95+
newExtent := (self extent - (aFloat@aFloat)).
96+
97+
self flag: 'magic number'.
98+
((newExtent x <= 0.1) or: [newExtent y <= 0.1]) ifTrue: [^ nil].
99+
100+
self extent: newExtent
101+
]
102+
103+
{
104+
#category : #'as yet unclassified',
105+
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 22:53'
106+
}
107+
GMTEView >> size: aFraction [
108+
109+
self extent: (aFraction @ aFraction)
36110
]

0 commit comments

Comments
 (0)