Skip to content

Commit e6eed57

Browse files
author
Aleksander Morgensterns
committed
Merge origin/tmm-dev into tmm-dev
2 parents d46a071 + 90e960f commit e6eed57

5 files changed

+154
-67
lines changed

source/GM-TE/GMTEEditor.class.st

Lines changed: 101 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ GMTEEditor class >> getVisibilityIndicator: aBoolean [
7575
ifFalse: [^ ' (h)']
7676
]
7777

78+
{
79+
#category : #'as yet unclassified',
80+
#'squeak_changestamp' : 'tw 7/12/2024 18:33'
81+
}
82+
GMTEEditor class >> hLayoutFrame: intI ofN: intN [
83+
84+
^ self hLayoutFrame: intI ofN: intN vSymmetric: 0
85+
]
86+
7887
{
7988
#category : #'as yet unclassified',
8089
#'squeak_changestamp' : 'tw 7/11/2024 17:03'
@@ -253,6 +262,35 @@ GMTEEditor class >> toolBarVSpace [
253262
^ 0.1
254263
]
255264

265+
{
266+
#category : #'as yet unclassified',
267+
#'squeak_changestamp' : 'tw 7/12/2024 18:33'
268+
}
269+
GMTEEditor class >> vLayoutFrame: intI ofN: intN [
270+
271+
^ self vLayoutFrame: intI ofN: intN hSymmetric: 0
272+
]
273+
274+
{
275+
#category : #'as yet unclassified',
276+
#'squeak_changestamp' : 'tw 7/12/2024 18:26'
277+
}
278+
GMTEEditor class >> vLayoutFrame: intI ofN: intN hLeft: aFloat right: anotherFloat [
279+
280+
"useful for building buttons, maybe move this to instance? TODO FLAG"
281+
282+
^ LayoutFrame fractions: ((aFloat @ (intI - 1 / intN)) corner: (1 - anotherFloat @ (intI / intN)))
283+
]
284+
285+
{
286+
#category : #'as yet unclassified',
287+
#'squeak_changestamp' : 'tw 7/12/2024 18:26'
288+
}
289+
GMTEEditor class >> vLayoutFrame: intI ofN: intN hSymmetric: aFloat [
290+
291+
^ self vLayoutFrame: intI ofN: intN hLeft: aFloat right: aFloat
292+
]
293+
256294
{
257295
#category : #'command processing',
258296
#'squeak_changestamp' : 'Valentin Teutschbein 7/6/2024 11:56'
@@ -327,11 +365,11 @@ GMTEEditor >> associatedMorph [
327365

328366
{
329367
#category : #accessing,
330-
#'squeak_changestamp' : 'TW 6/25/2024 15:55'
368+
#'squeak_changestamp' : 'mcjj 7/12/2024 19:38'
331369
}
332370
GMTEEditor >> associatedMorph: anObject [
333371

334-
associatedMorph := anObject.
372+
associatedMorph := anObject
335373
]
336374

337375
{
@@ -403,22 +441,22 @@ GMTEEditor >> brushButtons [
403441

404442
{
405443
#category : #accessing,
406-
#'squeak_changestamp' : 'TW 7/9/2024 18:19'
444+
#'squeak_changestamp' : 'mcjj 7/12/2024 19:38'
407445
}
408446
GMTEEditor >> brushButtons: anObject [
409447

410-
brushButtons := anObject.
448+
brushButtons := anObject
411449
]
412450

413451
{
414452
#category : #building,
415-
#'squeak_changestamp' : 'mcjj 7/11/2024 16:15'
453+
#'squeak_changestamp' : 'JS 7/12/2024 18:20'
416454
}
417455
GMTEEditor >> buildWith: builder [
418456
"builds the editor with ToolBuilder"
419457
"called it builder instead of aBuilder since every other implementation does that"
420458

421-
| newMorph selectedTile panel |
459+
| newMorph panel |
422460
"TODO: Build process contains a lot of magic numbers regarding relative/absolute positioning"
423461
newMorph := builder build: (builder pluggableWindowSpec new
424462
model: self;
@@ -447,15 +485,7 @@ GMTEEditor >> buildWith: builder [
447485
panel := GMTETileContainer withParent: self tileStore.
448486
self tileStore morph: panel.
449487

450-
selectedTile := GMTETileSelector new
451-
visible: false;
452-
model:self;
453-
yourself.
454-
455-
"TODO: Work in progress."
456-
self trayViewer morph: GMTETileTray new.
457-
self trayViewer morph
458-
addMorph: selectedTile.
488+
self placeSelectedTileIntoTileTray.
459489

460490
self tileViewer
461491
borderWidth: 2;
@@ -574,30 +604,37 @@ GMTEEditor >> createAttributeSpecWithBuilder: aBuilder descriptor: aString gette
574604

575605
{
576606
#category : #building,
577-
#'squeak_changestamp' : 'TW 7/9/2024 17:28'
607+
#'squeak_changestamp' : 'tw 7/12/2024 18:57'
578608
}
579609
GMTEEditor >> createAttributeSpecWithBuilder: aBuilder descriptor: aString getter: aSelector setter: anotherSelector model: aModel frame: aFrame [
580610
"a helper function to create attribute specs"
581611

582-
^ self withMorphOf: ((aBuilder pluggablePanelSpec new)
612+
| minTextWidth minInputWidth |
613+
minTextWidth := (TextStyle defaultFont approxWidthOfText: aString asText).
614+
minInputWidth := (TextStyle defaultFont approxWidthOfText: '1234' asText).
615+
616+
^ (aBuilder pluggablePanelSpec new)
617+
name: 'attributeContainer';
583618
frame: aFrame;
584619
layout: #proportional;
620+
minimumWidth: minTextWidth + minInputWidth;
585621
children: {
586622
(aBuilder pluggableStaticTextSpec new)
587623
model: aModel;
588-
frame: (LayoutFrame fractions: (0 @ 0 corner: (2 / 3) @ 1));
589-
text: aString.
624+
frame: (LayoutFrame fractions: (0 @ 0 corner: 2 / 3 @ 1));
625+
text: aString;
626+
minimumWidth: minTextWidth.
627+
590628

591629
(aBuilder pluggableInputFieldSpec new)
592630
model: aModel;
593631
indicateUnacceptedChanges: false;
594-
frame: (LayoutFrame fractions: (((2 / 3) + 0.1) @ 0 corner: 1 @ 1));
595-
minimumExtent: 45@30;
632+
frame: (LayoutFrame fractions: (2 / 3 @ 0 corner: 1 @ 1));
596633
getText: aSelector;
597-
setText: anotherSelector
634+
setText: anotherSelector;
635+
minimumWidth: minInputWidth
598636
};
599-
yourself) do: [:morph |
600-
morph layoutPolicy: TableLayout new]
637+
yourself
601638
]
602639

603640
{
@@ -647,27 +684,23 @@ GMTEEditor >> createCommandBarSpecWithBuilder: aBuilder [
647684

648685
{
649686
#category : #building,
650-
#'squeak_changestamp' : 'tw 7/11/2024 17:48'
687+
#'squeak_changestamp' : 'tw 7/12/2024 19:01'
651688
}
652689
GMTEEditor >> createInspectorSpecWithBuilder: aBuilder [
653690
"creates the spec for the inspector tab"
654691

655-
^ aBuilder pluggableScrollPaneSpec new
692+
^ aBuilder pluggablePanelSpec new
656693
frame: (LayoutFrame fractions: (0.8 @ 0 corner: 1 @ 0.25)
657694
offsets: (0 @ 30 corner: 0 @ 30));
658-
padding: (Rectangle left: 3 right: 0 top: 0 bottom: 0);
659-
hScrollBarPolicy: #never;
660-
layout: #vertical;
661695
name: 'inspector';
662696
children: {
663-
self createAttributeSpecWithBuilder: aBuilder descriptor: 'Padding:' getter: #getPaddingAsString setter: #setPadding: model: self.
697+
self createAttributeSpecWithBuilder: aBuilder descriptor: 'Padding:' getter: #getPaddingAsString setter: #setPadding: model: self frame: (GMTEEditor vLayoutFrame: 1 ofN: 3).
664698

665-
self createAttributeSpecWithBuilder: aBuilder descriptor: 'Grid Width:' getter: #getGridWidthAsString setter: #setGridWidth: model: self.
666-
667-
self createAttributeSpecWithBuilder: aBuilder descriptor: 'Grid Height:' getter: #getGridHeightAsString setter: #setGridHeight: model: self
699+
self createAttributeSpecWithBuilder: aBuilder descriptor: 'Grid Width:' getter: #getGridWidthAsString setter: #setGridWidth: model: self frame: (GMTEEditor vLayoutFrame: 2 ofN: 3).
700+
701+
self createAttributeSpecWithBuilder: aBuilder descriptor: 'Grid Height:' getter: #getGridHeightAsString setter: #setGridHeight: model: self frame: (GMTEEditor vLayoutFrame: 3 ofN: 3)
668702
};
669-
verticalResizing: #shrinkWrap;
670-
horizontalResizing: #shrinkWrap;
703+
minimumWidth: (self getMaximalLengthOfStrings: (OrderedCollection newFrom: {'Padding:' . 'Grid Width:' . 'Grid Height:'}));
671704
yourself
672705
]
673706

@@ -1071,11 +1104,12 @@ GMTEEditor >> exportMenu [
10711104

10721105
{
10731106
#category : #'input handling',
1074-
#'squeak_changestamp' : 'mcjj 7/12/2024 17:12'
1107+
#'squeak_changestamp' : 'mcjj 7/12/2024 19:34'
10751108
}
10761109
GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [
1077-
| key |
1110+
"handles keyboard shortcuts"
10781111

1112+
| key |
10791113
aKeyboardEvent isKeystroke
10801114
ifFalse: [^ aKeyboardEvent].
10811115

@@ -1088,7 +1122,6 @@ GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [
10881122
[$o] -> [self importFromTileset].
10891123
[$g] -> [self toggleGrid].
10901124
[$h] -> [self toggleBackgroundTiles].
1091-
[$r] -> [self rotateSelectedTile].
10921125

10931126
[$a] -> [self addLayer].
10941127
[$n] -> [self renameLayer].
@@ -1099,6 +1132,7 @@ GMTEEditor >> filterEvent: aKeyboardEvent for: anObject [
10991132

11001133
[$z] -> [self undo].
11011134
[$y] -> [self redo].
1135+
[$r] -> [self rotateSelectedTile].
11021136
[$1] -> [self selectRadiusBrush].
11031137
[$2] -> [self selectLineBrush].
11041138
[$3] -> [self selectFillBrush].
@@ -1195,6 +1229,15 @@ GMTEEditor >> getLayerList [
11951229
^ self tileMap tileMatrixStack collectLayers: [:aLayer | aLayer displayName, (GMTEEditor getVisibilityIndicator: aLayer visible)]
11961230
]
11971231

1232+
{
1233+
#category : #helper,
1234+
#'squeak_changestamp' : 'tw 7/12/2024 19:01'
1235+
}
1236+
GMTEEditor >> getMaximalLengthOfStrings: anOrderedCollection [
1237+
1238+
^ (anOrderedCollection collect: [:aString | TextStyle defaultFont approxWidthOfText: aString asText]) max
1239+
]
1240+
11981241
{
11991242
#category : #accessing,
12001243
#'squeak_changestamp' : 'jj 6/22/2024 20:54'
@@ -1669,6 +1712,24 @@ GMTEEditor >> parseSize: aText [
16691712
[^ aText asNumber] on: NumberParserError do: [^ nil]
16701713
]
16711714

1715+
{
1716+
#category : #building,
1717+
#'squeak_changestamp' : 'JS 7/12/2024 18:20'
1718+
}
1719+
GMTEEditor >> placeSelectedTileIntoTileTray [
1720+
1721+
| selectedTile |
1722+
selectedTile := GMTETileSelector new
1723+
visible: false;
1724+
name: 'selectedTile';
1725+
model: self;
1726+
yourself.
1727+
1728+
self trayViewer morph
1729+
color: Color transparent;
1730+
addMorph: selectedTile
1731+
]
1732+
16721733
{
16731734
#category : #accessing,
16741735
#'squeak_changestamp' : 'jj 6/22/2024 21:27'
@@ -1929,7 +1990,7 @@ GMTEEditor >> selectRectangleBrush [
19291990

19301991
{
19311992
#category : #accessing,
1932-
#'squeak_changestamp' : 'Alex M 7/9/2024 15:25'
1993+
#'squeak_changestamp' : 'JS 7/12/2024 18:12'
19331994
}
19341995
GMTEEditor >> selectTile: anObject [
19351996
"selects a tile from the tile store"
@@ -1940,7 +2001,7 @@ GMTEEditor >> selectTile: anObject [
19402001
ifFalse: [
19412002
self selectedTile: anObject fullResolutionSprite.
19422003
self tileMap tileSelectionSet highlightImage: anObject fullResolutionSprite.
1943-
self trayViewer morph submorphs first
2004+
(self trayViewer morph submorphNamed: 'selectedTile')
19442005
visible: true;
19452006
updateSprite: anObject fullResolutionSprite;
19462007
extent: 75@75]

source/GM-TE/GMTEEditorTileMap.class.st

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ GMTEEditorTileMap >> currentTileChanges: aTileDictionary [
5555

5656
{
5757
#category : #updating,
58-
#'squeak_changestamp' : 'Alex M 7/12/2024 17:16'
58+
#'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 18:28'
5959
}
6060
GMTEEditorTileMap >> deleteTiles: anIndexSet inLayer: aLayer [
6161
"delete tiles from editable matrix stack at given indices"
@@ -220,13 +220,13 @@ GMTEEditorTileMap >> mouseUp: anEvent [
220220

221221
{
222222
#category : #updating,
223-
#'squeak_changestamp' : 'Alex M 7/12/2024 17:15'
223+
#'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 18:27'
224224
}
225-
GMTEEditorTileMap >> placeTiles: aCoordinateCollection inLayer: aLayer [
225+
GMTEEditorTileMap >> placeTiles: anIndexSet inLayer: aLayer [
226226
"add currently selected tile (model) to editable matrix stack at given indices"
227-
227+
228228
| tile |
229-
aCoordinateCollection do: [:c |
229+
anIndexSet do: [:c |
230230
self savePreviousImageFromIndex: c inLayer: aLayer.
231231
((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [
232232
tile := self tileMatrixStack layer: aLayer at: c y at: c x.

source/GM-TE/GMTEImageButton.class.st

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,16 @@ GMTEImageButton >> target: anObject [
364364

365365
{
366366
#category : #'visual properties',
367-
#'squeak_changestamp' : 'TW 7/9/2024 19:11'
367+
#'squeak_changestamp' : 'tw 7/12/2024 18:39'
368368
}
369369
GMTEImageButton >> updateVisualState: anEvent [
370370

371371

372+
self enabled
373+
ifFalse: [
374+
self setImageMode: 'disabled'.
375+
^ nil].
376+
372377
self buttonGroup
373378
ifNil: [
374379
(self containsPoint: Sensor cursorPoint)

source/GM-TE/GMTETileMap.class.st

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,23 @@ GMTETileMap >> correctedTilePositionMap: aPoint [
296296
^ self correctedTilePosition: aPoint startingOffset: self tileCornerOffsetMap
297297
]
298298

299+
{
300+
#category : #updating,
301+
#'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 18:32'
302+
}
303+
GMTETileMap >> deleteTiles: anIndexSet inLayer: aLayer [
304+
"delete tiles from editable matrix stack at given indices"
305+
306+
| tile |
307+
anIndexSet do: [:c |
308+
((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [
309+
tile := self tileMatrixStack layer: aLayer at: c y at: c x.
310+
tile ifNotNil: [
311+
tile abandon.
312+
self tileMatrixStack layer: aLayer at: c y at: c x put: nil.
313+
self saveNewImageFromIndex: c inLayer: aLayer]]]
314+
]
315+
299316
{
300317
#category : #checking,
301318
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:08'
@@ -811,6 +828,31 @@ GMTETileMap >> moveViewBy: aPoint [
811828
self updateMap
812829
]
813830

831+
{
832+
#category : #updating,
833+
#'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 19:22'
834+
}
835+
GMTETileMap >> placeTiles: anIndexSet inLayer: aLayer ofClass: aTileClass withImage: anImage [
836+
837+
| tile |
838+
self assert: (aTileClass inheritsFrom: GMTETile) description: 'Expected GMTETile or subclass'.
839+
840+
anIndexSet do: [:c |
841+
((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [
842+
tile := self tileMatrixStack layer: aLayer at: c y at: c x.
843+
tile ifNil: [tile := self generateTileAtlayer: aLayer x: c x y: c y stack: tileMatrixStack tileType: aTileClass].
844+
tile updateSprite: anImage]]
845+
]
846+
847+
{
848+
#category : #updating,
849+
#'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 18:58'
850+
}
851+
GMTETileMap >> placeTiles: anIndexSet inLayer: aLayer withImage: anImage [
852+
853+
self placeTiles: anIndexSet inLayer: aLayer ofClass: GMTETile withImage: anImage
854+
]
855+
814856
{
815857
#category : #updating,
816858
#'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:27'

0 commit comments

Comments
 (0)