WinGui: Fix another instance of the Caliburn vs Json.net sillyness where objects...
[HandBrake.git] / macosx / HBHUDView.m
bloba183faf8e8dfd24ec9cc12eb418701a767699b93
1 /*  HBHUDButtonCell.m $
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. */
7 #import "HBHUDView.h"
9 @interface NSView (HBHUDViewExtension)
11 - (void)setBlendingMode:(int)mode;
12 - (void)setMaterial:(int)material;
13 - (void)setState:(int)state;
15 @end
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];
27     [view setMaterial:2];
28     [view setState: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"))
54     {
55         // If NSVisualEffectView class is loaded
56         // release ourself and return a NSVisualEffectView instance instead.
57         self = [[NSClassFromString(@"NSVisualEffectView") alloc] initWithFrame:frame];
58         if (self)
59         {
60             [HBHUDView setupNewStyleHUD:self];
61         }
62     }
63     else
64     {
65         self = [super initWithFrame:frame];
66     }
68     return self;
71 @end