Skip to content

Commit

Permalink
somes changes around cursorElement
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Mar 18, 2024
1 parent 7bbf9f5 commit a916af3
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 47 deletions.
4 changes: 2 additions & 2 deletions src/Album/AlbCursorElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ AlbCursorElement >> initialize [
self preventMouseEvents.
self constraintsDo: [ :c |
c horizontal exact: 2.
c vertical matchParent ]
c vertical matchParent ].
self addEventHandler: AlbCursorElementEventHandler new
]

{ #category : #initialization }
Expand Down Expand Up @@ -106,6 +107,5 @@ AlbCursorElement >> textPosition [
{ #category : #accessing }
AlbCursorElement >> textPosition: anInteger [

self fireEvent: AlbCursorElementMovedEvent new.
textPosition := anInteger
]
46 changes: 46 additions & 0 deletions src/Album/AlbCursorElementEventHandler.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Class {
#name : #AlbCursorElementEventHandler,
#superclass : #BlCustomEventHandler,
#instVars : [
'previousBoundsInSpace'
],
#category : #'Album-UI'
}

{ #category : #'event handling' }
AlbCursorElementEventHandler >> elementAddedToSceneGraphEvent: anEvent [

self notifyCursorElementMovedFromEvent: anEvent
]

{ #category : #'event handling' }
AlbCursorElementEventHandler >> elementExtentChangedEvent: anEvent [

self notifyCursorElementMovedFromEvent: anEvent
]

{ #category : #'event handling' }
AlbCursorElementEventHandler >> elementPositionInSpaceChangedEvent: anEvent [

self notifyCursorElementMovedFromEvent: anEvent
]

{ #category : #'api - accessing' }
AlbCursorElementEventHandler >> eventsToHandle [

^ {
BlElementExtentChangedEvent.
BlElementAddedToSceneGraphEvent.
BlElementPositionInSpaceChangedEvent }
]

{ #category : #'event handling' }
AlbCursorElementEventHandler >> notifyCursorElementMovedFromEvent: anEvent [

| cursorElement boundsInSpace |
cursorElement := anEvent currentTarget.
boundsInSpace := cursorElement bounds inSpace bounds.
previousBoundsInSpace = boundsInSpace ifTrue: [ ^ self ].
previousBoundsInSpace := boundsInSpace.
anEvent currentTarget fireEvent: AlbCursorElementMovedEvent new
]
18 changes: 7 additions & 11 deletions src/Album/AlbCursorMovedEvent.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,9 @@ Class {
'newIndex',
'dueTo'
],
#category : 'Album-Model-Events'
#category : #'Album-Model-Events'
}

{ #category : #'instance creation' }
AlbCursorMovedEvent class >> cursor: aCursor from: anOldIndex to: aNewIndex [
<return: #AlbCursorMovedEvent>

^ self new
cursor: aCursor;
oldIndex: anOldIndex;
newIndex: aNewIndex
]

{ #category : #'instance creation' }
AlbCursorMovedEvent class >> cursor: aCursor from: anOldIndex to: aNewIndex dueTo: aTextEditorOperator [
<return: #AlbCursorMovedEvent>
Expand Down Expand Up @@ -76,3 +66,9 @@ AlbCursorMovedEvent >> oldIndex [
AlbCursorMovedEvent >> oldIndex: aNumber [
oldIndex := aNumber
]

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

anObject cursorMovedEvent: self
]
1 change: 1 addition & 0 deletions src/Album/AlbEditorElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ AlbEditorElement >> initialize [
BlMouseEvent.
BlElementScrolledEvent.
AlbTextInsertedEvent.
AlbTextDeletedEvent.
AlbTextEditedEvent.
AlbInfiniteModeChangedEvent.
BlFocusEvent.
Expand Down
18 changes: 9 additions & 9 deletions src/Album/AlbEditorElementEventHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ AlbEditorElementEventHandler >> blurEvent: anEvent [
anEvent currentTarget primarySelectionElement dispatchEvent: anEvent copy
]

{ #category : #'element handlers' }
AlbEditorElementEventHandler >> cursorElementMovedEvent: anEvent [

| target |
target := anEvent currentTarget.
target dispatchPrimarySelectionInvalidateEvent
]

{ #category : #'element handlers' }
AlbEditorElementEventHandler >> elementExtentChangedEvent: anEvent [

Expand All @@ -31,7 +39,7 @@ AlbEditorElementEventHandler >> elementScrolledEvent: anEvent [
AlbEditorElementEventHandler >> eventsToHandle [

^ {
BlMouseUpEvent.
AlbCursorElementMovedEvent.
AlbInfiniteModeChangedEvent.
AlbPrimarySelectionElementClassChangedEvent.
BlElementExtentChangedEvent.
Expand All @@ -55,14 +63,6 @@ AlbEditorElementEventHandler >> infiniteModeChangedEvent: anEvent [
target dispatchPrimarySelectionInvalidateEvent
]

{ #category : #'element handlers' }
AlbEditorElementEventHandler >> mouseUpEvent: anEvent [

| target |
target := anEvent currentTarget.
target dispatchPrimarySelectionInvalidateEvent
]

{ #category : #'event handling' }
AlbEditorElementEventHandler >> primarySelectionElementClassChangedEvent: anEvent [

Expand Down
9 changes: 1 addition & 8 deletions src/Album/AlbOppositeDelimiterUpdater.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,12 @@ AlbOppositeDelimiterUpdater >> createOppositeDelimiterIn: anEditorElement [
^ nil
]

{ #category : #'event handling' }
AlbOppositeDelimiterUpdater >> cursorElementMovedEvent: anEvent [

self updateOppositeDelimiterIn: anEvent currentTarget.
]

{ #category : #'api - accessing' }
AlbOppositeDelimiterUpdater >> eventsToHandle [

^ {
AlbSubtextElementInvalidateEvent.
AlbInfiniteModeChangedEvent.
AlbCursorElementMovedEvent }
AlbInfiniteModeChangedEvent }
]

{ #category : #'event handling' }
Expand Down
14 changes: 13 additions & 1 deletion src/Album/AlbTextDeletedEvent.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Class {
'fromIndex',
'toIndex'
],
#category : 'Album-Model-Events'
#category : #'Album-Model-Events'
}

{ #category : #'instance creation' }
Expand All @@ -27,6 +27,18 @@ AlbTextDeletedEvent >> fromIndex: anObject [
fromIndex := anObject
]

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

anObject textDeletedEvent: self
]

{ #category : #accessing }
AlbTextDeletedEvent >> startIndex [

^ self fromIndex
]

{ #category : #accessing }
AlbTextDeletedEvent >> toIndex [
^ toIndex
Expand Down
8 changes: 1 addition & 7 deletions src/Album/AlbTextEditorSegmentElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@ Override me for more advanced customizations
Class {
#name : #AlbTextEditorSegmentElement,
#superclass : #BlElement,
#category : 'Album-UI'
#category : #'Album-UI'
}

{ #category : #initialization }
AlbTextEditorSegmentElement >> initialize [
super initialize.
self clipChildren: false
]

{ #category : #'api - compositing' }
AlbTextEditorSegmentElement >> wantsSeparateCompositingLayer [

^ false
]
16 changes: 14 additions & 2 deletions src/Album/AlbTextInsertedEvent.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ AlbTextInsertedEvent class >> text: aBlText at: anIndex [
]

{ #category : #accessing }
AlbTextInsertedEvent >> endIndex [
AlbTextInsertedEvent >> fromIndex [

^ self index + self text size
^ self index
]

{ #category : #accessing }
Expand All @@ -33,6 +33,12 @@ AlbTextInsertedEvent >> index: aNumber [
index := aNumber
]

{ #category : #sending }
AlbTextInsertedEvent >> sendTo: anEventHandler [

anEventHandler textInsertedEvent: self
]

{ #category : #accessing }
AlbTextInsertedEvent >> text [
^ text
Expand All @@ -42,3 +48,9 @@ AlbTextInsertedEvent >> text [
AlbTextInsertedEvent >> text: aText [
text := aText
]

{ #category : #accessing }
AlbTextInsertedEvent >> toIndex [

^ self index + self text size
]
8 changes: 1 addition & 7 deletions src/Album/AlbTextParagraph.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Class {
#instVars : [
'segmentPiece'
],
#category : 'Album-UI'
#category : #'Album-UI'
}

{ #category : #'paragraph - measuring' }
Expand All @@ -21,9 +21,3 @@ AlbTextParagraph >> segmentPiece: aSegmentPiece [

segmentPiece := aSegmentPiece
]

{ #category : #'api - compositing' }
AlbTextParagraph >> wantsSeparateCompositingLayer [

^ false
]
13 changes: 13 additions & 0 deletions src/Album/TAlbInfiniteDecorator.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ TAlbInfiniteDecorator >> asScrollableElement [
^ self next asScrollableElement
]

{ #category : #'t - infinite editor private - accessing text' }
TAlbInfiniteDecorator >> atTextIndex: aTextIndex do: aBlock [

" aBlock takes 2 arguments : the local text element and the local text index within the local text element"
self next atTextIndex: aTextIndex do: aBlock
]

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

Expand Down Expand Up @@ -57,6 +64,12 @@ TAlbInfiniteDecorator >> cursorColor: aColor [
self next cursorColor: aColor
]

{ #category : #'t - infinite editor accessing - cursor' }
TAlbInfiniteDecorator >> cursorElement [

^ self next cursorElement
]

{ #category : #'t - infinite editor accessing - cursor' }
TAlbInfiniteDecorator >> cursors [
<return: #AlbTextEditorCursor>
Expand Down

0 comments on commit a916af3

Please sign in to comment.