Skip to content

Commit

Permalink
Clean up (format) BlocHost-Morphic
Browse files Browse the repository at this point in the history
See #116
  • Loading branch information
tinchodias committed May 10, 2024
1 parent 37d782f commit 654832c
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 44 deletions.
1 change: 1 addition & 0 deletions src/BlocHost-Morphic/BlMorphicWorldDisplayScreen.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ BlMorphicWorldDisplayScreen >> beDisplay [

{ #category : #testing }
BlMorphicWorldDisplayScreen >> isFullscreen [

^ false
]

Expand Down
22 changes: 13 additions & 9 deletions src/BlocHost-Morphic/BlMorphicWorldEmbeddingElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ BlMorphicWorldEmbeddingElement class >> openMain [

{ #category : #accessing }
BlMorphicWorldEmbeddingElement >> activeHand [
^ self world activeHand
ifNil: [
| aHand |

aHand := world hands anyOne.
world activeHand: aHand.
aHand ]

^ self world activeHand ifNil: [
| aHand |
aHand := world hands anyOne.
world activeHand: aHand.
aHand ]
]

{ #category : #actions }
BlMorphicWorldEmbeddingElement >> beMain [

shouldBeMain := true.
self isAttachedToSceneGraph
ifTrue: [ world beMain ]
Expand Down Expand Up @@ -81,7 +81,9 @@ BlMorphicWorldEmbeddingElement >> initialize [
yourself).

self addEventHandler: BlMorphicWorldEmbeddingEventHandler new.
self addEventHandlerOn: BlMouseDownEvent do: [ self requestFocus ].
self
addEventHandlerOn: BlMouseDownEvent
do: [ self requestFocus ].

self enqueueTask:
(BlRepeatedTaskAction new
Expand All @@ -92,13 +94,15 @@ BlMorphicWorldEmbeddingElement >> initialize [

{ #category : #'hooks - children' }
BlMorphicWorldEmbeddingElement >> onAddedToSceneGraph [

super onAddedToSceneGraph.

shouldBeMain ifTrue: [ world beMain ]
]

{ #category : #layout }
BlMorphicWorldEmbeddingElement >> onLayout: aRectangle context: aBlElementBoundsUpdater [

super onLayout: aRectangle context: aBlElementBoundsUpdater.

world fullBounds.
Expand All @@ -121,12 +125,12 @@ BlMorphicWorldEmbeddingElement >> onMeasure: anExtentMeasurementSpec [

{ #category : #accessing }
BlMorphicWorldEmbeddingElement >> world [
<return: #WorldMorph>

^ world
]

{ #category : #accessing }
BlMorphicWorldEmbeddingElement >> world: aWorldMorph [

world := aWorldMorph
]
29 changes: 21 additions & 8 deletions src/BlocHost-Morphic/BlMorphicWorldEmbeddingEventHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ BlMorphicWorldEmbeddingEventHandler class >> initialize [

{ #category : #converting }
BlMorphicWorldEmbeddingEventHandler >> convertButton: aBlMouseButton [

aBlMouseButton = BlMouseButton primary
ifTrue: [ ^ MouseButtonEvent redButton ].
aBlMouseButton = BlMouseButton middle
Expand All @@ -69,6 +70,7 @@ BlMorphicWorldEmbeddingEventHandler >> convertButton: aBlMouseButton [

{ #category : #converting }
BlMorphicWorldEmbeddingEventHandler >> convertModifiers: modifiers [

| btns |
btns := 0.

Expand All @@ -88,16 +90,21 @@ BlMorphicWorldEmbeddingEventHandler >> convertModifiers: modifiers [

{ #category : #events }
BlMorphicWorldEmbeddingEventHandler >> dispatchMorphicEvent: anEvent hand: aHandMorph [

aHandMorph
ifNotNil: [
aHandMorph handleEvent: anEvent ]
ifNil: [ NonInteractiveTranscript stderr show: ('Can not handle {1} because hand is nil' format: { anEvent }); cr ]
ifNotNil: [ aHandMorph handleEvent: anEvent ]
ifNil: [
NonInteractiveTranscript stderr
show: ('Can not handle {1} because hand is nil'
format: { anEvent });
cr ]
]

{ #category : #visiting }
{ #category : #'keyboard handlers' }
BlMorphicWorldEmbeddingEventHandler >> keyDownEvent: anEvent [

| aHand aMorphicEvent aCharacter aKeyValue aCharCode |

anEvent consume.
aHand := anEvent currentTarget activeHand.

Expand Down Expand Up @@ -137,8 +144,9 @@ BlMorphicWorldEmbeddingEventHandler >> keyDownEvent: anEvent [
self dispatchMorphicEvent: aMorphicEvent hand: aHand
]

{ #category : #visiting }
{ #category : #'keyboard handlers' }
BlMorphicWorldEmbeddingEventHandler >> keyUpEvent: anEvent [

| aHand aMorphicEvent |

anEvent consume.
Expand Down Expand Up @@ -167,6 +175,7 @@ BlMorphicWorldEmbeddingEventHandler >> mapKeyToCharacter: aKeyboardKey [

{ #category : #'mouse handlers' }
BlMorphicWorldEmbeddingEventHandler >> mouseDownEvent: anEvent [

| aHand aMorphicEvent |

anEvent consume.
Expand All @@ -188,6 +197,7 @@ BlMorphicWorldEmbeddingEventHandler >> mouseDownEvent: anEvent [

{ #category : #'mouse handlers' }
BlMorphicWorldEmbeddingEventHandler >> mouseMoveEvent: anEvent [

| aHand aMorphicEvent oldPos theButtons |

anEvent consume.
Expand Down Expand Up @@ -217,6 +227,7 @@ BlMorphicWorldEmbeddingEventHandler >> mouseMoveEvent: anEvent [

{ #category : #'mouse handlers' }
BlMorphicWorldEmbeddingEventHandler >> mouseUpEvent: anEvent [

| aHand aMorphicEvent |

anEvent consume.
Expand All @@ -236,8 +247,9 @@ BlMorphicWorldEmbeddingEventHandler >> mouseUpEvent: anEvent [
self dispatchMorphicEvent: aMorphicEvent hand: aHand
]

{ #category : #visiting }
{ #category : #'mouse handlers' }
BlMorphicWorldEmbeddingEventHandler >> mouseWheelEvent: anEvent [

| vertical aHand aMorphicEvent |

anEvent consume.
Expand All @@ -262,8 +274,9 @@ BlMorphicWorldEmbeddingEventHandler >> mouseWheelEvent: anEvent [
self dispatchMorphicEvent: aMorphicEvent hand: aHand
]

{ #category : #visiting }
{ #category : #'keyboard handlers' }
BlMorphicWorldEmbeddingEventHandler >> textInputEvent: anEvent [

| aHand aMorphicEvent anInputString |

anEvent consume.
Expand Down
28 changes: 16 additions & 12 deletions src/BlocHost-Morphic/BlMorphicWorldMorph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ Class {

{ #category : #accessing }
BlMorphicWorldMorph class >> worldState: aWorldState [
^ self basicNew initializeWith: aWorldState

^ self basicNew
initializeWith: aWorldState;
yourself
]

{ #category : #actions }
Expand All @@ -34,24 +37,23 @@ BlMorphicWorldMorph >> beMain [
MorphicUIManager classVarNamed: #UIProcess put: aProcess ]
]

{ #category : #accessing }
{ #category : #api }
BlMorphicWorldMorph >> display [
<return: #Form>

^ display
]

{ #category : #initialization }
BlMorphicWorldMorph >> displayExtent [

^ display extent
]

{ #category : #initialization }
BlMorphicWorldMorph >> displayExtent: aPoint [
display
setExtent: aPoint
depth: display depth.


display setExtent: aPoint depth: display depth.

self changed
]

Expand Down Expand Up @@ -92,13 +94,14 @@ BlMorphicWorldMorph >> drawOnSpartaCanvas: aCanvas [

{ #category : #accessing }
BlMorphicWorldMorph >> drawingCache [

^ drawingCache ifNil: [ drawingCache := IdentityDictionary new ]
]

{ #category : #initialization }
BlMorphicWorldMorph >> initializeMenubar [
| oldWorld oldActiveWorld |

| oldWorld oldActiveWorld |
oldWorld := World.
oldActiveWorld := ActiveWorld.
World := self.
Expand All @@ -114,6 +117,7 @@ BlMorphicWorldMorph >> initializeMenubar [

{ #category : #initialization }
BlMorphicWorldMorph >> initializeWith: aWorldState [

| aHand |
self initialize.

Expand All @@ -139,19 +143,19 @@ BlMorphicWorldMorph >> initializeWith: aWorldState [

{ #category : #'change reporting' }
BlMorphicWorldMorph >> invalidRect: damageRect from: aMorph [

| myChild |
super invalidRect: damageRect from: aMorph.

aMorph == self
ifTrue: [ ^ self ].
aMorph == self ifTrue: [ ^ self ].

myChild := aMorph.

[ myChild isNotNil and: [ myChild owner ~~ self ] ]
whileTrue: [ myChild := myChild owner ].

myChild owner == self
ifTrue: [ self drawingCache removeKey: myChild ifAbsent: [ ] ]
myChild owner == self ifTrue: [
self drawingCache removeKey: myChild ifAbsent: [ ] ]
]

{ #category : #recategorized }
Expand Down
18 changes: 11 additions & 7 deletions src/BlocHost-Morphic/BlMorphicWorldRenderer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ BlMorphicWorldRenderer >> activateCursor: aCursor withMask: maskForm [

{ #category : #activation }
BlMorphicWorldRenderer >> actualScreenSize [
<return: #Point>

^ self element extent
]

{ #category : #accessing }
BlMorphicWorldRenderer >> canvas [

^ display getCanvas
]

Expand All @@ -50,9 +50,10 @@ BlMorphicWorldRenderer >> deactivate [

{ #category : #activation }
BlMorphicWorldRenderer >> doActivate [

| initialExtent |

initialExtent := world worldState realWindowExtent ifNil: [976@665].
initialExtent := world worldState realWindowExtent
ifNil: [ 976@665 ].

display := Form extent: initialExtent depth: 32.
world extent: initialExtent.
Expand All @@ -63,21 +64,24 @@ BlMorphicWorldRenderer >> doActivate [

{ #category : #accessing }
BlMorphicWorldRenderer >> element [

^ element
]

{ #category : #accessing }
BlMorphicWorldRenderer >> element: anObject [
element := anObject
BlMorphicWorldRenderer >> element: aBlElement [

element := aBlElement
]

{ #category : #accessing }
BlMorphicWorldRenderer >> icon: aForm [
]

{ #category : #activation }
{ #category : #initialization }
BlMorphicWorldRenderer >> initialize [

super initialize.

element := BlElement new
]
23 changes: 15 additions & 8 deletions src/BlocHost-Morphic/BlMorphicWorldState.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,59 @@ Class {

{ #category : #accessing }
BlMorphicWorldState >> display [
<return: #Form>

^ display
]

{ #category : #accessing }
BlMorphicWorldState >> display: aForm [

display := aForm
]

{ #category : #'update cycle' }
BlMorphicWorldState >> displayWorld: aWorld submorphs: submorphs [
element invalidRect: (BlBounds fromRectangle: (0@0 extent: aWorld extent))

element invalidRect:
(BlBounds fromRectangle: (0 @ 0 extent: aWorld extent))
]

{ #category : #'update cycle' }
BlMorphicWorldState >> doOneCycleFor: aWorld [
BlMorphicWorldState >> doOneCycleFor: aWorld [

self doOneCycleNowFor: aWorld
]

{ #category : #'update cycle' }
BlMorphicWorldState >> doOneCycleNowFor: aWorld [
self element isAttachedToSceneGraph
ifTrue: [
self element space host universe pulseSynchronously.
10 milliSeconds wait ]

self element isAttachedToSceneGraph ifFalse: [ ^ self ].
self element space host universe pulseSynchronously.
10 milliSeconds wait
]

{ #category : #accessing }
BlMorphicWorldState >> element [

^ element
]

{ #category : #accessing }
BlMorphicWorldState >> element: anObject [

element := anObject
]

{ #category : #initialization }
BlMorphicWorldState >> initialize [

super initialize.

self currentCursor: Cursor normal
]

{ #category : #canvas }
BlMorphicWorldState >> recordDamagedRect: damageRect [

element invalidRect: (BlBounds fromRectangle: damageRect)
]

0 comments on commit 654832c

Please sign in to comment.