Skip to content

Commit

Permalink
introduced ToElementState
Browse files Browse the repository at this point in the history
fixed MouseUpOutside users
  • Loading branch information
plantec committed Jul 17, 2023
1 parent 5037261 commit ec8fc03
Show file tree
Hide file tree
Showing 36 changed files with 365 additions and 335 deletions.
35 changes: 35 additions & 0 deletions src/Toplo-Incubator/ToNotebookExamples.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Class {
#name : #ToNotebookExamples,
#superclass : #Object,
#category : #'Toplo-Incubator'
}

{ #category : #tabs }
ToNotebookExamples class >> example_tabsWith2Pages [

| aNotebook redPage greenPage redCount greenCount |
aNotebook := ToNotebook new.

redCount := 0.
redPage := aNotebook addPageTitle: 'Red' bodyFactory: [
redCount := redCount + 1.
BlTextElement new
text:
(redCount asRopedText foreground: Color red darker);
yourself ].

greenCount := 0.
greenPage := aNotebook addPageTitle: 'Green' bodyFactory: [
greenCount := greenCount + 1.
BlTextElement new
text:
(greenCount asRopedText foreground:
Color green muchDarker);
yourself ].

aNotebook openInSpace
]

{ #category : #'see class side' }
ToNotebookExamples >> seeClassSide [
]
32 changes: 16 additions & 16 deletions src/Toplo/ToBackgroundLook.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ ToBackgroundLook >> hoverBg: aBackground [
hoverBg := aBackground
]

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

super hoveredLookEvent: anEvent.
anEvent elementDo: [ :e |
self hoverBg ifNotNil: [ :bg | e background: bg ] ]
]

{ #category : #accessing }
ToBackgroundLook >> initialBg [

Expand All @@ -41,22 +49,6 @@ ToBackgroundLook >> initialLookEvent: anEvent [
self initialBg ifNotNil: [ :bg | e background: bg ] ]
]

{ #category : #'event handling' }
ToBackgroundLook >> mouseHoverLookEvent: anEvent [

super mouseHoverLookEvent: anEvent.
anEvent elementDo: [ :e |
self hoverBg ifNotNil: [ :bg | e background: bg ] ]
]

{ #category : #'event handling' }
ToBackgroundLook >> mousePressedLookEvent: anEvent [

super mousePressedLookEvent: anEvent.
anEvent elementDo: [ :e |
self pressedBg ifNotNil: [ :bg | e background: bg ] ]
]

{ #category : #accessing }
ToBackgroundLook >> pressedBg [

Expand All @@ -68,3 +60,11 @@ ToBackgroundLook >> pressedBg: aBackground [

pressedBg := aBackground
]

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

super pressedLookEvent: anEvent.
anEvent elementDo: [ :e |
self pressedBg ifNotNil: [ :bg | e background: bg ] ]
]
26 changes: 13 additions & 13 deletions src/Toplo/ToBorderLook.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ ToBorderLook >> hoverPaint: aPaint [
hoverPaint := aPaint
]

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

super hoveredLookEvent: anEvent.
self hoverPaint ifNil: [ ^ self ].
anEvent elementDo: [ :e |
e border: (self builder
paint: self hoverPaint;
build) ]
]

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

Expand Down Expand Up @@ -99,20 +110,9 @@ ToBorderLook >> initialize [
]

{ #category : #'event handling' }
ToBorderLook >> mouseHoverLookEvent: anEvent [

super mouseHoverLookEvent: anEvent.
self hoverPaint ifNil: [ ^ self ].
anEvent elementDo: [ :e |
e border: (self builder
paint: self hoverPaint;
build) ]
]

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

super mousePressedLookEvent: anEvent.
super pressedLookEvent: anEvent.
self pressedPaint ifNil: [ ^ self ].
anEvent elementDo: [ :e |
e border: (self builder
Expand Down
6 changes: 3 additions & 3 deletions src/Toplo/ToCheckBoxDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ToCheckBoxDresser >> defaultCheckedIconImage [
{ #category : #initialization }
ToCheckBoxDresser >> defaultCheckedState [

^ ToElementState new
^ ToElementStateDep new
name: #checked;
whenEnterDo: [ :ann |
ann widget icon: self defaultCheckedIconImage.
Expand Down Expand Up @@ -85,7 +85,7 @@ ToCheckBoxDresser >> defaultIndeterminateIconImage [
{ #category : #initialization }
ToCheckBoxDresser >> defaultIndeterminateState [

^ ToElementState new
^ ToElementStateDep new
name: #indeterminate;
whenEnterDo: [ :ann |
ann widget icon: self defaultIndeterminateIconImage ];
Expand All @@ -107,7 +107,7 @@ ToCheckBoxDresser >> defaultUncheckedIconImage [
{ #category : #initialization }
ToCheckBoxDresser >> defaultUncheckedState [

^ ToElementState new
^ ToElementStateDep new
name: #unchecked;
whenEnterDo: [ :ann |
ann widget icon: self defaultUncheckedIconImage ]
Expand Down
6 changes: 3 additions & 3 deletions src/Toplo/ToCheckNodeDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ToCheckNodeDresser >> defaultCheckedIconImage [
{ #category : #initialization }
ToCheckNodeDresser >> defaultCheckedState [

^ ToElementState new
^ ToElementStateDep new
name: #checked;
whenEnterDo: [ :ann |
ann widget icon: self defaultCheckedIconImage.
Expand Down Expand Up @@ -87,7 +87,7 @@ ToCheckNodeDresser >> defaultIndeterminateIconImage [
{ #category : #initialization }
ToCheckNodeDresser >> defaultIndeterminateState [

^ ToElementState new
^ ToElementStateDep new
name: #indeterminate;
whenEnterDo: [ :ann |
ann widget icon: self defaultIndeterminateIconImage ];
Expand All @@ -109,7 +109,7 @@ ToCheckNodeDresser >> defaultUncheckedIconImage [
{ #category : #initialization }
ToCheckNodeDresser >> defaultUncheckedState [

^ ToElementState new
^ ToElementStateDep new
name: #unchecked;
whenEnterDo: [ :ann |
ann widget icon: self defaultUncheckedIconImage ]
Expand Down
4 changes: 2 additions & 2 deletions src/Toplo/ToChoiceBoxMenuItemDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ToChoiceBoxMenuItemDresser >> defaultCheckedIconImage [
{ #category : #initialization }
ToChoiceBoxMenuItemDresser >> defaultCheckedState [

^ ToElementState new
^ ToElementStateDep new
name: #checked;
whenEnterDo: [ :ann |
ann widget icon: (ToImage inner: self defaultCheckedIconImage) ];
Expand All @@ -31,7 +31,7 @@ ToChoiceBoxMenuItemDresser >> defaultUncheckedIconImage [
{ #category : #initialization }
ToChoiceBoxMenuItemDresser >> defaultUncheckedState [

^ ToElementState new
^ ToElementStateDep new
name: #unchecked;
whenEnterDo: [ :ann |
ann widget icon: (ToImage inner: self defaultUncheckedIconImage) ]
Expand Down
2 changes: 1 addition & 1 deletion src/Toplo/ToContextMenuDresser.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class {
ToContextMenuDresser >> mouseUpOutside: anEvent in: aMenuWindow [

| origEventTarget |
origEventTarget := anEvent originalEvent currentTarget.
origEventTarget := anEvent originalEvent target.
origEventTarget ifNil: [
^ super mouseUpOutside: anEvent in: aMenuWindow ].
(origEventTarget hasInParentChain: aMenuWindow widget) ifTrue: [
Expand Down
11 changes: 0 additions & 11 deletions src/Toplo/ToDisableLookEvent.class.st

This file was deleted.

11 changes: 11 additions & 0 deletions src/Toplo/ToDisabledState.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Class {
#name : #ToDisabledState,
#superclass : #ToElementState,
#category : #'Toplo-Core-Theme-States'
}

{ #category : #'look event sending' }
ToDisabledState >> sendEvent: anEvent toLook: aLook [

aLook disabledLookEvent: anEvent
]
26 changes: 13 additions & 13 deletions src/Toplo/ToElementLook.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,30 @@ ToElementLook >> elementLookEvent: anEvent [
]

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


]

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

]
ToElementLook >> initialLookEvent: anEvent [

{ #category : #testing }
ToElementLook >> isNull [

^ false
]

{ #category : #'event handling' }
ToElementLook >> mouseHoverLookEvent: anEvent [

ToElementLook >> installLookEvent: anEvent [

]

{ #category : #'event handling' }
ToElementLook >> mouseLeavedLookEvent: anEvent [

{ #category : #testing }
ToElementLook >> isNull [

^ false
]

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


]
Expand All @@ -74,6 +68,12 @@ ToElementLook >> next: aLook [
next := aLook
]

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


]

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

Expand Down
4 changes: 2 additions & 2 deletions src/Toplo/ToElementLookEventHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ToElementLookEventHandler >> addLook: aLook [
ToElementLookEventHandler >> elementAddedToSceneGraphEvent: anEvent [

anEvent target dispatchEvent: (ToInstallLookEvent new copyFrom: anEvent).
anEvent target dispatchEvent: (ToInitialLookEvent new copyFrom: anEvent)
anEvent target dispatchEvent: ((ToElementStateChangedEvent new state: ToInitialState new) copyFrom: anEvent)
]

{ #category : #'event handling' }
Expand Down Expand Up @@ -86,6 +86,6 @@ ToElementLookEventHandler >> themeChanged: anEvent in: anElement [

anEvent target dispatchEvent: (ToUninstallLookEvent new copyFrom: anEvent).
anEvent target dispatchEvent: (ToInstallLookEvent new copyFrom: anEvent).
anEvent target dispatchEvent: (ToInitialLookEvent new copyFrom: anEvent).
anEvent target dispatchEvent: ((ToElementStateChangedEvent new state: ToInitialState new) copyFrom: anEvent).
anEvent target dispatchEvent: lastEvent clone
]
14 changes: 0 additions & 14 deletions src/Toplo/ToElementMouseRelatedLookEvent.class.st

This file was deleted.

Loading

0 comments on commit ec8fc03

Please sign in to comment.