Skip to content

Commit

Permalink
remove AlbCursorStencil
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Jan 2, 2024
1 parent 8a8f892 commit 03c9704
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 92 deletions.
26 changes: 17 additions & 9 deletions src/Album/AlbCursorElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Class {
#instVars : [
'textPosition',
'blinking',
'blinkTask'
'blinkTask',
'focusedBackground'
],
#category : #'Album-UI'
}
Expand All @@ -15,12 +16,6 @@ AlbCursorElement >> beBlinking: aBoolean [
blinking := aBoolean
]

{ #category : #initialization }
AlbCursorElement >> defaultBackground [

^ Color red
]

{ #category : #initialization }
AlbCursorElement >> defaultBlinking [

Expand All @@ -33,12 +28,25 @@ AlbCursorElement >> defaultBlurredBackground [
^ Color transparent
]

{ #category : #accessing }
AlbCursorElement >> focusedBackground [

^ focusedBackground ifNil: [ focusedBackground := Color red ]
]

{ #category : #accessing }
AlbCursorElement >> focusedBackground: aBackground [

focusedBackground := aBackground.
self background: aBackground

]

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

super initialize.

self background: self defaultBackground.
textPosition := 0.
self beBlinking: self defaultBlinking.
self focusability: BlFocusability none.
Expand All @@ -58,7 +66,7 @@ AlbCursorElement >> newBlinkingTask [
{ #category : #'private - focus' }
AlbCursorElement >> onGotFocus [

self background: self defaultBackground.
self background: self focusedBackground.
self startBlinkingTask

]
Expand Down
67 changes: 0 additions & 67 deletions src/Album/AlbCursorStencil.class.st

This file was deleted.

2 changes: 1 addition & 1 deletion src/Album/AlbEditorElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ AlbEditorElement >> setupPrimarySelectionElement [

primarySelectionElement ifNotNil: [ :pse | pse removeFromParent ].
primarySelectionElement := self newPrimarySelectionElement.
primarySelectionElement ifNotNil: [ :pse | self addChild: pse ]
primarySelectionElement ifNotNil: [ :pse | self frontLayer addChild: pse ]
]

{ #category : #initialization }
Expand Down
37 changes: 24 additions & 13 deletions src/Album/AlbInfiniteEditorElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Class {
#classTraits : 'TBlLayoutResizable classTrait',
#instVars : [
'mode',
'cursorStencil',
'cursorElement',
'wordStencil',
'modeEventHandlers',
'modeShortcuts'
Expand Down Expand Up @@ -74,27 +74,27 @@ AlbInfiniteEditorElement >> cursor [
]

{ #category : #'accessing - cursor' }
AlbInfiniteEditorElement >> cursorColor: aColor [
AlbInfiniteEditorElement >> cursorBackground [

self cursorStencil cursorColor: aColor
^ self cursorElement background
]

{ #category : #'accessing - cursor' }
AlbInfiniteEditorElement >> cursorElement [
AlbInfiniteEditorElement >> cursorBackground: aBackground [

^ cursorStencil currentCursorElement
self cursorElement focusedBackground: aBackground
]

{ #category : #'accessing - cursor' }
AlbInfiniteEditorElement >> cursorStencil [
AlbInfiniteEditorElement >> cursorColor: aColor [

^ cursorStencil
self cursorBackground: aColor
]

{ #category : #'accessing - cursor' }
AlbInfiniteEditorElement >> cursorStencil: aCursorStencil [
AlbInfiniteEditorElement >> cursorElement [

cursorStencil := aCursorStencil
^ cursorElement startBlinkingTask; yourself
]

{ #category : #'private - accessing editor' }
Expand All @@ -104,9 +104,9 @@ AlbInfiniteEditorElement >> cursors [
]

{ #category : #initialization }
AlbInfiniteEditorElement >> defaultCursorStencil [
^ AlbCursorStencil new
AlbInfiniteEditorElement >> defaultCursorBackground [

^ Color red
]

{ #category : #initialization }
Expand Down Expand Up @@ -251,11 +251,22 @@ AlbInfiniteEditorElement >> infinite [
AlbInfiniteEditorElement >> initialize [

super initialize.
cursorStencil := AlbCursorStencil new.
self initializeCursorElement.
self mode: self defaultMode.
self matchParent
]

{ #category : #initialization }
AlbInfiniteEditorElement >> initializeCursorElement [
"Pay attention: a CursorElement ** must be a unique ** inside an editor element.
If not, dbl clicking will not work because the target of the first click may
be different from the one of the second click"

cursorElement := AlbCursorElement new
background: self defaultCursorBackground;
yourself
]

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

Expand Down
4 changes: 2 additions & 2 deletions src/Album/AlbTextElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Class {
'cursorElement',
'segmentPiece'
],
#category : 'Album-UI'
#category : #'Album-UI'
}

{ #category : #'cursor - management' }
Expand All @@ -14,7 +14,7 @@ AlbTextElement >> addCursorAt: aTextPosition inEditorElement: anEditorElement [
<return: #AlbCursorElement>
^ self cursorAt: aTextPosition ifFound: #yourself ifNone: [
cursorElement ifNil: [
cursorElement := anEditorElement cursorStencil asElement.
cursorElement := anEditorElement cursorElement.
cursorElement removeFromParent.
self addChild: cursorElement ].
cursorElement textPosition: aTextPosition.
Expand Down

0 comments on commit 03c9704

Please sign in to comment.