From fc2c05420021064af5e322f5e59cf0995239349a Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Wed, 8 Feb 2023 17:25:34 +0100 Subject: Port BackgroundView to swift, use system darkmode --- Flat Bezel/BBBackgroundView.h | 5 ----- Flat Bezel/BBBackgroundView.m | 24 ------------------------ Flat Bezel/BBFlatBezelInterface.m | 2 +- Flat Bezel/BBFlatBezelInterface.xib | 4 ++-- Flat Bezel/BackgroundView.swift | 31 +++++++++++++++++++++++++++++++ Flat Bezel/FlatBezel-Bridging-Header.h | 1 + 6 files changed, 35 insertions(+), 32 deletions(-) delete mode 100644 Flat Bezel/BBBackgroundView.h delete mode 100644 Flat Bezel/BBBackgroundView.m create mode 100644 Flat Bezel/BackgroundView.swift create mode 100644 Flat Bezel/FlatBezel-Bridging-Header.h (limited to 'Flat Bezel') diff --git a/Flat Bezel/BBBackgroundView.h b/Flat Bezel/BBBackgroundView.h deleted file mode 100644 index 1c699a2..0000000 --- a/Flat Bezel/BBBackgroundView.h +++ /dev/null @@ -1,5 +0,0 @@ -#import - -@interface BBBackgroundView : QSBezelBackgroundView - -@end diff --git a/Flat Bezel/BBBackgroundView.m b/Flat Bezel/BBBackgroundView.m deleted file mode 100644 index 7aff10b..0000000 --- a/Flat Bezel/BBBackgroundView.m +++ /dev/null @@ -1,24 +0,0 @@ -#import "BBBackgroundView.h" - -@implementation BBBackgroundView - -- (void)drawRect:(NSRect)rect { - rect = [self bounds]; - - NSBezierPath *roundRect = [NSBezierPath bezierPath]; - - [roundRect appendBezierPathWithRoundedRectangle:rect withRadius:8]; - [roundRect addClip]; - - BOOL darkMode = [[NSUserDefaults standardUserDefaults] boolForKey:@"QSFlatBezelDarkMode"]; - if (darkMode) { - [[NSColor colorWithRed:.1 green:.1 blue:.1 alpha:.99] set]; - } else { - [[NSColor colorWithRed:1 green:1 blue:1 alpha:.99] set]; - } - NSRectFill(rect); - - [super drawRect:rect]; -} - -@end diff --git a/Flat Bezel/BBFlatBezelInterface.m b/Flat Bezel/BBFlatBezelInterface.m index a191f81..a05a924 100644 --- a/Flat Bezel/BBFlatBezelInterface.m +++ b/Flat Bezel/BBFlatBezelInterface.m @@ -43,7 +43,7 @@ [theCell setCellRadiusFactor:8]; [theCell setHighlightColor:[NSColor colorWithRed:1 green:1 blue:1 alpha:.15]]; - [theCell setTextColor:[NSColor colorWithWhite:.8 alpha:1]]; + [theCell setTextColor:[NSColor textColor]]; [theCell setShowDetails:NO]; [theCell setState:NSControlStateValueOn]; [theCell setIconSize:QSSize128]; diff --git a/Flat Bezel/BBFlatBezelInterface.xib b/Flat Bezel/BBFlatBezelInterface.xib index 75378c6..dae6222 100644 --- a/Flat Bezel/BBFlatBezelInterface.xib +++ b/Flat Bezel/BBFlatBezelInterface.xib @@ -25,7 +25,7 @@ - + @@ -85,7 +85,7 @@ - + diff --git a/Flat Bezel/BackgroundView.swift b/Flat Bezel/BackgroundView.swift new file mode 100644 index 0000000..041874a --- /dev/null +++ b/Flat Bezel/BackgroundView.swift @@ -0,0 +1,31 @@ +// +// BBBackgroundView.swift +// Flat Bezel +// +// Created by Ruben Beltran del Rio on 2/8/23. +// Copyright © 2023 BRNBW. All rights reserved. +// + +import Foundation +import Cocoa + +class BackgroundView: QSBezelBackgroundView { + + override func draw(_ rect: NSRect) { + let boundsRect = self.bounds + + let roundRect = NSBezierPath() + roundRect.appendRoundedRect(boundsRect, xRadius: 8.0, yRadius: 8.0) + roundRect.addClip() + + let darkMode = self.effectiveAppearance.name == .darkAqua + if (darkMode) { + NSColor(red: 0.1, green: 0.1, blue: 0.1, alpha: 0.99).setFill() + } else { + NSColor(red: 1, green: 1, blue: 1, alpha: 0.99).setFill() + } + boundsRect.fill(using: .copy) + + super.draw(boundsRect) + } +} diff --git a/Flat Bezel/FlatBezel-Bridging-Header.h b/Flat Bezel/FlatBezel-Bridging-Header.h new file mode 100644 index 0000000..d3e20b0 --- /dev/null +++ b/Flat Bezel/FlatBezel-Bridging-Header.h @@ -0,0 +1 @@ +#import "Quicksilver.pch" -- cgit