Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jonashering committed Aug 3, 2017
1 parent 60a7111 commit bea8fbf
Show file tree
Hide file tree
Showing 99 changed files with 327 additions and 313 deletions.
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
*WindowAcrobatics-Core-Events-override
filterEvent: mouseOrKeyboardEvent for: anObject
filterEvent: aKeyboardEvent for: anObject
"Provide keyboard shortcuts."

"1) Mouse shortcuts"
mouseOrKeyboardEvent isMouse ifTrue: [
"Delegate keyboard shortcuts to my docking bars."
self submorphsDo: [:ea | ea isDockingBar ifTrue: [
ea filterEvent: aKeyboardEvent for: anObject. "No support for converting events here!"
aKeyboardEvent wasIgnored ifTrue: [^ aKeyboardEvent "early out"]]].

"Only accept mouse down, no up."
mouseOrKeyboardEvent isMouseDown
ifFalse: [^ mouseOrKeyboardEvent].

mouseOrKeyboardEvent blueButtonPressed
ifTrue: [ self tryInvokeHalo: mouseOrKeyboardEvent]
ifFalse: [mouseOrKeyboardEvent controlKeyPressed
ifTrue: [self tryInvokeMetaMenu: mouseOrKeyboardEvent]].

^ mouseOrKeyboardEvent].

"2) Keyboard shortcuts"
mouseOrKeyboardEvent isKeyboard ifTrue: [

"Delegate keyboard shortcuts to my docking bars."
self submorphsDo: [:ea | ea isDockingBar ifTrue: [
ea filterEvent: mouseOrKeyboardEvent for: anObject. "No support for converting events here!"
mouseOrKeyboardEvent wasIgnored ifTrue: [^ mouseOrKeyboardEvent "early out"]]].

"Only accept key strokes as shortcuts, no down/up."
mouseOrKeyboardEvent isKeystroke
ifFalse: [^ mouseOrKeyboardEvent].

"Window Acrobatics Key Handling"
mouseOrKeyboardEvent commandKeyPressed ifTrue: [
(WAHandler handle: mouseOrKeyboardEvent) ifTrue: [^ mouseOrKeyboardEvent ignore "hit!"].
aKeyboardEvent isKeystroke
ifFalse: [^ aKeyboardEvent].

aKeyboardEvent commandKeyPressed ifTrue: [
(WAHandler new handle: aKeyboardEvent) ifTrue: [^ aKeyboardEvent ignore "hit!"].
].

self tryInvokeKeyboardShortcut: mouseOrKeyboardEvent.

^ mouseOrKeyboardEvent].

"Should not be necessary if this filter is correctly configured."
^ mouseOrKeyboardEvent
aKeyboardEvent commandKeyPressed ifTrue: [
aKeyboardEvent keyCharacter caseOf: {
[$R] -> [Utilities browseRecentSubmissions. Transcript show: 'Hello'].
[$L] -> [self findAFileList: aKeyboardEvent].
[$O] -> [self findAMonticelloBrowser].
[$P] -> [self findAPreferencesPanel: aKeyboardEvent].
"[$Z] -> [ChangeList browseRecentLog]."
[$]] -> [Smalltalk snapshot: true andQuit: false].
[$+] -> [Preferences increaseFontSize].
[$-] -> [Preferences decreaseFontSize].
[$=] -> [Preferences restoreDefaultFonts].
} otherwise: [^ aKeyboardEvent "no hit"].

^ aKeyboardEvent ignore "hit!"].

^ aKeyboardEvent "no hit"
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"class" : {
},
"instance" : {
"filterEvent:for:" : "adz 7/25/2017 12:01" } }
"filterEvent:for:" : "jh 8/3/2017 14:20" } }
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ handling
alignKeyWindowAt: aPosition with: anExtent

self windowsInCurrentSpace
ifNotEmpty: [ (self windowsInCurrentSpace at: 1) position: aPosition; extent: anExtent].
ifNotEmpty: [ (self windowsInCurrentSpace first) position: aPosition; extent: anExtent].
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ util
heightOfDockingBar

(ActiveWorld submorphs select: [ :window | window isDockingBar ])
ifNotEmpty: [ ^ ((ActiveWorld submorphs select: [ :window | window isDockingBar ]) at: 1) height ]
ifNotEmpty: [ ^ ((ActiveWorld submorphs select: [ :window | window isDockingBar ]) first) height ]
ifEmpty: [ ^ 0 ].


Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
util
windowsInCurrentSpace

^ ActiveWorld submorphs select: [ :w | w isSystemWindow and: w position x >= 0 and: w position x < ActiveWorld extent x ]
^ ActiveWorld submorphs select: [ :w | w isSystemWindow and: [ w position x between: 0 and: ActiveWorld extent x ]]
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
},
"instance" : {
"align:" : "jh 8/3/2017 11:01",
"alignKeyWindowAt:with:" : "jh 8/3/2017 10:51",
"alignKeyWindowAt:with:" : "jh 8/3/2017 13:06",
"alignLastFourWindows" : "jh 8/3/2017 10:52",
"alignLastSixWindows" : "jh 8/3/2017 10:52",
"alignLastTwoWindows" : "jh 8/3/2017 10:52",
"alignLastUsedWindows:" : "jh 8/3/2017 10:55",
"heightOfDockingBar" : "jh 8/3/2017 11:03",
"heightOfDockingBar" : "jh 8/3/2017 13:10",
"initialize" : "jh 8/3/2017 11:01",
"windowExtents" : "jh 8/3/2017 11:01",
"windowPositions" : "jh 8/3/2017 11:01",
"windowsInCurrentSpace" : "jh 8/3/2017 10:51" } }
"windowsInCurrentSpace" : "jh 8/3/2017 13:15" } }
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
visualization
addNumberToVisualization: aNumber colored: aColor

self visualization addMorphBack: (StringMorph new contents: aNumber asString;
self visualization addMorphBack:
(StringMorph new
contents: aNumber asString;
color: aColor;
font: (StrikeFont familyName: 'ComicSansMS' pointSize: 36 emphasized: 1)).
font: self defaultFont).
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pages
addThumbnailsToCurrentPage

(self pageDict at: self currentPage) do: [:thmb | self addMorphBack: thmb].
(self pageDict at: self currentPage) do: [ :thmb | self addMorphBack: thmb ].
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
visualization
changePageVisualizationTo: aColor

(self visualization submorphs at: self currentPage) color: aColor.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults
defaultFont

^ StrikeFont familyName: 'ComicSansMS' pointSize: 36 emphasized: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults
defaultInstructionMessage

^ 'Hit [Esc] to close. Use ArrowUp and ArrowDown to navigate between the pages'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults
defaultInstructionMessagePosition

^ 10 @ 10
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
visualization
defaultVisualizationExtent

^ 45@ActiveWorld extent y.
^ 45 @ ActiveWorld height
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
visualization
defaultVisualizationPosition

^ ActiveWorld extent x - 45 @ 0.
^ ActiveWorld width - 45 @ 0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pages
deleteThumbnailsOnCurrentPage

self thumbnailsOnPage do: [:thmb|thmb delete].
self thumbnailsOnPage do: [ :thmb | thmb delete ].
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ drawOn: aCanvas

super drawOn: aCanvas.
aCanvas
drawString: 'Hit [Esc] to close. Hit $x to close the selected window. Use ArrowUp and ArrowDown to navigate between the pages'
at: 10@10
drawString: self defaultInstructionMessage
at: self defaultInstructionMessagePosition
font: Preferences standardDefaultTextFont
color: Color white.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pages
firstPage

^ self currentPage <= 1.
^ self currentPage <= 1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ pages
nextPage

self lastPage ifFalse: [

self deleteThumbnailsOnCurrentPage.

self equatePageInVisualization.

self currentPage: self currentPage + 1.

self addThumbnailsToCurrentPage.

self selectWindow: (self pageDict at: self currentPage) first.

self highlightPageInVisualiszation.

self updateLayout.
self
deleteThumbnailsOnCurrentPage;
changePageVisualizationTo: Color gray;
currentPage: (self currentPage + 1);
addThumbnailsToCurrentPage;
selectWindow: ((self pageDict at: self currentPage) first);
changePageVisualizationTo: Color white;
updateLayout.
].

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
accessing
numberOfWindowsOnPage: anObject

numberOfWindowsOnPage := anObject
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ pages
previousPage

self firstPage ifFalse: [

self thumbnailsOnPage ifNotEmpty: [self deleteThumbnailsOnCurrentPage. self equatePageInVisualization].

self currentPage: self currentPage - 1.

self addThumbnailsToCurrentPage.

self selectWindow: (self pageDict at: self currentPage) last.

self highlightPageInVisualiszation.

self updateLayout.
self thumbnailsOnPage
ifNotEmpty: [self deleteThumbnailsOnCurrentPage; changePageVisualizationTo: Color gray].
self
currentPage: (self currentPage - 1);
addThumbnailsToCurrentPage;
selectWindow: ((self pageDict at: self currentPage) last);
changePageVisualizationTo: Color white;
updateLayout.
].
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ selectNextWindow

self thumbnailsOnPage ifNotEmpty: [
self selectWindow: (self thumbnailsOnPage atWrap: (self thumbnailsOnPage indexOf: self selectedWindow) + 1)
]
].
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ selectPreviousWindow

self thumbnailsOnPage ifNotEmpty: [
self selectWindow: (self thumbnailsOnPage atWrap: (self thumbnailsOnPage indexOf: self selectedWindow) - 1)
]
].
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ windows-handling
selectWindow: thumbnail

thumbnail ifNotNil: [
selectionRectangle bounds: (thumbnail bounds outsetBy: (6@43 corner: 6@6))].
selectionRectangle bounds: (thumbnail bounds outsetBy: self selectionRectancleOutset) ].
selectionRectangle setProperty: #target toValue: thumbnail.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults
selectionRectancleOutset

^ 6 @ 43 corner: 6 @ 6
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ setVisualizationLayout
listDirection: #topToBottom;
listCentering: #center;
layoutInset: 20;
cellInset: 10.
cellInset: 10
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pages
thumbnailsOnPage

^ self submorphs copyWithout: selectionRectangle.
^ self submorphs copyWithout: selectionRectangle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pages
windowFromNextPage: aNumber

aNumber > self numberPages ifTrue: [(self pageDict at: aNumber - 1) isEmpty ifTrue: [self pageDict removeKey: aNumber - 1.
self deletePageInVisualization: aNumber - 1]]
ifFalse: [| wnd | wnd := (self pageDict at: aNumber) removeFirst. (self pageDict at: aNumber - 1) addLast: wnd.
^ self windowFromNextPage: aNumber + 1 ].
aNumber > self numberPages
ifTrue: [(self pageDict at: aNumber - 1) isEmpty ifTrue: [self pageDict removeKey: aNumber - 1.
self deletePageInVisualization: aNumber - 1]]
ifFalse: [| wnd | wnd := (self pageDict at: aNumber) removeFirst. (self pageDict at: aNumber - 1) addLast: wnd. ^ self windowFromNextPage: aNumber + 1 ].

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
spaces
windowsInCurrentSpace

^ ActiveWorld submorphs select: [ :w | w isSystemWindow and: w position x >= 0 and: [w position x < ActiveWorld extent x]].
^ ActiveWorld submorphs select: [ :w | w isSystemWindow and: [ w position x between: 0 and: ActiveWorld extent x ]]
Loading

0 comments on commit bea8fbf

Please sign in to comment.