diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-02-08 17:25:34 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2023-02-08 17:25:34 +0100 |
| commit | fc2c05420021064af5e322f5e59cf0995239349a (patch) | |
| tree | 18ea7a9d8116cf486b1d39d1885aff80a6484dad /Flat Bezel | |
| parent | 5200836d4b4ca9baf0f578f7a462f27d155abff4 (diff) | |
Port BackgroundView to swift, use system darkmode
Diffstat (limited to 'Flat Bezel')
| -rw-r--r-- | Flat Bezel/BBBackgroundView.h | 5 | ||||
| -rw-r--r-- | Flat Bezel/BBBackgroundView.m | 24 | ||||
| -rw-r--r-- | Flat Bezel/BBFlatBezelInterface.m | 2 | ||||
| -rw-r--r-- | Flat Bezel/BBFlatBezelInterface.xib | 4 | ||||
| -rw-r--r-- | Flat Bezel/BackgroundView.swift | 31 | ||||
| -rw-r--r-- | Flat Bezel/FlatBezel-Bridging-Header.h | 1 |
6 files changed, 35 insertions, 32 deletions
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 <QSInterface/QSInterface.h> - -@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 @@ <rect key="contentRect" x="530" y="653" width="648" height="200"/> <rect key="screenRect" x="0.0" y="0.0" width="1512" height="944"/> <value key="minSize" type="size" width="440" height="200"/> - <view key="contentView" id="6" customClass="BBBackgroundView"> + <view key="contentView" id="6" customClass="BackgroundView" customModule="Flat_Bezel" customModuleProvider="target"> <rect key="frame" x="0.0" y="0.0" width="648" height="200"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> @@ -85,7 +85,7 @@ </constraints> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" state="on" alignment="center" title="⏷" id="214"> <font key="font" metaFont="system"/> - <color key="textColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> + <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> </textField> 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" |