Skip to content

Commit

Permalink
ToSkinStateQueue>>enqueueEnablementStateForElement: fixed to enqueue …
Browse files Browse the repository at this point in the history
…an EnablementState befor other intrinsic states in case the target element is enabled.

No list selection with the pointer in case the target list is disabled
ToSkinStateGenerator do not generate states in case the target is disabled
  • Loading branch information
plantec committed Sep 25, 2024
1 parent 2a26801 commit 9cb5b2e
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 31 deletions.
3 changes: 2 additions & 1 deletion src/Toplo-Widget-Album/ToLabelSkin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ ToLabelSkin >> selectedSkinEvent: anEvent [
ifTrue: [ #'label-selected-focused' ]
ifFalse: [ #'label-selected-unfocused' ].
to := e valueOfTokenNamed: tokname.
e foreground: to ]
e foreground: to.
e applyStyle ]
]
16 changes: 11 additions & 5 deletions src/Toplo-Widget-List/ToListNodeSelectionEventHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ToListNodeSelectionEventHandler >> clickEvent: anEvent [
| node listElement mode |
node := anEvent currentTarget.
listElement := node holder listElement.
listElement isEnabled ifFalse: [ ^ self ].
mode := listElement primarySelectionMode.
mode selectOnMouseDown ifTrue: [ ^ self ].
self notifyClickOnNodeFromEvent: anEvent.
Expand Down Expand Up @@ -47,11 +48,16 @@ ToListNodeSelectionEventHandler >> listClickOnNodeRequestEvent: aListClickOnNode
{ #category : #'mouse handlers' }
ToListNodeSelectionEventHandler >> mouseDownEvent: anEvent [

anEvent
ifPrimary: [ self primaryMouseDownEvent: anEvent ]
secondary: [ ]
middle: [ ]
other: [ ]
| node listElement |
node := anEvent currentTarget.
listElement := node holder listElement.
listElement isEnabled ifFalse: [ ^ self ].

anEvent
ifPrimary: [ self primaryMouseDownEvent: anEvent ]
secondary: [ ]
middle: [ ]
other: [ ]
]

{ #category : #'mouse handlers' }
Expand Down
56 changes: 37 additions & 19 deletions src/Toplo-Widget-List/ToListPrimarySelectionElementSkin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,27 @@ Class {
}

{ #category : #'event handling' }
ToListPrimarySelectionElementSkin >> focusedSkinEvent: anEvent [
ToListPrimarySelectionElementSkin >> disabledSkinEvent: anEvent [

super focusedSkinEvent: anEvent.
super disabledSkinEvent: anEvent.
anEvent elementDo: [ :e |
e isBeneath
ifTrue: [
e background:
(e valueOfTokenNamed: #'color-primary-selection-focused') ]
ifFalse: [
e background:
(e valueOfTokenNamed: #'color-primary-selection-over-focused') ] ]
e border: (BlBorder
paint: (e valueOfTokenNamed: #'color-primary-selection-disabled')
width: (e valueOfTokenNamed: #'border-width-primary-selection')).
e background: BlBackground transparent ]
]

{ #category : #'event handling' }
ToListPrimarySelectionElementSkin >> installSkinEvent: anEvent [
ToListPrimarySelectionElementSkin >> enabledSkinEvent: anEvent [

super installSkinEvent: anEvent.
super enabledSkinEvent: anEvent.
anEvent elementDo: [ :e |

e geometry: (BlRoundedRectangleGeometry cornerRadius:
(e valueOfTokenNamed: #'border-radius-SM')).

e selectionOption isGrouped ifTrue: [
e border: (BlBorder
paint: (e valueOfTokenNamed: #'border-color-primary-selection')
width: (e valueOfTokenNamed: #'border-width-primary-selection')) ].
e selectionOption isGrouped
ifTrue: [
e border: (BlBorder
paint: (e valueOfTokenNamed: #'border-color-primary-selection')
width: (e valueOfTokenNamed: #'border-width-primary-selection')) ]
ifFalse: [ e border: BlBorder empty ].

" I must take into account the focused state of the node container element
here to start with the right background "
Expand All @@ -53,6 +48,29 @@ ToListPrimarySelectionElementSkin >> installSkinEvent: anEvent [
(e valueOfTokenNamed: #'color-primary-selection-over-unfocused') ] ] ]
]

{ #category : #'event handling' }
ToListPrimarySelectionElementSkin >> focusedSkinEvent: anEvent [

super focusedSkinEvent: anEvent.
anEvent elementDo: [ :e |
e isBeneath
ifTrue: [
e background:
(e valueOfTokenNamed: #'color-primary-selection-focused') ]
ifFalse: [
e background:
(e valueOfTokenNamed: #'color-primary-selection-over-focused') ] ]
]

{ #category : #'event handling' }
ToListPrimarySelectionElementSkin >> installSkinEvent: anEvent [

super installSkinEvent: anEvent.
anEvent elementDo: [ :e |
e geometry: (BlRoundedRectangleGeometry cornerRadius:
(e valueOfTokenNamed: #'border-radius-SM')) ]
]

{ #category : #'event handling' }
ToListPrimarySelectionElementSkin >> unfocusedSkinEvent: anEvent [

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ ToListSecondarySelectionElementEventHandler >> mouseMoveEvent: anEvent [
| target nodeContainer globalPosition childNode |
anEvent anyButtonPressed ifTrue: [ ^ self ].
target := anEvent currentTarget.
target isEnabled ifFalse: [ ^ self ].
nodeContainer := target innerContainer.
globalPosition := anEvent position.

Expand Down
17 changes: 17 additions & 0 deletions src/Toplo/ToSkinStateGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Class {
{ #category : #'focus events handling' }
ToSkinStateGenerator >> blurEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
self generateBlurStateFromEvent: anEvent
]

Expand All @@ -28,6 +29,7 @@ ToSkinStateGenerator >> checkableCheckEvent: anEvent [
{ #category : #'mouse handlers' }
ToSkinStateGenerator >> clickEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
anEvent
ifPrimary: [ self primaryClickEvent: anEvent ]
secondary: [ ]
Expand All @@ -38,6 +40,7 @@ ToSkinStateGenerator >> clickEvent: anEvent [
{ #category : #'dnd handlers' }
ToSkinStateGenerator >> dragEndEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
self dragged: false.
self leaved ifTrue: [ ^ self ].
self leaved: true.
Expand All @@ -50,25 +53,29 @@ ToSkinStateGenerator >> dragEndEvent: anEvent [
{ #category : #'dnd handlers' }
ToSkinStateGenerator >> dragEnterEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
self leaved: false
]

{ #category : #'dnd handlers' }
ToSkinStateGenerator >> dragEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
self dragged ifFalse: [ ^ self ].
self generateDraggedStateFromEvent: anEvent
]

{ #category : #'dnd handlers' }
ToSkinStateGenerator >> dragLeaveEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
self leaved: true
]

{ #category : #'dnd handlers' }
ToSkinStateGenerator >> dragStartEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
self dragged: true.
self generateDragStartedStateFromEvent: anEvent
]
Expand All @@ -88,6 +95,7 @@ ToSkinStateGenerator >> dragged: aBoolean [
{ #category : #'dnd handlers' }
ToSkinStateGenerator >> dropEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
self generateDroppedStateFromEvent: anEvent
]

Expand Down Expand Up @@ -123,12 +131,14 @@ ToSkinStateGenerator >> eventsToHandle [
{ #category : #'focus events handling' }
ToSkinStateGenerator >> focusEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
self generateFocusStateFromEvent: anEvent
]

{ #category : #'state generating' }
ToSkinStateGenerator >> generateBlurStateFromEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
target skinManagerDo: [ :sm |
sm
addSkinStateGeneration: [
Expand Down Expand Up @@ -337,6 +347,7 @@ ToSkinStateGenerator >> listNodeSelectedEvent: anEvent [
{ #category : #'mouse handlers' }
ToSkinStateGenerator >> mouseDownEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
anEvent
ifPrimary: [ self primaryMouseDownEvent: anEvent ]
secondary: [ ]
Expand All @@ -347,6 +358,7 @@ ToSkinStateGenerator >> mouseDownEvent: anEvent [
{ #category : #'mouse handlers' }
ToSkinStateGenerator >> mouseEnterEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
self leaved: false.
self dragged ifTrue: [ ^ self ].
target isEnabled ifFalse: [ ^ self ].
Expand All @@ -357,6 +369,7 @@ ToSkinStateGenerator >> mouseEnterEvent: anEvent [
{ #category : #'mouse handlers' }
ToSkinStateGenerator >> mouseLeaveEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
self dragged ifTrue: [ ^ self ].
self leaved ifTrue: [ ^ self ].
self leaved: true.
Expand All @@ -367,6 +380,7 @@ ToSkinStateGenerator >> mouseLeaveEvent: anEvent [
{ #category : #'mouse handlers' }
ToSkinStateGenerator >> mouseUpEvent: anEvent [

target isEnabled ifFalse: [ ^ self ].
anEvent
ifPrimary: [ self primaryMouseUpEvent: anEvent ]
secondary: [ ]
Expand All @@ -380,6 +394,7 @@ ToSkinStateGenerator >> mouseUpOutsideEvent: anEvent [
In that case, no action is triggered "

| wasPressed |
target isEnabled ifFalse: [ ^ self ].
wasPressed := self pressed.
self pressed: false.
self dragged: false.
Expand Down Expand Up @@ -457,6 +472,7 @@ ToSkinStateGenerator >> startStillHoveredEvent: anEvent [

| startDelay space |
target ifNil: [ ^ self ].
target isEnabled ifFalse: [ ^ self ].
target space ifNil: [ ^ self ].
space := target space.
startDelay := target stillHoveredStartDelay.
Expand All @@ -478,6 +494,7 @@ ToSkinStateGenerator >> startStillPressedEvent: anEvent [

| startDelay space targetPos |
target space ifNil: [ ^ self ].
target isEnabled ifFalse: [ ^ self ].
space := target space.
startDelay := target stillPressedStartDelay.
startDelay ifNil: [ ^ self ].
Expand Down
18 changes: 12 additions & 6 deletions src/Toplo/ToSkinStateQueue.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,22 @@ ToSkinStateQueue >> applyOn: anElement [

{ #category : #adding }
ToSkinStateQueue >> enqueueEnablementStateForElement: anElement [

" restitute the intrasic states (as enablement, check)
enablement state must always be the last one to be enqueued "
enablement state must always be the first one for an enabled element,
it must be the last one to be enqueued for a disabled element "

anElement isEnabled ifTrue: [
self
enqueueState: (ToEnablementState new enabled: true)
for: anElement ].

self intrinsicStatesDo: [ :state |
self enqueueState: state for: anElement ].
self
enqueueState: (ToEnablementState new enabled: anElement isEnabled)
for: anElement.


anElement isEnabled ifFalse: [
self
enqueueState: (ToEnablementState new enabled: false)
for: anElement ]
]

{ #category : #adding }
Expand Down

0 comments on commit 9cb5b2e

Please sign in to comment.