3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.fr/>.
5 It may be used under the terms of the GNU General Public License. */
9 @interface NSView (HBHUDViewExtension)
11 - (void)setBlendingMode:(int)mode;
12 - (void)setMaterial:(int)material;
13 - (void)setState:(int)state;
17 @implementation HBHUDView
19 + (void)setupNewStyleHUD:(NSView *)view
21 [view setWantsLayer:YES];
22 [view.layer setCornerRadius:4];
24 // Hardcode the values so we can
25 // compile it with the 10.9 sdk.
26 [view setBlendingMode:1];
30 [view setAppearance:[NSClassFromString(@"NSAppearance") appearanceNamed:@"NSAppearanceNameVibrantDark"]];
33 - (void)drawRect:(NSRect)dirtyRect
35 NSGraphicsContext *theContext = [NSGraphicsContext currentContext];
36 [theContext saveGraphicsState];
38 NSRect rect = NSMakeRect(0.0, 0.0, [self frame].size.width, [self frame].size.height);
40 // Draw a standard HUD with black transparent background and white border.
41 [[NSColor colorWithCalibratedRed:0.0 green:0.0 blue:0.0 alpha:0.6] setFill];
42 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(rect, 1, 1) xRadius:14.0 yRadius:14.0] fill];
44 [[NSColor whiteColor] setStroke];
45 [NSBezierPath setDefaultLineWidth:2.0];
46 [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(rect, 1, 1) xRadius:14.0 yRadius:14.0] stroke];
48 [theContext restoreGraphicsState];
51 - (instancetype)initWithFrame:(NSRect)frame
53 if (NSClassFromString(@"NSVisualEffectView"))
55 // If NSVisualEffectView class is loaded
56 // release ourself and return a NSVisualEffectView instance instead.
57 self = [[NSClassFromString(@"NSVisualEffectView") alloc] initWithFrame:frame];
60 [HBHUDView setupNewStyleHUD:self];
65 self = [super initWithFrame:frame];