Skip to content

Commit

Permalink
AlbInfiniteEditorElement mode is not an observable slot anymore.
Browse files Browse the repository at this point in the history
removed whenModeChangedDo:
  • Loading branch information
plantec committed Dec 30, 2023
1 parent 08e4c04 commit a6652ea
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 51 deletions.
4 changes: 2 additions & 2 deletions src/Album/AlbCursorElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Class {
'blinking',
'blinkTask'
],
#category : 'Album-UI'
#category : #'Album-UI'
}

{ #category : #accessing }
Expand All @@ -30,7 +30,7 @@ AlbCursorElement >> defaultBlinking [
{ #category : #initialization }
AlbCursorElement >> defaultBlurredBackground [

^ Color brown
^ Color transparent
]

{ #category : #initialization }
Expand Down
20 changes: 11 additions & 9 deletions src/Album/AlbEditorElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ AlbEditorElement >> defaultBackground [
AlbEditorElement >> defaultFrontLayer [

| layer |
self flag: 'Check elevation use'.
layer := BlElement new.
"layer elevation: (BlRelativeElevation elevation: SmallInteger maxVal)."
layer constraintsDo: [ :c |
c horizontal matchParent.
c vertical matchParent ].
Expand Down Expand Up @@ -88,22 +86,26 @@ AlbEditorElement >> initialize [
self installRemanentUpdater.
self addChild: next.

self whenModeChangedDo: [
self installPrimarySelectionElement.
self installRemanentUpdater.
self installModeEventHandlers ].
self addEventHandler: (BlEventHandler
on: AlbInfiniteEditorModeChangedEvent
do: [
self installPrimarySelectionElement.
self installRemanentUpdater.
self installModeEventHandlers ]).

self whenEditorChangedDo: [ :event |
self installRemanentUpdater ].
self whenEditorChangedDo: [ :event | self installRemanentUpdater ].

frontLayer := self defaultFrontLayer.
self addChild: frontLayer as: #frontLayer.
distributor := BlSharedEventDistributor new
adjustMousePosition: false;
shareEvents: (Array with: BlMouseEvent);
shareEvents: {
BlMouseEvent.
AlbInfiniteEditorModeChangedEvent };
yourself.
self frontLayer addEventHandler: distributor.
self infinite addEventHandler: distributor.
self addEventHandler: distributor.
self matchParent.
self installModeEventHandlers
]
Expand Down
44 changes: 19 additions & 25 deletions src/Album/AlbInfiniteEditorElement.class.st
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Class {
#name : #AlbInfiniteEditorElement,
#superclass : #BlInfiniteElement,
#traits : 'TObservable + TBlLayoutResizable',
#classTraits : 'TObservable classTrait + TBlLayoutResizable classTrait',
#traits : 'TBlLayoutResizable',
#classTraits : 'TBlLayoutResizable classTrait',
#instVars : [
'#mode => ObservableSlot',
'#cursorStencil',
'#wordStencil',
'#modeEventHandlers',
'#modeShortcuts'
'mode',
'cursorStencil',
'wordStencil',
'modeEventHandlers',
'modeShortcuts'
],
#category : 'Album-UI'
#category : #'Album-UI'
}

{ #category : #'accessing - editor' }
Expand Down Expand Up @@ -272,24 +272,25 @@ AlbInfiniteEditorElement >> infinite [

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

self class initializeSlots: self.

super initialize.

self background: self defaultBackground.
cursorStencil := AlbCursorStencil new.
self editor: self defaulTextEditor.

" action when mode change (Observable slot) "
self whenModeChangedDo: [ :m | self modeChanged ].
mode := self defaultMode.
self addEventHandler: (BlEventHandler
on: AlbInfiniteEditorModeChangedEvent
do: [ self modeChanged ]).
self mode: self defaultMode.
self matchParent.
self margin: self defaultMargin.
self padding: self defaultPadding.
self whenLayoutedDo: [
self whenLayoutedDo: [
self geometryChanged.
self selectionChanged ].
self elevation: ((BlRelativeElevation elevation: SmallInteger maxVal - 1)).
self elevation:
(BlRelativeElevation elevation: SmallInteger maxVal - 1)
]

{ #category : #'accessing - editor' }
Expand Down Expand Up @@ -330,7 +331,8 @@ AlbInfiniteEditorElement >> mode [
AlbInfiniteEditorElement >> mode: anEditabilityMode [

mode = anEditabilityMode ifTrue: [ ^ self ].
mode := anEditabilityMode
mode := anEditabilityMode.
self dispatchEvent: AlbInfiniteEditorModeChangedEvent new
]

{ #category : #'view - configuration' }
Expand Down Expand Up @@ -622,14 +624,6 @@ AlbInfiniteEditorElement >> whenEditorChangedDo: aBlock [
do: aBlock)
]

{ #category : #'view - configuration' }
AlbInfiniteEditorElement >> whenModeChangedDo: aBlock [

"set a block to perform after that the mode has been chanbed, and its action performed"

self property: #mode whenChangedDo: aBlock
]

{ #category : #'view - configuration' }
AlbInfiniteEditorElement >> whenTextEditedDo: aBlock [

Expand Down
11 changes: 11 additions & 0 deletions src/Album/AlbInfiniteEditorModeChangedEvent.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Class {
#name : #AlbInfiniteEditorModeChangedEvent,
#superclass : #BlEvent,
#category : #'Album-UI'
}

{ #category : #sending }
AlbInfiniteEditorModeChangedEvent >> sendTo: anObject [

anObject infiniteEditorModeChangedEvent: self
]
11 changes: 9 additions & 2 deletions src/Album/AlbPrimarySelectionElement.class.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Class {
#name : #AlbPrimarySelectionElement,
#superclass : #AlbAbstractSubtextElement,
#category : 'Album-UI-Text-Portion'
#instVars : [
'modeChangedEventHandler'
],
#category : #'Album-UI-Text-Portion'
}

{ #category : #initialization }
Expand Down Expand Up @@ -36,7 +39,10 @@ AlbPrimarySelectionElement >> onGotFocus [
{ #category : #'api - install/uninstall hook' }
AlbPrimarySelectionElement >> onInstalled [

self editorElement infinite whenModeChangedDo: [ self onUninstalled ]
modeChangedEventHandler := BlEventHandler
on: AlbInfiniteEditorModeChangedEvent
do: [ self onUninstalled ].
self editorElement addEventHandler: modeChangedEventHandler
]

{ #category : #private }
Expand All @@ -48,6 +54,7 @@ AlbPrimarySelectionElement >> onLostFocus [
{ #category : #'api - install/uninstall hook' }
AlbPrimarySelectionElement >> onUninstalled [

self editorElement removeEventHandler: modeChangedEventHandler.
updateStrategy onUninstalledIn: self

]
Expand Down
17 changes: 12 additions & 5 deletions src/Album/AlbRemanentsUpdater.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ Class {
#superclass : #AlbTextPortionUpdater,
#instVars : [
'oppositeEcho',
'textReplacedHandler'
'textReplacedHandler',
'modeChangeHandler'
],
#category : 'Album-UI-Text-Portion'
#category : #'Album-UI-Text-Portion'
}

{ #category : #'opposite delimiter' }
Expand Down Expand Up @@ -81,17 +82,23 @@ AlbRemanentsUpdater >> extentChangedIn: anEditorElement [
AlbRemanentsUpdater >> onInstalledIn: anEditorElement [

super onInstalledIn: anEditorElement.
anEditorElement infinite whenModeChangedDo: [ self onUninstalledIn: anEditorElement ].
modeChangeHandler := BlEventHandler
on: AlbInfiniteEditorModeChangedEvent
do: [ self onUninstalledIn: anEditorElement ].
textReplacedHandler := BlEventHandler
on: AlbTextEditorReplacedEvent
do: [ :evt | self onUninstalledIn: anEditorElement ].
anEditorElement infinite addEventHandler: textReplacedHandler
do: [ :evt |
self onUninstalledIn: anEditorElement ].
anEditorElement infinite addEventHandler: textReplacedHandler.
anEditorElement addEventHandler: modeChangeHandler.

]

{ #category : #'api - install/uninstall hook' }
AlbRemanentsUpdater >> onUninstalledIn: anEditorElement [

anEditorElement infinite removeEventHandler: textReplacedHandler.
anEditorElement removeEventHandler: modeChangeHandler.
super onUninstalledIn: anEditorElement.

]
Expand Down
8 changes: 0 additions & 8 deletions src/Album/TAlbInfiniteDecorator.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,6 @@ TAlbInfiniteDecorator >> whenEditorChangedDo: aBlock [
self next whenEditorChangedDo: aBlock
]

{ #category : #'t - infinite editor view - configuration' }
TAlbInfiniteDecorator >> whenModeChangedDo: aBlock [

"set a block to perform after that the mode has been chanbed, and its action performed"

self next whenModeChangedDo: aBlock
]

{ #category : #'t - infinite editor view - configuration' }
TAlbInfiniteDecorator >> whenTextEditedDo: aBlock [

Expand Down

0 comments on commit a6652ea

Please sign in to comment.