Skip to content

Commit

Permalink
Added TToMouseHandler to gather all mouse related event management
Browse files Browse the repository at this point in the history
  • Loading branch information
plantec committed Jul 27, 2023
1 parent 8286281 commit 08c481c
Show file tree
Hide file tree
Showing 29 changed files with 502 additions and 437 deletions.
10 changes: 4 additions & 6 deletions src/Toplo-LookAndFeel/ToLAFRadioButtonDresser.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #ToLAFRadioButtonDresser,
#superclass : #ToMouseHandlingDresser,
#superclass : #ToWidgetDresser,
#traits : 'TToSkinnableElementDresser',
#classTraits : 'TToSkinnableElementDresser classTrait',
#instVars : [
Expand Down Expand Up @@ -36,7 +36,7 @@ ToLAFRadioButtonDresser >> defaultCheckedIconImage: anElement [
{ #category : #accessing }
ToLAFRadioButtonDresser >> defaultCheckedState [

^ ToWidgetState new
^ ToWidgetStateDep new
name: #checked;
whenEnterDo: [ :ann |
ann widget icon: (self defaultCheckedIconImage: ann widget) ];
Expand All @@ -59,7 +59,7 @@ ToLAFRadioButtonDresser >> defaultIndeterminateIconImage: anElement [
{ #category : #accessing }
ToLAFRadioButtonDresser >> defaultIndeterminateState [

^ ToWidgetState new
^ ToWidgetStateDep new
name: #indeterminate;
whenEnterDo: [ :ann |
ann widget icon: (self defaultIndeterminateIconImage: ann widget) ];
Expand Down Expand Up @@ -88,7 +88,7 @@ ToLAFRadioButtonDresser >> defaultUncheckedIconImage: anElement [
{ #category : #accessing }
ToLAFRadioButtonDresser >> defaultUncheckedState [

^ ToWidgetState new
^ ToWidgetStateDep new
name: #unchecked;
whenEnterDo: [ :ann |
ann widget icon: (self defaultUncheckedIconImage: ann widget) ]
Expand Down Expand Up @@ -121,8 +121,6 @@ ToLAFRadioButtonDresser >> hover: anElement event: anEvent [
{ #category : #accessing }
ToLAFRadioButtonDresser >> initialState: anElement [

super initialState: anElement.

"update main element"
self background: self skin background in: anElement.
self border: self skin border in: anElement.
Expand Down
35 changes: 35 additions & 0 deletions src/Toplo/TToEnableableHandler.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Trait {
#name : #TToEnableableHandler,
#instVars : [
'enabledHandler',
'disabledHandler'
],
#category : #'Toplo-Core'
}

{ #category : #'t - enableable handler - events handling' }
TToEnableableHandler >> disabledEvent: anEvent in: anElement [
]

{ #category : #'t - enableable handler - events handling' }
TToEnableableHandler >> enabledEvent: anEvent in: anElement [
]

{ #category : #'t - enableable handler - install/uninstall hook' }
TToEnableableHandler >> onInstalledEnableableHandlingIn: anElement [

enabledHandler := BlEventHandler on: ToWidgetEnabledEvent do: [ :event | self enabledEvent: event in: anElement ].
disabledHandler := BlEventHandler on: ToWidgetDisabledEvent do: [ :event | self disabledEvent: event in: anElement ].

anElement addEventHandler: enabledHandler.
anElement addEventHandler: disabledHandler
]

{ #category : #'t - enableable handler - install/uninstall hook' }
TToEnableableHandler >> onUninstalledEnableableHandlingIn: anElement [

anElement removeEventHandler: enabledHandler.
anElement removeEventHandler: disabledHandler.
enabledHandler := nil.
disabledHandler := nil
]
115 changes: 115 additions & 0 deletions src/Toplo/TToMouseHandler.trait.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
Trait {
#name : #TToMouseHandler,
#instVars : [
'mouseEventListener'
],
#category : #'Toplo-Core'
}

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> clickEvent: anEvent in: anElement [


]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> doubleClickEvent: anEvent in: anElement [


]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> leftClickEvent: anEvent in: anElement [

]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> leftMouseDownEvent: anEvent in: anElement [

]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> leftMouseUpEvent: anEvent in: anElement [

]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> middleClickEvent: anEvent in: anElement [


]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> middleMouseDownEvent: anEvent in: anElement [

]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> middleMouseUpEvent: anEvent in: anElement [

]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> mouseDownEvent: anEvent in: anElement [

]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> mouseEnterEvent: anEvent in: anElement [
]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> mouseLeaveEvent: anEvent in: anElement [


]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> mouseUpEvent: anEvent in: anElement [


]

{ #category : #'t - mouse handling - install/uninstall hook' }
TToMouseHandler >> onInstalledMouseHandlingIn: anElement [

mouseEventListener := ToDresserMouseEventListener new target: anElement; dresser: self; yourself.
anElement addEventHandler: mouseEventListener
]

{ #category : #'t - mouse handling - install/uninstall hook' }
TToMouseHandler >> onUninstalledMouseHandlingIn: anElement [

anElement removeEventHandler: mouseEventListener.
mouseEventListener := nil

]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> otherClickEvent: anEvent in: anElement [

]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> otherMouseDownEvent: anEvent in: anElement [

]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> otherMouseUpEvent: anEvent in: anElement [

]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> rightClickEvent: anEvent in: anElement [
]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> rightMouseDownEvent: anEvent in: anElement [

]

{ #category : #'t - mouse handling - events handling' }
TToMouseHandler >> rightMouseUpEvent: anEvent in: anElement [

]
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
Class {
#name : #ToAbstractElementLook,
#name : #ToAbstractLook,
#superclass : #Object,
#category : #'Toplo-Core-Theme'
}

{ #category : #'private event handling' }
ToAbstractElementLook >> elementLookEvent: anEvent [
ToAbstractLook >> elementLookEvent: anEvent [

^ self subclassResponsibility
]

{ #category : #'event handling' }
ToAbstractElementLook >> installLookEvent: anEvent [
ToAbstractLook >> installLookEvent: anEvent [


]

{ #category : #testing }
ToAbstractElementLook >> isNull [
ToAbstractLook >> isNull [

^ false
]

{ #category : #removing }
ToAbstractElementLook >> removeLook: aLook previous: previousLook [
ToAbstractLook >> removeLook: aLook previous: previousLook [

self subclassResponsibility
]

{ #category : #'event handling' }
ToAbstractElementLook >> uninstallLookEvent: anEvent [
ToAbstractLook >> uninstallLookEvent: anEvent [


]
2 changes: 1 addition & 1 deletion src/Toplo/ToBackgroundLook.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #ToBackgroundLook,
#superclass : #ToElementLook,
#superclass : #ToDefaultElementLook,
#instVars : [
'initialBg',
'hoverBg',
Expand Down
8 changes: 1 addition & 7 deletions src/Toplo/ToBasicMenuItemDresser.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #ToBasicMenuItemDresser,
#superclass : #ToMouseHandlingDresser,
#superclass : #ToWidgetDresser,
#category : #'Toplo-Widget-Menu'
}

Expand Down Expand Up @@ -44,9 +44,3 @@ ToBasicMenuItemDresser >> onInstalledIn: anElement [
anElement border: BlBorder empty.
anElement padding: (BlInsets top: 0 left: 5 bottom: 0 right: 4 )
]

{ #category : #'api - install/uninstall hook' }
ToBasicMenuItemDresser >> onUninstalledIn: anElement [

super onUninstalledIn: anElement
]
2 changes: 1 addition & 1 deletion src/Toplo/ToBorderLook.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #ToBorderLook,
#superclass : #ToElementLook,
#superclass : #ToDefaultElementLook,
#instVars : [
'builder',
'pressedPaint',
Expand Down
10 changes: 7 additions & 3 deletions src/Toplo/ToButtonSkin.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Class {
#name : #ToButtonSkin,
#superclass : #ToWidgetSkin,
#instVars : [
'type'
'type',
'cursorLook'
],
#category : #'Toplo-Widget-Button-Skins'
}
Expand Down Expand Up @@ -64,16 +65,19 @@ ToButtonSkin >> onSkinInstalledIn: anElement [
" must send to super ** after ** the look is initialize from type "
super onSkinInstalledIn: anElement.
self type onSkinInstalled: self in: anElement.
cursorLook := ToMouseCursorLook new.
cursorLook hoverCursor: [ :but | but isEnabled ifTrue: [ BlCursor hand ] ifFalse: []].
self addLook: cursorLook.


]

{ #category : #'api - install/uninstall hook' }
ToButtonSkin >> onSkinUninstalledIn: anElement [

self type onSkinUninstalled: self in: anElement.
self removeLook: cursorLook.
super onSkinUninstalledIn: anElement


]

{ #category : #accessing }
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo/ToCheckLook.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #ToCheckLook,
#superclass : #ToElementLook,
#superclass : #ToDefaultElementLook,
#instVars : [
'checkedImage',
'indeterminateImage',
Expand Down
53 changes: 53 additions & 0 deletions src/Toplo/ToDefaultElementLook.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Class {
#name : #ToDefaultElementLook,
#superclass : #ToElementLook,
#category : #'Toplo-Core-Theme-Looks'
}

{ #category : #accessing }
ToDefaultElementLook class >> next: aLook [

^ self new next: aLook
]

{ #category : #'event handling' }
ToDefaultElementLook >> clickLookEvent: anEvent [


]

{ #category : #'event handling' }
ToDefaultElementLook >> hoveredLookEvent: anEvent [


]

{ #category : #'event handling' }
ToDefaultElementLook >> initialLookEvent: anEvent [


]

{ #category : #'event handling' }
ToDefaultElementLook >> installLookEvent: anEvent [

super installLookEvent: anEvent
]

{ #category : #'event handling' }
ToDefaultElementLook >> leavedLookEvent: anEvent [


]

{ #category : #'event handling' }
ToDefaultElementLook >> pressedLookEvent: anEvent [


]

{ #category : #'event handling' }
ToDefaultElementLook >> uninstallLookEvent: anEvent [

super uninstallLookEvent: anEvent
]
3 changes: 1 addition & 2 deletions src/Toplo/ToDividerDresser.class.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : #ToDividerDresser,
#superclass : #ToMouseHandlingDresser,
#superclass : #ToWidgetDresser,
#instVars : [
'dividerHandler',
'firstTargetPositionChangeHandler',
Expand Down Expand Up @@ -52,7 +52,6 @@ ToDividerDresser >> hover: anElement event: anEvent [
{ #category : #'api - install/uninstall hook' }
ToDividerDresser >> initialState: anElement [

super initialState: anElement.
anElement thickness: 4.
anElement geometry: (BlRoundedRectangleGeometry cornerRadius: 4).
anElement border: (BlBorder paint: self colorProvider defaultBorderColor).
Expand Down
Loading

0 comments on commit 08c481c

Please sign in to comment.