blob: 1d6079d96f248b8feae85034ce5df8de75e04be8 (
plain)
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
|
/* HBHUDButtonCell.m $
This file is part of the HandBrake source code.
Homepage: <http://handbrake.fr/>.
It may be used under the terms of the GNU General Public License. */
#import "HBHUDView.h"
@interface HBHUDVisualEffectsView : NSVisualEffectView
@end
@implementation HBHUDVisualEffectsView
- (instancetype)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
self.wantsLayer = YES;
self.layer.cornerRadius = 4;
self.blendingMode = NSVisualEffectBlendingModeWithinWindow;
self.material = NSVisualEffectMaterialDark;
self.state = NSVisualEffectStateActive;
self.appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark];
}
return self;
}
- (BOOL)acceptsFirstResponder
{
return YES;
}
@end
@implementation HBHUDView
- (instancetype)initWithFrame:(NSRect)frame
{
if (NSClassFromString(@"NSVisualEffectView"))
{
// If NSVisualEffectView class is loaded
// release ourself and return a NSVisualEffectView instance instead.
self = (HBHUDView *)[[HBHUDVisualEffectsView alloc] initWithFrame:frame];
}
else
{
self = [super initWithFrame:frame];
}
return self;
}
- (BOOL)acceptsFirstResponder
{
return YES;
}
- (void)drawRect:(NSRect)dirtyRect
{
NSGraphicsContext *theContext = [NSGraphicsContext currentContext];
[theContext saveGraphicsState];
NSRect rect = NSMakeRect(0.0, 0.0, self.frame.size.width, self.frame.size.height);
// Draw a standard HUD with black transparent background and white border.
[[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.0 alpha:0.6] setFill];
[[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(rect, 1, 1) xRadius:14.0 yRadius:14.0] fill];
[[NSColor whiteColor] setStroke];
[NSBezierPath setDefaultLineWidth:2.0];
[[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(rect, 1, 1) xRadius:14.0 yRadius:14.0] stroke];
[theContext restoreGraphicsState];
}
@end
|