forked from andreberg/gitx
-
Notifications
You must be signed in to change notification settings - Fork 79
/
PBGitGradientBarView.m
52 lines (35 loc) · 1010 Bytes
/
PBGitGradientBarView.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
//
// PBGitGradientBarView.m
// GitX
//
// Created by Nathan Kinsinger on 2/22/10.
// Copyright 2010 Nathan Kinsinger. All rights reserved.
//
#import "PBGitGradientBarView.h"
@implementation PBGitGradientBarView
- (id) initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (!self)
return nil;
[self setTopShade:1.0 bottomShade:0.0];
return self;
}
- (void) drawRect:(NSRect)dirtyRect
{
[gradient drawInRect:[self bounds] angle:90];
}
- (void) setTopColor:(NSColor *)topColor bottomColor:(NSColor *)bottomColor
{
if (!topColor || !bottomColor)
return;
gradient = [[NSGradient alloc] initWithStartingColor:bottomColor endingColor:topColor];
[self setNeedsDisplay:YES];
}
- (void) setTopShade:(float)topShade bottomShade:(float)bottomShade
{
NSColor *topColor = [NSColor colorWithCalibratedWhite:topShade alpha:1.0];
NSColor *bottomColor = [NSColor colorWithCalibratedWhite:bottomShade alpha:1.0];
[self setTopColor:topColor bottomColor:bottomColor];
}
@end