summaryrefslogtreecommitdiffstats
path: root/macosx/HBHUDView.m
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/HBHUDView.m')
-rw-r--r--macosx/HBHUDView.m73
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