Skip to content

Commit 09f40b6

Browse files
committed
Use taskbarTask as model for the morph and so re-enable icon in the toolbar
1 parent 3374ab6 commit 09f40b6

File tree

4 files changed

+39
-10
lines changed

4 files changed

+39
-10
lines changed

src/Morphic-Widgets-Taskbar/TaskbarItemMorph.class.st

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ TaskbarItemMorph >> initialize [
5252
{ #category : 'initialization' }
5353
TaskbarItemMorph >> initializeAnnouncements [
5454
self
55-
on: #mouseEnter send: #taskbarButtonEntered:event:in: to: self model withValue: self;
56-
on: #mouseLeave send: #taskbarButtonLeft:event:in: to: self model withValue: self
55+
on: #mouseEnter send: #taskbarButtonEntered:event:in: to: self model morph withValue: self;
56+
on: #mouseLeave send: #taskbarButtonLeft:event:in: to: self model morph withValue: self
5757
]
5858

5959
{ #category : 'initialization' }
@@ -65,7 +65,7 @@ TaskbarItemMorph >> initializeFor: aTaskbar [
6565
lm := self theme
6666
newRowIn: aTaskbar
6767
for:
68-
{((self iconFormSetNamed: self model taskbarIconName) ifNil: [ ^ nil ]) asMorph.
68+
{(self model icon ifNil: [ ^ nil ]) asMorph.
6969
lab}.
7070
lm cellInset: 2.
7171
self
@@ -78,14 +78,14 @@ TaskbarItemMorph >> initializeFor: aTaskbar [
7878
self initializeAnnouncements.
7979
lab
8080
color:
81-
(self model isCollapsed
81+
(self model state = #minimized
8282
ifTrue: [ self theme taskbarItemLabelColorForCollapsed: self ]
8383
ifFalse: [ self theme taskbarItemLabelColorForExpanded: self ])
8484
]
8585

8686
{ #category : 'accessing' }
8787
TaskbarItemMorph >> labelOfSize: labSize [
88-
^ self theme buttonLabelForText: (self model taskbarLabel truncateWithElipsisTo: labSize)
88+
^ self theme buttonLabelForText: (self model label truncateWithElipsisTo: labSize)
8989
]
9090

9191
{ #category : 'accessing' }
@@ -121,6 +121,23 @@ TaskbarItemMorph >> normalFillStyle [
121121
^ self theme taskbarItemNormalFillStyleFor: self
122122
]
123123

124+
{ #category : 'accessing' }
125+
TaskbarItemMorph >> performAction: event [
126+
"Inform the model that this button has been pressed. Sent by the controller when this button is pressed. If the button's actionSelector takes any arguments, they are obtained dynamically by sending the argumentSelector to the argumentsProvider"
127+
128+
enabled ifFalse: [ ^ self ].
129+
askBeforeChanging ifTrue: [
130+
model morph okToChange ifFalse: [ ^ self ] ].
131+
self actionBlock ifNotNil: [ ^ self actionBlock cull: event ].
132+
actionSelector ifNotNil: [
133+
actionSelector numArgs = 0
134+
ifTrue: [ model morph perform: actionSelector ]
135+
ifFalse: [
136+
argumentsProvider ifNotNil: [
137+
arguments := argumentsProvider perform: argumentsSelector ].
138+
model morph perform: actionSelector withArguments: arguments ] ]
139+
]
140+
124141
{ #category : 'style - border' }
125142
TaskbarItemMorph >> pressedBorderStyle [
126143
"Return the pressed borderStyle of the receiver."

src/Morphic-Widgets-Taskbar/TaskbarTask.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ TaskbarTask >> taskListButtonFor: aTasklist [
144144
TaskbarTask >> taskbarButtonFor: aTaskBar [
145145
"Answer a button for the task."
146146

147-
^self morph taskbarButtonFor: aTaskBar
147+
^ aTaskBar theme newTaskbarButtonIn: aTaskBar forTask: self
148148
]
149149

150150
{ #category : 'accessing' }

src/Polymorph-Widgets/Object.extension.st

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ Object >> systemIconName [
4242
]
4343

4444
{ #category : '*Polymorph-Widgets' }
45-
Object >> taskbarLabel [
45+
Object class >> taskbarLabel [
4646
"Answer the label string for the receiver in a task bar
4747
or nil for the default."
4848

49-
^self class taskbarLabel
49+
^nil
5050
]
5151

5252
{ #category : '*Polymorph-Widgets' }
53-
Object class >> taskbarLabel [
53+
Object >> taskbarLabel [
5454
"Answer the label string for the receiver in a task bar
5555
or nil for the default."
5656

57-
^nil
57+
^self class taskbarLabel
5858
]

src/Polymorph-Widgets/UITheme.class.st

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3406,6 +3406,18 @@ UITheme >> newTaskbarButtonIn: aTaskbar for: aWindow [
34063406
yourself
34073407
]
34083408

3409+
{ #category : 'morph creation' }
3410+
UITheme >> newTaskbarButtonIn: aTaskbar forTask: aTaskbarTask [
3411+
"Answer a taskbar button morph for the given window."
3412+
3413+
^ (TaskbarItemMorph
3414+
on: aTaskbarTask
3415+
getState: #isActive
3416+
action: #taskbarButtonClicked)
3417+
initializeFor: aTaskbar;
3418+
yourself
3419+
]
3420+
34093421
{ #category : 'morph creation' }
34103422
UITheme >> newTaskbarThumbnailIn: aThemedMorph for: aWindow [
34113423
"Answer a taskbar thumbnail morph for the given window."

0 commit comments

Comments
 (0)