diff --git a/src/Album/AlbCursorElement.class.st b/src/Album/AlbCursorElement.class.st index 64f139d..09912f8 100644 --- a/src/Album/AlbCursorElement.class.st +++ b/src/Album/AlbCursorElement.class.st @@ -4,7 +4,8 @@ Class { #instVars : [ 'textPosition', 'blinking', - 'blinkTask' + 'blinkTask', + 'focusedBackground' ], #category : #'Album-UI' } @@ -15,12 +16,6 @@ AlbCursorElement >> beBlinking: aBoolean [ blinking := aBoolean ] -{ #category : #initialization } -AlbCursorElement >> defaultBackground [ - - ^ Color red -] - { #category : #initialization } AlbCursorElement >> defaultBlinking [ @@ -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. @@ -58,7 +66,7 @@ AlbCursorElement >> newBlinkingTask [ { #category : #'private - focus' } AlbCursorElement >> onGotFocus [ - self background: self defaultBackground. + self background: self focusedBackground. self startBlinkingTask ] diff --git a/src/Album/AlbCursorStencil.class.st b/src/Album/AlbCursorStencil.class.st deleted file mode 100644 index 63ef512..0000000 --- a/src/Album/AlbCursorStencil.class.st +++ /dev/null @@ -1,67 +0,0 @@ -" -I'm responsible for creating the cursor element in Album. I keep the current cursor so that it is instantiated one time for each AlbEditorElement. - - -Internal Representation and Key Implementation Points. - - Instance Variables - blinkTask: to manage the blinking - blinking: true is the cursor must blink - currentCursorElement: the current cursor element - - - Implementation Points -See the #create comment about the current instance variable - - - -" -Class { - #name : #AlbCursorStencil, - #superclass : #BlStencil, - #instVars : [ - 'currentCursorElement', - 'cursorColor' - ], - #category : 'Album-UI-Stencils' -} - -{ #category : #'api - instantiation' } -AlbCursorStencil >> create [ - "Pay attention: a CursorElement ** must be a singleton **. - If not, dbl clicking will not work because the target of the first click may - be different from the one of the second click" - - currentCursorElement ifNotNil: [ - ^ currentCursorElement startBlinkingTask ]. - ^ currentCursorElement := AlbCursorElement new - background: self cursorColor; - startBlinkingTask; - yourself -] - -{ #category : #accessing } -AlbCursorStencil >> currentCursorElement [ - - ^ currentCursorElement -] - -{ #category : #accessing } -AlbCursorStencil >> cursorColor [ - - ^ cursorColor -] - -{ #category : #accessing } -AlbCursorStencil >> cursorColor: aColor [ - - cursorColor := aColor. - currentCursorElement := nil -] - -{ #category : #initialization } -AlbCursorStencil >> initialize [ - - super initialize. - cursorColor := Color red -] diff --git a/src/Album/AlbEditorElement.class.st b/src/Album/AlbEditorElement.class.st index e148085..67de95e 100644 --- a/src/Album/AlbEditorElement.class.st +++ b/src/Album/AlbEditorElement.class.st @@ -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 } diff --git a/src/Album/AlbInfiniteEditorElement.class.st b/src/Album/AlbInfiniteEditorElement.class.st index 1bc13c6..70d4d44 100644 --- a/src/Album/AlbInfiniteEditorElement.class.st +++ b/src/Album/AlbInfiniteEditorElement.class.st @@ -5,7 +5,7 @@ Class { #classTraits : 'TBlLayoutResizable classTrait', #instVars : [ 'mode', - 'cursorStencil', + 'cursorElement', 'wordStencil', 'modeEventHandlers', 'modeShortcuts' @@ -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' } @@ -104,9 +104,9 @@ AlbInfiniteEditorElement >> cursors [ ] { #category : #initialization } -AlbInfiniteEditorElement >> defaultCursorStencil [ - - ^ AlbCursorStencil new +AlbInfiniteEditorElement >> defaultCursorBackground [ + + ^ Color red ] { #category : #initialization } @@ -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 [ diff --git a/src/Album/AlbTextElement.class.st b/src/Album/AlbTextElement.class.st index 1890ed5..05e1537 100644 --- a/src/Album/AlbTextElement.class.st +++ b/src/Album/AlbTextElement.class.st @@ -5,7 +5,7 @@ Class { 'cursorElement', 'segmentPiece' ], - #category : 'Album-UI' + #category : #'Album-UI' } { #category : #'cursor - management' } @@ -14,7 +14,7 @@ AlbTextElement >> addCursorAt: aTextPosition inEditorElement: anEditorElement [ ^ self cursorAt: aTextPosition ifFound: #yourself ifNone: [ cursorElement ifNil: [ - cursorElement := anEditorElement cursorStencil asElement. + cursorElement := anEditorElement cursorElement. cursorElement removeFromParent. self addChild: cursorElement ]. cursorElement textPosition: aTextPosition.