-
Notifications
You must be signed in to change notification settings - Fork 0
/
PreferencesWindowController.rb
executable file
·64 lines (46 loc) · 1.61 KB
/
PreferencesWindowController.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# PreferencesWindowController.rb
# Timey
#
# Created by Jade Meskill on 9/29/10.
# Copyright 2010 Integrum Technologies, LLC. All rights reserved.
require 'NSWindowControllerHelper'
class PreferencesWindowController < NSWindowController
attr_accessor :timerView, :appearanceView
attr_accessor :timerToolbarItem, :appearanceToolbarItem
attr_accessor :currentView
include NSWindowControllerHelper
def show(sender)
NSApp.activateIgnoringOtherApps(true)
window.center
showWindow(sender)
end
def windowDidLoad
switchToView(timerView, item:timerToolbarItem, animate:false)
end
def windowDidResignKey(notification)
window.makeFirstResponder(nil)
end
def close
window.close
end
def showAppearanceView(sender)
switchToView(appearanceView, item:appearanceToolbarItem, animate:false)
end
def showTimerView(sender)
switchToView(timerView, item:timerToolbarItem, animate:false)
end
def switchToView(view, item:toolbarItem, animate:animate)
window.toolbar.setSelectedItemIdentifier(toolbarItem.itemIdentifier)
if (currentView.respondsToSelector("removeFromSuperview"))
currentView.removeFromSuperview
end
view.setFrameOrigin([0,0])
window.contentView.addSubview(view)
setCurrentView(view)
borderHeight = window.frame.size.height - window.contentView.frame.size.height
newWindowFrame = window.frame
newWindowFrame.size.height = view.frame.size.height + borderHeight
newWindowFrame.origin.y += window.frame.size.height - newWindowFrame.size.height
window.setFrame(newWindowFrame, display:true, animate:true)
end
end