Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close windows from taskbar thumbnail #17477

Open
wants to merge 2 commits into
base: Pharo13
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions src/Morphic-Widgets-Taskbar/SystemWindow.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,18 @@ SystemWindow >> taskbarButtonClicked [
SystemWindow >> taskbarButtonEntered: aButton event: evt in: aMorph [
"The mouse has entered out taskbar button.
Show a thumbnail."
| taskbar |
taskbar := aButton owner.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!!!


aButton owner ifNotNil: [:buttonBar | |thumb|
taskbar ifNotNil: [:buttonBar | |thumb|
buttonBar showWindowPreview ifFalse: [^self].
thumb := self valueOfProperty: #taskbarThumbnail.
thumb
ifNil: [thumb := self theme newTaskbarThumbnailIn: self for: self]
ifNotNil: [^self].
self setProperty: #taskbarThumbnail toValue: thumb.
thumb bottomLeft: ((aButton left min: aButton owner right - thumb width)@ (aButton owner top - 4)).
thumb := taskbar valueOfProperty: #taskbarThumbnail.
thumb ifNotNil: [
thumb window = self ifTrue: [^self].
thumb delete ].
thumb := self theme newTaskbarThumbnailFor: self taskbarButton: aButton.
taskbar setProperty: #taskbarThumbnail toValue: thumb.
thumb bottomLeft: (aButton left min: taskbar right - thumb width)@ (taskbar top - 4).
thumb openInWorld]
]

Expand All @@ -113,12 +116,6 @@ SystemWindow >> taskbarButtonFor: aTaskbar [
SystemWindow >> taskbarButtonLeft: aButton event: evt in: aMorph [
"The mouse has left our taskbar button.
Remove our thumbnail."

self
valueOfProperty: #taskbarThumbnail
ifPresentDo: [:thumb |
thumb delete.
self removeProperty: #taskbarThumbnail]
]

{ #category : '*Morphic-Widgets-Taskbar' }
Expand Down
138 changes: 138 additions & 0 deletions src/Polymorph-Widgets/TaskbarThumbnailMorph.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
"
I am the helpful little window that appear when you hover a taskbar button. I show a recent screenshot of the window in question and an easy way to close that window.
"
Class {
#name : 'TaskbarThumbnailMorph',
#superclass : 'PanelMorph',
#instVars : [
'window',
'taskbarButton',
'deleteAt',
'taskbar'
],
#category : 'Polymorph-Widgets-Themes',
#package : 'Polymorph-Widgets',
#tag : 'Themes'
}

{ #category : 'instance creation' }
TaskbarThumbnailMorph class >> for: aWindow taskbarButton: aButton theme: aTheme [
^ self new
window: aWindow;
button: aButton;
theme: aTheme;
initializeAppearance;
yourself.
]

{ #category : 'fading' }
TaskbarThumbnailMorph >> aboutToBeDeleted [
deleteAt := DateAndTime now + 150 milliSeconds
]

{ #category : 'accessing' }
TaskbarThumbnailMorph >> button: aButton [
self assert: taskbarButton isNil description: 'Do not change the taskbar button after creation'.
taskbarButton := aButton.
taskbar := aButton owner.

taskbarButton
on: #mouseEnter
send: #isNotBeingDeleted
to: self;

on: #mouseLeave
send: #aboutToBeDeleted
to: self
]

{ #category : 'submorphs - add/remove' }
TaskbarThumbnailMorph >> delete [
"NOTE: We should only remove it if we are the current thumbnail"
taskbar removeProperty: #taskbarThumbnail.
super delete
]

{ #category : 'event handling' }
TaskbarThumbnailMorph >> handlesMouseOver: evt [

^true
]

{ #category : 'initialization' }
TaskbarThumbnailMorph >> initializeAppearance [
| thumb closeButton labelAndButton |
thumb := window taskbarThumbnail.
closeButton := (self theme
newCloseControlIn: window
for: window
action: [window closeBoxHit. self delete]
help: 'Close this window' translated)
extent: window boxExtent.
labelAndButton := PanelMorph new.
labelAndButton
layoutPolicy: RowLayout new;
hResizing: #shrinkWrap;
vResizing: #shrinkWrap;
addMorphBack: closeButton;
addMorphBack: (self theme
buttonLabelForText: (window labelString truncateWithElipsisTo: 50)).
self
hResizing: #shrinkWrap;
vResizing: #shrinkWrap;
changeTableLayout;
layoutInset: 8 scaledByDisplayScaleFactor;
cellInset: 4 scaledByDisplayScaleFactor;
addMorphBack: thumb;
addMorphBack: labelAndButton;
extent: self minExtent;
fillStyle: (self theme taskListFillStyleFor: self);
borderStyle: (self theme taskbarThumbnailNormalBorderStyleFor: self);
cornerStyle: (self theme taskbarThumbnailCornerStyleFor: self).
]

{ #category : 'fading' }
TaskbarThumbnailMorph >> isNotBeingDeleted [
deleteAt := nil
]

{ #category : 'event handling' }
TaskbarThumbnailMorph >> mouseEnter: evt [
self isNotBeingDeleted
]

{ #category : 'event handling' }
TaskbarThumbnailMorph >> mouseLeave: evt [
self aboutToBeDeleted
]

{ #category : 'stepping and presenter' }
TaskbarThumbnailMorph >> step [
deleteAt ifNil: [^self].

(self containsPoint: self activeHand position) ifTrue: [
self isNotBeingDeleted.
^self].

deleteAt < DateAndTime now ifTrue: [self delete]
]

{ #category : 'stepping and presenter' }
TaskbarThumbnailMorph >> stepTime [
^ 50
]

{ #category : 'stepping and presenter' }
TaskbarThumbnailMorph >> wantsSteps [
^ true
]

{ #category : 'accessing' }
TaskbarThumbnailMorph >> window [
^ window
]

{ #category : 'accessing' }
TaskbarThumbnailMorph >> window: aWindow [
window := aWindow
]
21 changes: 2 additions & 19 deletions src/Polymorph-Widgets/UITheme.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3391,27 +3391,10 @@ UITheme >> newTaskbarButtonIn: aTaskbar for: aWindow [
]

{ #category : 'morph creation' }
UITheme >> newTaskbarThumbnailIn: aThemedMorph for: aWindow [
UITheme >> newTaskbarThumbnailFor: aWindow taskbarButton: aButton [
"Answer a taskbar thumbnail morph for the given window."

|answer thumb|
thumb := aWindow taskbarThumbnail.
answer := PanelMorph new
hResizing: #shrinkWrap;
vResizing: #shrinkWrap;
changeTableLayout;
layoutInset: 8 scaledByDisplayScaleFactor;
cellInset: 4 scaledByDisplayScaleFactor;
addMorphBack: thumb;
addMorphBack: ((self
buttonLabelForText: (aWindow labelString truncateWithElipsisTo: 50))
color: Color white).
answer
extent: answer minExtent;
fillStyle: (self taskListFillStyleFor: answer);
borderStyle: (self taskbarThumbnailNormalBorderStyleFor: aWindow);
cornerStyle: (self taskbarThumbnailCornerStyleFor: answer).
^answer
^ TaskbarThumbnailMorph for: aWindow taskbarButton: aButton theme: self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

]

{ #category : 'morph creation' }
Expand Down