-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppController.m
165 lines (133 loc) · 4.14 KB
/
AppController.m
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#import "AppController.h"
@implementation AppController
- (void)awakeFromNib
{
[[NSColorPanel sharedColorPanel] setShowsAlpha:YES];
}
- (IBAction)changeSide:(id)sender
{
NSDisableScreenUpdates();
if (attachedWindow) {
[self toggleWindow:sender];
}
[self toggleWindow:sender];
NSEnableScreenUpdates();
}
- (IBAction)changeBorderColor:(id)sender
{
if (attachedWindow) {
[attachedWindow setBorderColor:[sender color]];
[textField setTextColor:[sender color]];
} else {
[self toggleWindow:sender];
}
}
- (IBAction)changeBackgroundColor:(id)sender
{
if (attachedWindow) {
[attachedWindow setBackgroundColor:[sender color]];
} else {
[self toggleWindow:sender];
}
}
- (IBAction)changeViewMargin:(id)sender
{
if (attachedWindow) {
[attachedWindow setViewMargin:[sender floatValue]];
[attachedWindow setBorderWidth:[borderWidthSlider floatValue]];
} else {
[self toggleWindow:sender];
}
}
- (IBAction)changeBorderWidth:(id)sender
{
if (attachedWindow) {
[attachedWindow setBorderWidth:[sender floatValue]];
} else {
[self toggleWindow:sender];
}
}
- (IBAction)changeCornerRadius:(id)sender
{
if (attachedWindow) {
[attachedWindow setCornerRadius:[sender floatValue]];
} else {
[self toggleWindow:sender];
}
}
- (IBAction)changeHasArrow:(id)sender
{
if (attachedWindow) {
[attachedWindow setHasArrow:([sender state] == NSOnState)];
} else {
[self toggleWindow:sender];
}
}
- (IBAction)changeDrawsRoundCornerBesideArrow:(id)sender
{
if (attachedWindow) {
[attachedWindow setDrawsRoundCornerBesideArrow:([sender state] == NSOnState)];
} else {
[self toggleWindow:sender];
}
}
- (IBAction)changeArrowBaseWidth:(id)sender
{
if (attachedWindow) {
[attachedWindow setArrowBaseWidth:[sender floatValue]];
} else {
[self toggleWindow:sender];
}
}
- (IBAction)changeArrowHeight:(id)sender
{
if (attachedWindow) {
[attachedWindow setArrowHeight:[sender floatValue]];
} else {
[self toggleWindow:sender];
}
}
- (IBAction)changeDistance:(id)sender
{
NSDisableScreenUpdates();
if (attachedWindow) {
[self toggleWindow:sender];
}
[self toggleWindow:sender];
NSEnableScreenUpdates();
}
- (IBAction)toggleWindow:(id)sender
{
if (!attachedWindow) {
int side = [sidePopup indexOfSelectedItem];
NSPoint buttonPoint = NSMakePoint(NSMidX([toggleButton frame]),
NSMidY([toggleButton frame]));
attachedWindow = [[NSFLoatingWindow alloc] initWithView:view
attachedToPoint:buttonPoint
inWindow:[toggleButton window]
onSide:side
atDistance:[distanceSlider floatValue]];
[attachedWindow setBorderColor:[borderColorWell color]];
[textField setTextColor:[borderColorWell color]];
[attachedWindow setBackgroundColor:[backgroundColorWell color]];
[attachedWindow setViewMargin:[viewMarginSlider floatValue]];
[attachedWindow setBorderWidth:[borderWidthSlider floatValue]];
[attachedWindow setCornerRadius:[cornerRadiusSlider floatValue]];
[attachedWindow setHasArrow:([hasArrowCheckbox state] == NSOnState)];
[attachedWindow setDrawsRoundCornerBesideArrow:
([drawRoundCornerBesideArrowCheckbox state] == NSOnState)];
[attachedWindow setArrowBaseWidth:[arrowBaseWidthSlider floatValue]];
[attachedWindow setArrowHeight:[arrowHeightSlider floatValue]];
[[toggleButton window] addChildWindow:attachedWindow ordered:NSWindowAbove];
} else {
[[toggleButton window] removeChildWindow:attachedWindow];
[attachedWindow orderOut:self];
[attachedWindow release];
attachedWindow = nil;
}
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app
{
return YES;
}
@end