Skip to content

Commit fab6023

Browse files
author
Ivo Zilkenat
committed
Finalized Zooming/View
1 parent 76507ab commit fab6023

File tree

8 files changed

+86
-88
lines changed

8 files changed

+86
-88
lines changed

source/GM-TE/GMTEEditor.class.st

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,12 +1027,15 @@ GMTEEditor >> exportAsImage [
10271027

10281028
{
10291029
#category : #'menu button functions',
1030-
#'squeak_changestamp' : 'jj 6/23/2024 14:14'
1030+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 19:18'
10311031
}
10321032
GMTEEditor >> exportAsMorph [
10331033
"saves the current tileMap as a .morph file, which allows for reimporting"
10341034

1035-
(self tileMap copy model: nil) saveOnFile.
1035+
((self tileMap veryDeepCopy)
1036+
model: nil;
1037+
resetView
1038+
) saveOnFile.
10361039
self savedSinceModified: true
10371040
]
10381041

source/GM-TE/GMTEEditorTileMap.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Class {
1515
}
1616

1717
{
18-
#category : #'as yet unclassified',
18+
#category : #'instance creation',
1919
#'squeak_changestamp' : 'jj 6/23/2024 13:36'
2020
}
2121
GMTEEditorTileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPadding sizeRatio: aRatio model: aModel [

source/GM-TE/GMTETile.class.st

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Class {
55
}
66

77
{
8-
#category : #'as yet unclassified',
8+
#category : #'instance creation',
99
#'squeak_changestamp' : 'Alex M 7/9/2024 15:03'
1010
}
1111
GMTETile class >> checkerBoardTile [
@@ -23,7 +23,7 @@ GMTETile class >> checkerBoardTile [
2323
]
2424

2525
{
26-
#category : #'as yet unclassified',
26+
#category : #'instance creation',
2727
#'squeak_changestamp' : 'Alex M 7/1/2024 16:21'
2828
}
2929
GMTETile class >> fromSprite: aSprite [
@@ -34,7 +34,7 @@ GMTETile class >> fromSprite: aSprite [
3434
]
3535

3636
{
37-
#category : #'as yet unclassified',
37+
#category : #constants,
3838
#'squeak_changestamp' : 'jj 6/22/2024 16:11'
3939
}
4040
GMTETile class >> placeHolderColor [
@@ -43,7 +43,7 @@ GMTETile class >> placeHolderColor [
4343
]
4444

4545
{
46-
#category : #'as yet unclassified',
46+
#category : #'instance creation',
4747
#'squeak_changestamp' : 'jj 6/22/2024 16:11'
4848
}
4949
GMTETile class >> position: aPoint extent: anExtent [

source/GM-TE/GMTETileMap.class.st

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ GMTETileMap class >> maxLayers [
5555
]
5656

5757
{
58-
#category : #'as yet unclassified',
59-
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:15'
58+
#category : #'instance creation',
59+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:16'
6060
}
6161
GMTETileMap class >> newFromEditableTileMap: aMap [
6262

@@ -78,14 +78,13 @@ GMTETileMap class >> newFromEditableTileMap: aMap [
7878
"Initially draw background tiles"
7979
newMap updateTilesBackground.
8080
newMap resetView.
81-
self flag: 'dragging does not work properly when openedInWorld'.
82-
newMap hasStaticView: false.
81+
newMap hasStaticView: true.
8382

8483
^ newMap
8584
]
8685

8786
{
88-
#category : #'as yet unclassified',
87+
#category : #'instance creation',
8988
#'squeak_changestamp' : 'jj 6/22/2024 16:12'
9089
}
9190
GMTETileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPadding sizeRatio: aRatio [
@@ -216,24 +215,6 @@ GMTETileMap >> borderTileWidth: anObject [
216215
borderTileWidth := anObject
217216
]
218217

219-
{
220-
#category : #view,
221-
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:04'
222-
}
223-
GMTETileMap >> canZoomInBy: aFloat [
224-
225-
^ self view canChangeSizeBy: (aFloat negated)
226-
]
227-
228-
{
229-
#category : #view,
230-
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:04'
231-
}
232-
GMTETileMap >> canZoomOutBy: aFloat [
233-
234-
^ self view canChangeSizeBy: aFloat
235-
]
236-
237218
{
238219
#category : #view,
239220
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 20:46'
@@ -514,6 +495,15 @@ GMTETileMap >> getTileFromLayer: aLayer x: x y: y stack: aStack [
514495

515496

516497

498+
]
499+
500+
{
501+
#category : #'event handling',
502+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:18'
503+
}
504+
GMTETileMap >> handlesMouseDown: anEvent [
505+
506+
^ (self hasStaticView not) and: [anEvent shiftPressed]
517507
]
518508

519509
{
@@ -765,7 +755,7 @@ GMTETileMap >> mapTileWidth: anObject [
765755

766756
{
767757
#category : #'event handling',
768-
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:05'
758+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 19:12'
769759
}
770760
GMTETileMap >> mouseMove: anEvent [
771761

@@ -1430,20 +1420,18 @@ GMTETileMap >> zoomAt: aPoint by: aFloat [
14301420

14311421
{
14321422
#category : #view,
1433-
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:05'
1423+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:07'
14341424
}
14351425
GMTETileMap >> zoomInAt: aPoint [
14361426

1437-
(self canZoomInBy: 0.1) ifFalse: [^ nil].
14381427
self zoomAt: aPoint by: 0.1
14391428
]
14401429

14411430
{
14421431
#category : #view,
1443-
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:05'
1432+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:07'
14441433
}
14451434
GMTETileMap >> zoomOutAt: aPoint [
14461435

1447-
(self canZoomOutBy: 0.1) ifFalse: [^ nil].
14481436
self zoomAt: aPoint by: -0.1
14491437
]

source/GM-TE/GMTETileMatrixLayer.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Class {
1010
}
1111

1212
{
13-
#category : #'as yet unclassified',
13+
#category : #'instance creation',
1414
#'squeak_changestamp' : 'TW 6/23/2024 23:36'
1515
}
1616
GMTETileMatrixLayer class >> width: aWidth height: aHeight layerIndex: anIndex [

source/GM-TE/GMTETileMatrixStack.class.st

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Class {
1212
}
1313

1414
{
15-
#category : #'as yet unclassified',
15+
#category : #'instance creation',
1616
#'squeak_changestamp' : 'jj 6/23/2024 17:02'
1717
}
1818
GMTETileMatrixStack class >> fromWidth: aWidth height: aHeight [
@@ -22,7 +22,7 @@ GMTETileMatrixStack class >> fromWidth: aWidth height: aHeight [
2222
]
2323

2424
{
25-
#category : #'as yet unclassified',
25+
#category : #'instance creation',
2626
#'squeak_changestamp' : 'jj 6/22/2024 16:28'
2727
}
2828
GMTETileMatrixStack class >> fromWidth: aWidth height: aHeight morphicLayerOffset: anOffset [

source/GM-TE/GMTEView.class.st

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,66 @@ Class {
55
}
66

77
{
8-
#category : #'as yet unclassified',
9-
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:06'
8+
#category : #constants,
9+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:22'
1010
}
11-
GMTEView >> canChangeSizeBy: aFloat [
11+
GMTEView class >> minExtentValue [
12+
"Note: Heavily impacts performance, when used as Zoom Frame, since many big ImageMorph's seem to induce a major performance penality"
1213

13-
| newExtent |
14-
newExtent := (self extent + (aFloat@aFloat)).
14+
^ 0.35
15+
]
16+
17+
{
18+
#category : #updating,
19+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:05'
20+
}
21+
GMTEView >> changeSizeBy: aFloat [
1522

16-
((newExtent x <= 0.1) or: [newExtent y <= 0.1]) ifTrue: [^ false].
17-
((newExtent x > 1) or: [newExtent y > 1]) ifTrue: [^ false].
18-
^ true
23+
| newExtent newOrigin |
1924

25+
newExtent := self correctedExtent: (self extent + (aFloat@aFloat)).
26+
newOrigin := self correctedOrigin: self origin withExtent: newExtent.
27+
28+
self origin: newOrigin.
29+
self extent: newExtent
2030
]
2131

2232
{
23-
#category : #'as yet unclassified',
24-
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:01'
33+
#category : #conversion,
34+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:14'
2535
}
26-
GMTEView >> changeSizeBy: aFloat [
36+
GMTEView >> correctedExtent: anExtent [
37+
38+
| newX newY |
39+
40+
newX := (anExtent x min: 1) max: GMTEView minExtentValue.
41+
newY := (anExtent y min: 1) max: GMTEView minExtentValue.
42+
43+
^ newX @ newY.
44+
]
2745

28-
| newExtent |
29-
newExtent := (self extent + (aFloat@aFloat)).
46+
{
47+
#category : #conversion,
48+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:13'
49+
}
50+
GMTEView >> correctedOrigin: anOrigin withExtent: anExtent [
3051

31-
self flag: 'magic number'.
32-
(self canChangeSizeBy: aFloat) ifFalse: [^ nil].
33-
(self isOverlappingOrigin: self origin withExtent: newExtent) ifTrue: [^ nil].
52+
| newX newY |
53+
"Assuming: (0, 0) <= anExtent <= (1, 1)"
54+
newX := anOrigin x.
55+
newY := anOrigin y.
56+
57+
(newX < 0) ifTrue: [newX := 0].
58+
(newX + anExtent x > 1) ifTrue: [newX := 1 - anExtent x].
3459

35-
self extent: newExtent
60+
(newY < 0) ifTrue: [newY := 0].
61+
(newY + anExtent y > 1) ifTrue: [newY := 1 - anExtent y].
62+
63+
^ newX @ newY
3664
]
3765

3866
{
39-
#category : #'as yet unclassified',
67+
#category : #accessing,
4068
#'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 20:20'
4169
}
4270
GMTEView >> extent: anExtent [
@@ -59,49 +87,28 @@ GMTEView >> initialize [
5987
]
6088

6189
{
62-
#category : #'as yet unclassified',
63-
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 22:43'
64-
}
65-
GMTEView >> isOverlappingOrigin: anOrigin withExtent: anExtent [
66-
67-
| corner |
68-
corner := anOrigin + anExtent.
69-
70-
self flag: 'tmp for testing'.
71-
^ false.
72-
73-
"^ (((corner x > 1) or: [corner y > 1]) or: [anOrigin x < 0]) or: [anOrigin y < 0]"
74-
]
75-
76-
{
77-
#category : #'as yet unclassified',
78-
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:41'
90+
#category : #updating,
91+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 20:10'
7992
}
8093
GMTEView >> moveBy: aPoint [
81-
"Set origin but also respect view not overlapping reference view"
82-
83-
| newOrigin |
84-
newOrigin := self origin + aPoint.
94+
"Move origin but also respect view not overlapping reference view"
8595

86-
(self isOverlappingOrigin: newOrigin withExtent: self extent) ifTrue: [^ nil].
87-
88-
self origin: newOrigin
96+
self origin: (self correctedOrigin: (self origin + aPoint) withExtent: self extent)
8997
]
9098

9199
{
92-
#category : #'as yet unclassified',
93-
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:20'
100+
#category : #updating,
101+
#'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 19:44'
94102
}
95103
GMTEView >> moveTo: anOrigin [
96104
"Set origin but also respect view not overlapping reference view"
97105

98-
(self isOverlappingOrigin: anOrigin withExtent: self extent) ifTrue: [^ nil].
99-
100-
self origin: anOrigin
106+
self origin: (self correctedOrigin: anOrigin withExtent: self extent)
107+
101108
]
102109

103110
{
104-
#category : #'as yet unclassified',
111+
#category : #accessing,
105112
#'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 20:35'
106113
}
107114
GMTEView >> origin: aPoint [
@@ -110,7 +117,7 @@ GMTEView >> origin: aPoint [
110117
]
111118

112119
{
113-
#category : #'as yet unclassified',
120+
#category : #updating,
114121
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:33'
115122
}
116123
GMTEView >> reset [
@@ -120,7 +127,7 @@ GMTEView >> reset [
120127
]
121128

122129
{
123-
#category : #'as yet unclassified',
130+
#category : #accessing,
124131
#'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 22:53'
125132
}
126133
GMTEView >> size: aFraction [

testingResources/squeak2.gif

0 Bytes
Loading

0 commit comments

Comments
 (0)