summaryrefslogtreecommitdiffstats
path: root/macosx/HBHUDView.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2014-08-22 17:59:21 +0000
committerritsuka <[email protected]>2014-08-22 17:59:21 +0000
commitad7edc8fb58a256881fd470801e80dbb425cc79f (patch)
tree5552786381f3866295c90ae782afbc7935e584c2 /macosx/HBHUDView.m
parent7e22c9f782914792c38323081844f972fcdf63a7 (diff)
MacGui: fixed the preview controller HUD style on the next OS X release.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6347 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBHUDView.m')
-rw-r--r--macosx/HBHUDView.m95
1 files changed, 95 insertions, 0 deletions
diff --git a/macosx/HBHUDView.m b/macosx/HBHUDView.m
new file mode 100644
index 000000000..769c5ba99
--- /dev/null
+++ b/macosx/HBHUDView.m
@@ -0,0 +1,95 @@
+//
+// HBVisualEffectBox.m
+// HandBrake
+//
+// Created by Toby on 21/08/14.
+//
+//
+
+#import "HBHUDView.h"
+
+@interface NSView (HBHUDViewExtension)
+
+- (void)setBlendingMode:(int)mode;
+- (void)setMaterial:(int)material;
+- (void)setState:(int)state;
+
+@end
+
+@implementation HBHUDView
+
+- (instancetype)init
+{
+ self = [super init];
+ if (self)
+ {
+ [self setupOldStyleHUD];
+ }
+
+ return self;
+}
+
++ (void)setupNewStyleHUD:(NSView *)view
+{
+ [view setWantsLayer:YES];
+ [view.layer setCornerRadius:4];
+
+ // Hardcode the values so we can
+ // compile it with the 10.9 sdk.
+ [view setBlendingMode:1];
+ [view setMaterial:2];
+ [view setState:1];
+
+ [view setAppearance:[NSAppearance appearanceNamed:@"NSAppearanceNameVibrantDark"]];
+}
+
+- (void)setupOldStyleHUD
+{
+ [self setWantsLayer:YES];
+ [self.layer setCornerRadius:14];
+
+ // Black transparent background and white border
+ CGColorRef white = CGColorCreateGenericRGB(1.0, 1.0, 1.0, 0.9);
+ [self.layer setBorderColor:white];
+ CFRelease(white);
+ [self.layer setBorderWidth:2];
+
+ CGColorRef black = CGColorCreateGenericRGB(0.0, 0.0, 0.0, 0.6);
+ [self.layer setBackgroundColor:black];
+ CFRelease(black);
+}
+
+- (instancetype)initWithFrame:(NSRect)frame
+{
+ if (NSClassFromString(@"NSVisualEffectView"))
+ {
+ // Return a NSVisualEffectView instance
+ self = [[NSClassFromString(@"NSVisualEffectView") alloc] initWithFrame:frame];
+ if (self)
+ {
+ [HBHUDView setupNewStyleHUD:self];
+ }
+ }
+ else
+ {
+ self = [super initWithFrame:frame];
+ if (self)
+ {
+ [self setupOldStyleHUD];
+ }
+ }
+
+ return self;
+}
+
+- (instancetype)initWithCoder:(NSCoder *)coder
+{
+ self = [super initWithCoder:coder];
+ if (self)
+ {
+ [self setupOldStyleHUD];
+ }
+ return self;
+}
+
+@end \ No newline at end of file