-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathISNewLabelWindowController.j
110 lines (84 loc) · 4.05 KB
/
ISNewLabelWindowController.j
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
@import <AppKit/CPColorWell.j>
@implementation ISNewLabelWindowController : CPWindowController
{
@outlet CPTextField errorField;
@outlet CPTextField label;
@outlet CPTextField nameField;
@outlet CPColorWell colorButton;
@outlet CPButton addButton;
@outlet CPButton cancelButton;
}
- (void)awakeFromCib
{
// FIX ME: WTFBBQ?!?! Nib2cib doesn't decode isEnabled properly? :/
[colorButton setEnabled:YES];
var win = [self window];
[win setIsDetached:YES];
[win styleButton:addButton withColor:"green"];
[win styleButton:cancelButton withColor:"red"];
[win styleTextField:nameField];
}
- (@action)addLabel:(id)sender
{
}
- (@action)cancel:(id)sender
{
[[self window] orderOutWithAnimation:sender];
}
- (void)showWindow:(id)sender
{
[[self window] setAnimationLocation:"50% 50%"];
[[self window] setAnimationLength:"100"];
[super showWindow:sender];
[[self window] center];
[[self window] orderFontWithAnimation:sender];
}
@end
var bezelColor = nil,
highlightedBezelColor = nil;
@implementation CPColorWell (bezelstuff)
- (void)drawRect:(CGRect)aRect
{
var context = [[CPGraphicsContext currentContext] graphicsPort];
if (self.isHighlighted)
{
gradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [ 251 / 255, 251 / 255, 251 / 255, 1,
150 / 255, 150 / 255, 150 / 255, 1,
251 / 255, 251 / 255, 251 / 255, 1], [0, .1, 1], 3);
}
else
{
gradient = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [ 251 / 255, 251 / 255, 251 / 255, 1,
200 / 255, 200 / 255, 200 / 255, 1,
251 / 255, 251 / 255, 251 / 255, 1], [0, .1, 1], 3);
}
var path = CGPathWithRoundedRectangleInRect(aRect, 3, 3, YES, YES, YES, YES);
CGContextAddPath(context, path);
CGContextDrawLinearGradient(context, gradient, CGPointMake(0,0), CGPointMake(0, aRect.size.height), nil);
}
- (void)drawBezelWithHighlight:(BOOL)shouldHighlight
{
self.isHighlighted = shouldHighlight;
[self setNeedsDisplay:YES];
return;
if (!bezelColor)
{
bezelColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:
[
[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleWithPath:@"Frameworks/AppKit/Resources/Aristo.blend"] pathForResource:@"button-bezel-left.png"] size:CGSizeMake(4.0, 24.0)],
[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleWithPath:@"Frameworks/AppKit/Resources/Aristo.blend"] pathForResource:@"button-bezel-center.png"] size:CGSizeMake(1.0, 24.0)],
[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleWithPath:@"Frameworks/AppKit/Resources/Aristo.blend"] pathForResource:@"button-bezel-right.png"] size:CGSizeMake(4.0, 24.0)]
]
isVertical:NO]];
highlightedBezelColor = [CPColor colorWithPatternImage:[[CPThreePartImage alloc] initWithImageSlices:
[
[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleWithPath:@"Frameworks/AppKit/Resources/Aristo.blend"] pathForResource:@"button-bezel-highlighted-left.png"] size:CGSizeMake(4.0, 24.0)],
[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleWithPath:@"Frameworks/AppKit/Resources/Aristo.blend"] pathForResource:@"button-bezel-highlighted-center.png"] size:CGSizeMake(1.0, 24.0)],
[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleWithPath:@"Frameworks/AppKit/Resources/Aristo.blend"] pathForResource:@"button-bezel-highlighted-right.png"] size:CGSizeMake(4.0, 24.0)]
]
isVertical:NO]];
}
var colorToUse = shouldHighlight ? highlightedBezelColor : bezelColor;
[self setBackgroundColor:colorToUse];
}
@end