diff --git a/source/GM-TE/GMTEBrush.class.st b/source/GM-TE/GMTEBrush.class.st index 8f6a8d69..616c22cb 100644 --- a/source/GM-TE/GMTEBrush.class.st +++ b/source/GM-TE/GMTEBrush.class.st @@ -78,9 +78,9 @@ GMTEBrush >> currentMatrixIndex: anIndex [ { #category : #execute, - #'squeak_changestamp' : 'Valentin Teutschbein 7/11/2024 17:10' + #'squeak_changestamp' : 'JS 7/12/2024 16:50' } -GMTEBrush >> executeWithMatrixIndex: anIndex andLayer: aLayer [ +GMTEBrush >> executeWithIndex: anIndex andLayer: aLayer [ anIndex ifNil: [^ nil]. self currentMatrixIndex: anIndex. diff --git a/source/GM-TE/GMTEEditTilesCommand.class.st b/source/GM-TE/GMTEEditTilesCommand.class.st index 1972bc86..3d5d2879 100644 --- a/source/GM-TE/GMTEEditTilesCommand.class.st +++ b/source/GM-TE/GMTEEditTilesCommand.class.st @@ -2,6 +2,7 @@ Class { #name : #GMTEEditTilesCommand, #superclass : #GMTECommand, #instVars : [ + 'editor', 'tileMap', 'previousSprites', 'currentSprites' @@ -47,6 +48,22 @@ GMTEEditTilesCommand >> do [ self placeTilesFromList: self currentSprites ] +{ + #category : #accessing, + #'squeak_changestamp' : 'Alex M 7/12/2024 17:12' +} +GMTEEditTilesCommand >> editor [ + ^ editor +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'Alex M 7/12/2024 17:12' +} +GMTEEditTilesCommand >> editor: anObject [ + editor := anObject +] + { #category : #initialization, #'squeak_changestamp' : 'Alex M 6/28/2024 02:45' diff --git a/source/GM-TE/GMTEEditorTileMap.class.st b/source/GM-TE/GMTEEditorTileMap.class.st index 7a619573..33e3a0a6 100644 --- a/source/GM-TE/GMTEEditorTileMap.class.st +++ b/source/GM-TE/GMTEEditorTileMap.class.st @@ -1,3 +1,6 @@ +" +A GMTEEditorTileMap is a Tilemap that can only be found in the editor or as an exported .morph file. It provides the additional methods for i/o compared to the regular tilemap. +" Class { #name : #GMTEEditorTileMap, #superclass : #GMTETileMap, @@ -7,7 +10,8 @@ Class { 'previousTileStates', 'currentTileChanges' ], - #category : #'GM-TE-TileMap' + #category : #'GM-TE-TileMap', + #'squeak_changestamp' : 'JS 7/12/2024 17:04' } { @@ -24,11 +28,11 @@ GMTEEditorTileMap class >> tileWidth: aWidth tileHeight: aHeight padding: aPaddi { #category : #accessing, - #'squeak_changestamp' : 'JS 7/12/2024 14:48' + #'squeak_changestamp' : 'JS 7/12/2024 16:55' } GMTEEditorTileMap >> brush [ - ^ model brush + ^ self model brush ] { @@ -51,7 +55,7 @@ GMTEEditorTileMap >> currentTileChanges: aTileDictionary [ { #category : #updating, - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:21' + #'squeak_changestamp' : 'Alex M 7/12/2024 17:16' } GMTEEditorTileMap >> deleteTiles: anIndexSet inLayer: aLayer [ "delete tiles from editable matrix stack at given indices" @@ -64,7 +68,8 @@ GMTEEditorTileMap >> deleteTiles: anIndexSet inLayer: aLayer [ self savePreviousImageFromIndex: c inLayer: aLayer. tile abandon. self tileMatrixStack layer: aLayer at: c y at: c x put: nil. - self saveNewImageFromPosition: tile position inLayer: aLayer]]]. + self saveNewImageFromIndex: c inLayer: aLayer. + self model savedSinceModified: false]]] ] { @@ -95,7 +100,7 @@ GMTEEditorTileMap >> handlesMouseOver: anEvent [ ] { - #category : #'event handling', + #category : #updating, #'squeak_changestamp' : 'JS 7/12/2024 15:15' } GMTEEditorTileMap >> highlightTilesFromIndices: anIndexSet [ @@ -112,7 +117,7 @@ GMTEEditorTileMap >> highlightTilesFromIndices: anIndexSet [ { #category : #initialization, - #'squeak_changestamp' : 'Alex M 6/28/2024 20:24' + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:04' } GMTEEditorTileMap >> initialize [ @@ -120,7 +125,8 @@ GMTEEditorTileMap >> initialize [ self tileSelectionSet: (GMTETileSelectionSet new); previousTileStates: Dictionary new; - currentTileChanges: Dictionary new + currentTileChanges: Dictionary new; + hasStaticView: false ] { @@ -134,18 +140,19 @@ GMTEEditorTileMap >> model [ { #category : #accessing, - #'squeak_changestamp' : 'TW 6/22/2024 01:25' + #'squeak_changestamp' : 'JS 7/12/2024 16:25' } -GMTEEditorTileMap >> model: anObject [ +GMTEEditorTileMap >> model: aModel [ - model := anObject + model := aModel ] { #category : #'event handling', - #'squeak_changestamp' : 'JS 7/12/2024 15:19' + #'squeak_changestamp' : 'JS 7/12/2024 16:50' } GMTEEditorTileMap >> mouseDown: anEvent [ + "prepare the brush for next operation on self" | selectedIndex | self model singleLayerSelected ifFalse: [^ nil]. @@ -153,42 +160,48 @@ GMTEEditorTileMap >> mouseDown: anEvent [ selectedIndex := self tileIndexFromPosition: anEvent position. self brush firstMatrixIndex: selectedIndex. - self brush executeWithMatrixIndex: selectedIndex andLayer: (self tileMatrixStack layer: self selectedLayers anyOne). + self brush executeWithIndex: selectedIndex andLayer: (self tileMatrixStack layer: self selectedLayers anyOne). anEvent yellowButtonPressed ifTrue: [self tileSelectionSet highlightImage: nil] ] { #category : #'event handling', - #'squeak_changestamp' : 'JS 7/12/2024 15:18' + #'squeak_changestamp' : 'JS 7/12/2024 16:27' } GMTEEditorTileMap >> mouseLeave: anEvent [ - + self tileSelectionSet clearAllHighlightings ] { #category : #'event handling', - #'squeak_changestamp' : 'JS 7/12/2024 15:17' + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:20' } GMTEEditorTileMap >> mouseMove: anEvent [ - "Implements highlighting of tiles when hovering" + "implements highlighting of tiles when hovering" + + | activeLayer selectedIndices currentIndex | + super mouseMove: anEvent. + anEvent shiftPressed ifTrue: [^ nil]. - | activeLayer selectedIndices | self model singleLayerSelected ifFalse: [^ nil]. activeLayer := self tileMatrixStack layer: self model selectedLayers anyOne. - selectedIndices := self model brush executeWithMatrixIndex: (self tileIndexFromPosition: anEvent position) andLayer: activeLayer. + currentIndex := self tileIndexFromPosition: anEvent position. - (anEvent redButtonPressed or: [anEvent yellowButtonPressed]) ifFalse: [self model brush resetOutputSet]. + selectedIndices := self brush executeWithIndex: currentIndex andLayer: activeLayer. + + (anEvent redButtonPressed or: [anEvent yellowButtonPressed]) ifFalse: [self brush resetOutputSet]. self highlightTilesFromIndices: selectedIndices ] { #category : #'event handling', - #'squeak_changestamp' : 'JS 7/12/2024 15:23' + #'squeak_changestamp' : 'JS 7/12/2024 16:28' } GMTEEditorTileMap >> mouseUp: anEvent [ + "apply brush operation on tilemap" | selectedIndices | self brush firstMatrixIndex: nil. @@ -196,30 +209,31 @@ GMTEEditorTileMap >> mouseUp: anEvent [ selectedIndices := self brush outputSet asCollection. self updateTiles: selectedIndices inLayer: self selectedLayers anyOne FromEvent: anEvent. - self model brush resetOutputSet. + self brush resetOutputSet. (self previousTileStates isEmpty) ifFalse: [self saveTileEditChanges]. - self tileSelectionSet clearAllHighlightings; - highlightImage: (self model selectedTile) + self tileSelectionSet + clearAllHighlightings; + highlightImage: (self model selectedTile) ] { #category : #updating, - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:21' + #'squeak_changestamp' : 'Alex M 7/12/2024 17:15' } GMTEEditorTileMap >> placeTiles: aCoordinateCollection inLayer: aLayer [ - "Add currently selected tile (model) to editable matrix stack at given indices" + "add currently selected tile (model) to editable matrix stack at given indices" | tile | aCoordinateCollection do: [:c | self savePreviousImageFromIndex: c inLayer: aLayer. ((self tileMatrixStack layer: aLayer) inBounds: c) ifTrue: [ tile := self tileMatrixStack layer: aLayer at: c y at: c x. - tile ifNil: [ tile := self generateTileAtlayer: aLayer x: c x y: c y stack: tileMatrixStack tileType: GMTETile]. - self updateTileSprite: tile. - self saveNewImageFromPosition: tile position inLayer: aLayer]]. - + tile ifNil: [tile := self generateTileAtlayer: aLayer x: c x y: c y stack: tileMatrixStack tileType: GMTETile]. + self model selectedTile ifNotNil: [tile updateSprite: self model selectedTile]. + self saveNewImageFromIndex: c inLayer: aLayer. + self model savedSinceModified: false]] ] { @@ -252,12 +266,12 @@ GMTEEditorTileMap >> rescaleMap [ ] { - #category : #TODO, - #'squeak_changestamp' : 'Alex M 7/3/2024 23:50' + #category : #updating, + #'squeak_changestamp' : 'JS 7/12/2024 16:31' } GMTEEditorTileMap >> resetLayers: aSet [ - | layer | + | layer | aSet do: [:layerIndex | layer := self tileMatrixStack layer: layerIndex. layer withIndicesDo: [:tile :y :x | @@ -280,68 +294,52 @@ GMTEEditorTileMap >> resetTileEditChanges [ { #category : #'command processing', - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' + #'squeak_changestamp' : 'JS 7/12/2024 16:34' } -GMTEEditorTileMap >> saveNewImageFromIndex: aCoordinate inLayer: aLayer [ - | tile | - - tile := self tileMatrixStack layer: aLayer at: aCoordinate y at: aCoordinate x. +GMTEEditorTileMap >> saveNewImageFromIndex: anIndex inLayer: aLayer [ + | tile | + tile := self tileMatrixStack layer: aLayer at: anIndex y at: anIndex x. + tile - ifNil: [self currentTileChanges at: {aCoordinate x. aCoordinate y. aLayer} put: nil] - ifNotNil: [self currentTileChanges at: {aCoordinate x. aCoordinate y. aLayer} put: tile fullResolutionSprite] + ifNil: [self currentTileChanges at: {anIndex x. anIndex y. aLayer} put: nil] + ifNotNil: [self currentTileChanges at: {anIndex x. anIndex y. aLayer} put: tile fullResolutionSprite] ] { #category : #'command processing', - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' + #'squeak_changestamp' : 'JS 7/12/2024 16:40' } -GMTEEditorTileMap >> saveNewImageFromPosition: aPosition inLayer: aLayer [ - - self saveNewImageFromIndex: (self tileIndexFromPosition: aPosition) inLayer: aLayer -] +GMTEEditorTileMap >> savePreviousImageFromIndex: anIndex inLayer: aLayer [ -{ - #category : #'command processing', - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' -} -GMTEEditorTileMap >> savePreviousImageFromIndex: aCoordinate inLayer: aLayer [ - | tile | - - tile := self tileMatrixStack layer: aLayer at: aCoordinate y at: aCoordinate x. + | tile | + tile := self tileMatrixStack layer: aLayer at: anIndex y at: anIndex x. tile - ifNil: [self previousTileStates at: {aCoordinate x. aCoordinate y. aLayer} ifAbsentPut: nil] - ifNotNil: [self previousTileStates at: {aCoordinate x. aCoordinate y. aLayer} ifAbsentPut: tile fullResolutionSprite] -] - -{ - #category : #'command processing', - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:20' -} -GMTEEditorTileMap >> savePreviousImageFromPosition: aPosition inLayer: aLayer [ - - self savePreviousImageFromIndex: (self tileIndexFromPosition: aPosition) inLayer: aLayer + ifNil: [self previousTileStates at: {anIndex x. anIndex y. aLayer} ifAbsentPut: nil] + ifNotNil: [self previousTileStates at: {anIndex x. anIndex y. aLayer} ifAbsentPut: tile fullResolutionSprite] ] { #category : #'command processing', - #'squeak_changestamp' : 'JS 7/11/2024 14:07' + #'squeak_changestamp' : 'JS 7/12/2024 16:43' } GMTEEditorTileMap >> saveTileEditChanges [ - - self - model addCommand: (GMTEEditTilesCommand previousTiles: self previousTileStates currentTiles: self currentTileChanges tilemap: self). - self resetTileEditChanges. + + | command | + command := GMTEEditTilesCommand previousTiles: self previousTileStates currentTiles: self currentTileChanges tilemap: self. + + self model addCommand: command. + self resetTileEditChanges ] { #category : #accessing, - #'squeak_changestamp' : 'JS 7/12/2024 14:49' + #'squeak_changestamp' : 'JS 7/12/2024 16:55' } GMTEEditorTileMap >> selectedLayers [ - ^ model selectedLayers + ^ self model selectedLayers ] { @@ -364,24 +362,16 @@ GMTEEditorTileMap >> tileSelectionSet: aSet [ { #category : #updating, - #'squeak_changestamp' : 'Alex M 6/25/2024 18:08' -} -GMTEEditorTileMap >> updateTileSprite: aTile [ - "Helper function to apply sprite from tile selection to aTile" - - self model selectedTile ifNotNil: [aTile updateSprite: self model selectedTile] -] - -{ - #category : #updating, - #'squeak_changestamp' : 'Valentin Teutschbein 7/12/2024 14:13' + #'squeak_changestamp' : 'Alex M 7/12/2024 17:14' } GMTEEditorTileMap >> updateTiles: anIndexSet inLayer: aLayer FromEvent: anEvent [ + | validLeftClick validRightClick | (self tileIndexFromPosition: anEvent position) ifNil: [^ nil]. - (anEvent redButtonChanged and: [self model selectedTile notNil]) ifTrue: [self placeTiles: anIndexSet inLayer: aLayer]. - (anEvent yellowButtonChanged) ifTrue: [self deleteTiles: anIndexSet inLayer: aLayer]. + validLeftClick := anEvent redButtonChanged and: [self model selectedTile notNil]. + validRightClick := anEvent yellowButtonChanged. - self model savedSinceModified: false + validLeftClick ifTrue: [self placeTiles: anIndexSet inLayer: aLayer]. + validRightClick ifTrue: [self deleteTiles: anIndexSet inLayer: aLayer]. ] diff --git a/source/GM-TE/GMTETileMap.class.st b/source/GM-TE/GMTETileMap.class.st index 11ad8354..53e504d6 100644 --- a/source/GM-TE/GMTETileMap.class.st +++ b/source/GM-TE/GMTETileMap.class.st @@ -27,7 +27,8 @@ Class { 'tileMatrixStackBackground', 'forceMapSizeRatio', 'backgroundTiles', - 'view' + 'view', + 'hasStaticView' ], #category : #'GM-TE-TileMap' } @@ -55,7 +56,7 @@ GMTETileMap class >> maxLayers [ { #category : #'as yet unclassified', - #'squeak_changestamp' : 'Ivo Zilkenat 7/2/2024 18:05' + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:15' } GMTETileMap class >> newFromEditableTileMap: aMap [ @@ -76,6 +77,10 @@ GMTETileMap class >> newFromEditableTileMap: aMap [ "Initially draw background tiles" newMap updateTilesBackground. + newMap resetView. + self flag: 'dragging does not work properly when openedInWorld'. + newMap hasStaticView: false. + ^ newMap ] @@ -213,15 +218,54 @@ GMTETileMap >> borderTileWidth: anObject [ { #category : #view, - #'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 00:08' + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 15:59' +} +GMTETileMap >> canZoomIn [ + + ^ false +] + +{ + #category : #view, + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:04' +} +GMTETileMap >> canZoomInBy: aFloat [ + + ^ self view canChangeSizeBy: (aFloat negated) +] + +{ + #category : #view, + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:04' +} +GMTETileMap >> canZoomOutBy: aFloat [ + + ^ self view canChangeSizeBy: aFloat +] + +{ + #category : #view, + #'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 20:46' } GMTETileMap >> centerViewAt: aPoint [ + "Note: aPoint is relative to current view" "Note: center must induce legal view (non-overlapping)" self view moveTo: (self inViewPointToViewCenter: aPoint). self updateMap ] +{ + #category : #view, + #'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 22:31' +} +GMTETileMap >> centerViewAtAbs: aPoint [ + "Note: center must induce legal view (non-overlapping)" + + self view moveTo: (self absPointToViewCenter: aPoint). + self updateMap +] + { #category : #conversion, #'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:09' @@ -479,6 +523,42 @@ GMTETileMap >> getTileFromLayer: aLayer x: x y: y stack: aStack [ +] + +{ + #category : #'event handling', + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:16' +} +GMTETileMap >> handlesMouseMove: anEvent [ + + ^ true +] + +{ + #category : #'event handling', + #'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 21:12' +} +GMTETileMap >> handlesMouseWheel: anEvent [ + + ^ true +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:04' +} +GMTETileMap >> hasStaticView [ + + ^ hasStaticView +] + +{ + #category : #accessing, + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:04' +} +GMTETileMap >> hasStaticView: anObject [ + + hasStaticView := anObject. ] { @@ -535,7 +615,7 @@ GMTETileMap >> inViewPointToViewFraction: aPoint [ { #category : #initialization, - #'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:15' + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:04' } GMTETileMap >> initialize [ @@ -545,6 +625,7 @@ GMTETileMap >> initialize [ clipSubmorphs: true; forceMapSizeRatio: false; view: GMTEView new; + hasStaticView: true; "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)" @@ -691,6 +772,45 @@ GMTETileMap >> mapTileWidth: anObject [ mapTileWidth := anObject ] +{ + #category : #'event handling', + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:05' +} +GMTETileMap >> mouseMove: anEvent [ + + self hasStaticView ifTrue: [^ nil]. + anEvent shiftPressed ifFalse: [^ nil]. + anEvent redButtonPressed ifFalse: [^ nil]. + + self moveViewBy: (anEvent startPoint - anEvent position) +] + +{ + #category : #'event handling', + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:05' +} +GMTETileMap >> mouseWheel: anEvent [ + + self flag: 'does not work'. + "anEvent shiftPressed ifFalse: [^ nil]." + + self hasStaticView ifTrue: [^ nil]. + anEvent isWheelDown ifTrue: [self zoomInAt: (anEvent position - self topLeft)]. + anEvent isWheelUp ifTrue: [self zoomOutAt: (anEvent position - self topLeft)] +] + +{ + #category : #view, + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:50' +} +GMTETileMap >> moveViewBy: aPoint [ + "Note: aPoint is relative to current view" + "Note: center must induce legal view (non-overlapping)" + + self view moveBy: (self absPointToViewFraction: (aPoint / self viewScaleFactor)). + self updateMap +] + { #category : #updating, #'squeak_changestamp' : 'Ivo Zilkenat 6/24/2024 11:27' @@ -1320,10 +1440,42 @@ GMTETileMap >> vigenerateBackgroundTiles [ { #category : #view, - #'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 00:33' + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 17:10' +} +GMTETileMap >> zoomAt: aPoint by: aFloat [ + "" + + | newCenter oldMouseCenterOffset aPointAbs oldScaleFactor | + + oldScaleFactor := self viewScaleFactor. + aPointAbs := self inViewPointToAbs: aPoint. + oldMouseCenterOffset := (self inViewPointToAbs: (self extent / 2)) - aPointAbs. + + self view changeSizeBy: (aFloat negated). + + newCenter := (oldScaleFactor / self viewScaleFactor) * oldMouseCenterOffset + aPointAbs. + self centerViewAtAbs: newCenter. + + self flag: 'refactor. This seems to be necessary but highlights only exist for editable tile map'. + "self tileSelectionSet clearAllHighlightings" +] + +{ + #category : #view, + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:05' } GMTETileMap >> zoomInAt: aPoint [ - self view shrinkBy: 0.1. - self centerViewAt: aPoint + (self canZoomInBy: 0.1) ifFalse: [^ nil]. + self zoomAt: aPoint by: 0.1 +] + +{ + #category : #view, + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:05' +} +GMTETileMap >> zoomOutAt: aPoint [ + + (self canZoomOutBy: 0.1) ifFalse: [^ nil]. + self zoomAt: aPoint by: -0.1 ] diff --git a/source/GM-TE/GMTETilemapSizeCommand.class.st b/source/GM-TE/GMTETilemapSizeCommand.class.st index fe18b4f0..fe683543 100644 --- a/source/GM-TE/GMTETilemapSizeCommand.class.st +++ b/source/GM-TE/GMTETilemapSizeCommand.class.st @@ -2,7 +2,6 @@ Class { #name : #GMTETilemapSizeCommand, #superclass : #GMTEEditTilesCommand, #instVars : [ - 'editor', 'method', 'prevSize', 'newSize', @@ -34,22 +33,6 @@ GMTETilemapSizeCommand >> do [ self editor perform: self method with: self newSize ] -{ - #category : #accessing, - #'squeak_changestamp' : 'Alex M 7/1/2024 18:00' -} -GMTETilemapSizeCommand >> editor [ - ^ editor -] - -{ - #category : #accessing, - #'squeak_changestamp' : 'Alex M 7/1/2024 18:00' -} -GMTETilemapSizeCommand >> editor: anObject [ - editor := anObject -] - { #category : #accessing, #'squeak_changestamp' : 'Alex M 7/1/2024 18:48' diff --git a/source/GM-TE/GMTEView.class.st b/source/GM-TE/GMTEView.class.st index 9d55a807..de30ac68 100644 --- a/source/GM-TE/GMTEView.class.st +++ b/source/GM-TE/GMTEView.class.st @@ -6,15 +6,30 @@ Class { { #category : #'as yet unclassified', - #'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:17' + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:06' } -GMTEView >> enlargeBy: aFloat [ +GMTEView >> canChangeSizeBy: aFloat [ + + | newExtent | + newExtent := (self extent + (aFloat@aFloat)). + + ((newExtent x <= 0.1) or: [newExtent y <= 0.1]) ifTrue: [^ false]. + ((newExtent x > 1) or: [newExtent y > 1]) ifTrue: [^ false]. + ^ true + +] + +{ + #category : #'as yet unclassified', + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:01' +} +GMTEView >> changeSizeBy: aFloat [ | newExtent | newExtent := (self extent + (aFloat@aFloat)). self flag: 'magic number'. - ((newExtent x > 1) or: [newExtent y > 1]) ifTrue: [^ nil]. + (self canChangeSizeBy: aFloat) ifFalse: [^ nil]. (self isOverlappingOrigin: self origin withExtent: newExtent) ifTrue: [^ nil]. self extent: newExtent @@ -45,13 +60,32 @@ GMTEView >> initialize [ { #category : #'as yet unclassified', - #'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:05' + #'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 22:43' } GMTEView >> isOverlappingOrigin: anOrigin withExtent: anExtent [ | corner | corner := anOrigin + anExtent. - ^ (corner x > 1) or: [corner y > 1] + + self flag: 'tmp for testing'. + ^ false. + + "^ (((corner x > 1) or: [corner y > 1]) or: [anOrigin x < 0]) or: [anOrigin y < 0]" +] + +{ + #category : #'as yet unclassified', + #'squeak_changestamp' : 'Ivo Zilkenat 7/12/2024 16:41' +} +GMTEView >> moveBy: aPoint [ + "Set origin but also respect view not overlapping reference view" + + | newOrigin | + newOrigin := self origin + aPoint. + + (self isOverlappingOrigin: newOrigin withExtent: self extent) ifTrue: [^ nil]. + + self origin: newOrigin ] { @@ -68,11 +102,11 @@ GMTEView >> moveTo: anOrigin [ { #category : #'as yet unclassified', - #'squeak_changestamp' : 'Ivo Zilkenat 7/10/2024 18:33' + #'squeak_changestamp' : 'Ivo Zilkenat 7/11/2024 20:35' } GMTEView >> origin: aPoint [ - self setOrigin: aPoint corner: (aPoint + self corner) + self setOrigin: aPoint corner: (aPoint + (self corner - self origin)) ] { @@ -85,21 +119,6 @@ GMTEView >> reset [ ] -{ - #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'