From: Ruben Beltran del Rio Date: Wed, 8 Feb 2023 16:25:34 +0000 (+0100) Subject: Port BackgroundView to swift, use system darkmode X-Git-Tag: 1.0.0~6 X-Git-Url: https://git.r.bdr.sh/rbdr/Flat-Bezel.qsplugin/commitdiff_plain/fc2c05420021064af5e322f5e59cf0995239349a?ds=sidebyside Port BackgroundView to swift, use system darkmode --- diff --git a/Flat Bezel.xcodeproj/project.pbxproj b/Flat Bezel.xcodeproj/project.pbxproj index 6c886d5..1dc96c0 100644 --- a/Flat Bezel.xcodeproj/project.pbxproj +++ b/Flat Bezel.xcodeproj/project.pbxproj @@ -7,11 +7,11 @@ objects = { /* Begin PBXBuildFile section */ - 42447D7A193F6C9D0077B4B2 /* BBBackgroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = 42447D79193F6C9D0077B4B2 /* BBBackgroundView.m */; }; 42447D7D19407DA00077B4B2 /* BBSearchObjectView.m in Sources */ = {isa = PBXBuildFile; fileRef = 42447D7C19407DA00077B4B2 /* BBSearchObjectView.m */; }; 42447D821940935E0077B4B2 /* gear-black.png in Resources */ = {isa = PBXBuildFile; fileRef = 42447D7F1940935E0077B4B2 /* gear-black.png */; }; 42447D831940935E0077B4B2 /* search-black.png in Resources */ = {isa = PBXBuildFile; fileRef = 42447D801940935E0077B4B2 /* search-black.png */; }; 42663058193CC1FA00C0DD31 /* BBFlatBezelInterface.xib in Resources */ = {isa = PBXBuildFile; fileRef = 42663057193CC1FA00C0DD31 /* BBFlatBezelInterface.xib */; }; + B576D2F52993FBD400A8B645 /* BackgroundView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B576D2F42993FBD400A8B645 /* BackgroundView.swift */; }; CD3B1BE2285F2E8C004862D7 /* search-white.png in Resources */ = {isa = PBXBuildFile; fileRef = CD3B1BE0285F2E8C004862D7 /* search-white.png */; }; CD3B1BE3285F2E8C004862D7 /* gear-white.png in Resources */ = {isa = PBXBuildFile; fileRef = CD3B1BE1285F2E8C004862D7 /* gear-white.png */; }; E470B7E31709F3A0000169F2 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E470B7E21709F3A0000169F2 /* Cocoa.framework */; }; @@ -20,13 +20,13 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 42447D78193F6C9D0077B4B2 /* BBBackgroundView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BBBackgroundView.h; sourceTree = ""; }; - 42447D79193F6C9D0077B4B2 /* BBBackgroundView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BBBackgroundView.m; sourceTree = ""; }; 42447D7B19407DA00077B4B2 /* BBSearchObjectView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BBSearchObjectView.h; sourceTree = ""; }; 42447D7C19407DA00077B4B2 /* BBSearchObjectView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BBSearchObjectView.m; sourceTree = ""; }; 42447D7F1940935E0077B4B2 /* gear-black.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "gear-black.png"; sourceTree = ""; }; 42447D801940935E0077B4B2 /* search-black.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "search-black.png"; sourceTree = ""; }; 42663057193CC1FA00C0DD31 /* BBFlatBezelInterface.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BBFlatBezelInterface.xib; sourceTree = ""; }; + B576D2F42993FBD400A8B645 /* BackgroundView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackgroundView.swift; sourceTree = ""; }; + B576D2F62993FD7500A8B645 /* FlatBezel-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FlatBezel-Bridging-Header.h"; sourceTree = ""; }; CD3B1BE0285F2E8C004862D7 /* search-white.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "search-white.png"; sourceTree = ""; }; CD3B1BE1285F2E8C004862D7 /* gear-white.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "gear-white.png"; sourceTree = ""; }; E470B7DF1709F3A0000169F2 /* Flat Bezel.qsplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Flat Bezel.qsplugin"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -85,13 +85,12 @@ children = ( E470B7EA1709F3A0000169F2 /* Configuration */, E470B7E51709F3A0000169F2 /* Supporting Files */, - 42447D78193F6C9D0077B4B2 /* BBBackgroundView.h */, - 42447D79193F6C9D0077B4B2 /* BBBackgroundView.m */, 42447D7B19407DA00077B4B2 /* BBSearchObjectView.h */, 42447D7C19407DA00077B4B2 /* BBSearchObjectView.m */, E470B7F61709F3A0000169F2 /* BBFlatBezelInterface.h */, E470B7F71709F3A0000169F2 /* BBFlatBezelInterface.m */, 42663057193CC1FA00C0DD31 /* BBFlatBezelInterface.xib */, + B576D2F42993FBD400A8B645 /* BackgroundView.swift */, CD3B1BE1285F2E8C004862D7 /* gear-white.png */, CD3B1BE0285F2E8C004862D7 /* search-white.png */, 42447D7F1940935E0077B4B2 /* gear-black.png */, @@ -105,6 +104,7 @@ children = ( E470B7E61709F3A0000169F2 /* Info.plist */, E470B7E71709F3A0000169F2 /* InfoPlist.strings */, + B576D2F62993FD7500A8B645 /* FlatBezel-Bridging-Header.h */, ); name = "Supporting Files"; sourceTree = ""; @@ -214,7 +214,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 42447D7A193F6C9D0077B4B2 /* BBBackgroundView.m in Sources */, + B576D2F52993FBD400A8B645 /* BackgroundView.swift in Sources */, 42447D7D19407DA00077B4B2 /* BBSearchObjectView.m in Sources */, E470B7F81709F3A0000169F2 /* BBFlatBezelInterface.m in Sources */, ); @@ -283,6 +283,7 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_WEAK = YES; + DEFINES_MODULE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 12.0; PRODUCT_BUNDLE_IDENTIFIER = "pizza.unlimited.${PRODUCT_NAME:rfc1034identifier}"; @@ -299,6 +300,7 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_WEAK = YES; + DEFINES_MODULE = YES; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 12.0; PRODUCT_BUNDLE_IDENTIFIER = "pizza.unlimited.${PRODUCT_NAME:rfc1034identifier}"; 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"