forked from HumbleUI/JWM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockTileProgressBar.mm
37 lines (30 loc) · 1.08 KB
/
DockTileProgressBar.mm
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
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#include "DockTileProgressBar.hh"
@implementation DockTileProgressBar
- (void)drawRect:(NSRect)dirtyRect {
if (self.style != NSProgressIndicatorBarStyle)
return;
// Draw edges of rounded rect.
NSRect rect = NSInsetRect([self bounds], 1.0, 1.0);
CGFloat radius = rect.size.height / 2;
NSBezierPath* bezierPath =
[NSBezierPath bezierPathWithRoundedRect:rect xRadius:radius yRadius:radius];
[bezierPath setLineWidth:2.0];
[[NSColor grayColor] set];
[bezierPath stroke];
// Fill the rounded rect.
rect = NSInsetRect(rect, 2.0, 2.0);
radius = rect.size.height / 2;
bezierPath =
[NSBezierPath bezierPathWithRoundedRect:rect xRadius:radius yRadius:radius];
[bezierPath setLineWidth:1.0];
[bezierPath addClip];
// Calculate the progress width.
rect.size.width =
floor(rect.size.width * ([self doubleValue] / [self maxValue]));
// Fill the progress bar with color blue.
[[NSColor colorWithSRGBRed:0.2 green:0.6 blue:1 alpha:1] set];
NSRectFill(rect);
}
@end