diff options
author | Damiano Galassi <[email protected]> | 2016-05-03 18:47:14 +0200 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2016-05-03 18:47:14 +0200 |
commit | e53308f9342d911a9d3e8f4d1eeba6e53fabc0ab (patch) | |
tree | f65f5390d9174276022790a308660e17d7a3601f /macosx/HBHUDView.m | |
parent | 4ab21a0ca630dc4bac79149a6eec598921899fe5 (diff) |
MacGui: use AVFoundation as the first option for the preview playback. Add volume and tracks controls to the player hud.
Diffstat (limited to 'macosx/HBHUDView.m')
-rw-r--r-- | macosx/HBHUDView.m | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/macosx/HBHUDView.m b/macosx/HBHUDView.m index e4030f743..1d6079d96 100644 --- a/macosx/HBHUDView.m +++ b/macosx/HBHUDView.m @@ -6,37 +6,37 @@ #import "HBHUDView.h" -@implementation HBHUDView +@interface HBHUDVisualEffectsView : NSVisualEffectView +@end + +@implementation HBHUDVisualEffectsView -+ (void)setupNewStyleHUD:(NSVisualEffectView *)view +- (instancetype)initWithFrame:(NSRect)frame { - [view setWantsLayer:YES]; - [view.layer setCornerRadius:4]; + self = [super initWithFrame:frame]; - [view setBlendingMode:NSVisualEffectBlendingModeWithinWindow]; - [view setMaterial:NSVisualEffectMaterialDark]; - [view setState:NSVisualEffectStateActive]; + if (self) + { + self.wantsLayer = YES; + self.layer.cornerRadius = 4; + + self.blendingMode = NSVisualEffectBlendingModeWithinWindow; + self.material = NSVisualEffectMaterialDark; + self.state = NSVisualEffectStateActive; - [view setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]]; + self.appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]; + } + return self; } -- (void)drawRect:(NSRect)dirtyRect +- (BOOL)acceptsFirstResponder { - 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]; + return YES; +} - [[NSColor whiteColor] setStroke]; - [NSBezierPath setDefaultLineWidth:2.0]; - [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(rect, 1, 1) xRadius:14.0 yRadius:14.0] stroke]; +@end - [theContext restoreGraphicsState]; -} +@implementation HBHUDView - (instancetype)initWithFrame:(NSRect)frame { @@ -44,11 +44,7 @@ { // If NSVisualEffectView class is loaded // release ourself and return a NSVisualEffectView instance instead. - self = [[NSClassFromString(@"NSVisualEffectView") alloc] initWithFrame:frame]; - if (self) - { - [HBHUDView setupNewStyleHUD:(NSVisualEffectView *)self]; - } + self = (HBHUDView *)[[HBHUDVisualEffectsView alloc] initWithFrame:frame]; } else { @@ -58,4 +54,27 @@ 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
\ No newline at end of file |