Skip to content
Permalink
Browse files

Change color of button bar for Dark Mode (Console)

  • Loading branch information...
dmoagx committed Jul 18, 2018
1 parent a98cdf4 commit 658d82ab48683312f9995041fc93e6bbff86aa3e
@@ -33,22 +33,6 @@
<rect key="frame" x="0.0" y="0.0" width="575" height="203"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView misplaced="YES" id="71">
<rect key="frame" x="-1" y="0.0" width="578" height="23"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" animates="YES" imageScaling="axesIndependently" image="button_bar_spacer" id="72"/>
</imageView>
<button verticalHuggingPriority="750" id="9">
<rect key="frame" x="399" y="2" width="166" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="roundRect" title="Save As..." bezelStyle="roundedRect" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="12">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<connections>
<action selector="saveConsoleAs:" target="-2" id="54"/>
</connections>
</button>
<searchField wantsLayer="YES" verticalHuggingPriority="750" id="8">
<rect key="frame" x="10" y="174" width="531" height="19"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
@@ -61,6 +45,10 @@
<outlet property="delegate" destination="-2" id="61"/>
</connections>
</searchField>
<progressIndicator hidden="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" minValue="16" maxValue="100" doubleValue="16" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" id="62">
<rect key="frame" x="549" y="175" width="16" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
</progressIndicator>
<scrollView autohidesScrollers="YES" horizontalLineScroll="18" horizontalPageScroll="10" verticalLineScroll="18" verticalPageScroll="10" usesPredominantAxisScrolling="NO" id="7">
<rect key="frame" x="-1" y="22" width="578" height="144"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@@ -152,10 +140,21 @@
</connections>
</tableHeaderView>
</scrollView>
<progressIndicator hidden="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" minValue="16" maxValue="100" doubleValue="16" bezeled="NO" indeterminate="YES" controlSize="small" style="spinning" id="62">
<rect key="frame" x="549" y="175" width="16" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
</progressIndicator>
<customView id="plS-KC-BwQ" customClass="SPButtonBar">
<rect key="frame" x="0.0" y="0.0" width="575" height="23"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
</customView>
<button verticalHuggingPriority="750" id="9">
<rect key="frame" x="399" y="2" width="166" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
<buttonCell key="cell" type="roundRect" title="Save As..." bezelStyle="roundedRect" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="12">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<connections>
<action selector="saveConsoleAs:" target="-2" id="54"/>
</connections>
</button>
<button toolTip="Clear Console" id="73">
<rect key="frame" x="30" y="-1" width="32" height="25"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
@@ -233,7 +232,7 @@
</popUpButtonCell>
</popUpButton>
<textField verticalHuggingPriority="750" id="108">
<rect key="frame" x="67" y="4" width="375" height="14"/>
<rect key="frame" x="67" y="4" width="326" height="14"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" id="109">
<font key="font" metaFont="smallSystem"/>
@@ -329,7 +328,6 @@
</objects>
<resources>
<image name="button_action" width="30" height="22"/>
<image name="button_bar_spacer" width="11" height="23"/>
<image name="button_clear" width="30" height="22"/>
</resources>
</document>
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,48 @@
//
// SPButtonBar.h
// sequel-pro
//
// Created by Max Lohrmann on 16.07.18.
// Copyright (c) 2018 Max Lohrmann. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// More info at <https://github.com/sequelpro/sequelpro>

/**
* This view can be used as the background for button bars displayed at the bottom of the window
* in various places.
* On 10.14+ it will automatically adapt to the Dark UI mode.
*
* Since Apple's complete "documentation" of Dark mode resources consists of "Just use Asset
* Catalogs. Oh btw, that'll only work in Xcode 10 and OS X 10.14.", I guess this will be the
* alternative to using file formats that are ten times more volatile than the Mac hardware lineup.
*/
@interface SPButtonBar : NSView
{
NSImage *lightImage;
NSImage *darkImage;
}

- (instancetype)init NS_UNAVAILABLE;

@end
@@ -0,0 +1,108 @@
//
// SPButtonBar.m
// sequel-pro
//
// Created by Max Lohrmann on 16.07.18.
// Copyright (c) 2018 Max Lohrmann. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following
// conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE.
//
// More info at <https://github.com/sequelpro/sequelpro>

#import "SPButtonBar.h"
#import "SPOSInfo.h"

static BOOL isOSAtLeast10_14 = NO;

static void init(SPButtonBar *obj);

@interface SPButtonBar ()

- (BOOL)isInDarkMode;

@end

@implementation SPButtonBar

+ (void)initialize
{
isOSAtLeast10_14 = [SPOSInfo isOSVersionAtLeastMajor:10 minor:14 patch:0];
}

- (instancetype)init
{
[NSException raise:NSInternalInconsistencyException format:@"%s is not a valid initializer for class!",__func__];
return nil; // compiler hint
}

- (instancetype)initWithFrame:(NSRect)frameRect //designated initializer of super
{
if(self = [super initWithFrame:frameRect]) {
init(self);
}
return self;
}

- (instancetype)initWithCoder:(NSCoder *)decoder //designated initializer of super
{
if(self = [super initWithCoder:decoder]) {
init(self);
}
return self;
}

void init(SPButtonBar *obj)
{
obj->lightImage = [[NSImage imageNamed:@"button_bar_spacer"] retain];
obj->darkImage = [[NSImage imageNamed:@"button_bar_spacer_dark"] retain];
}

- (void)dealloc
{
SPClear(lightImage);
SPClear(darkImage);
[super dealloc];
}

- (BOOL)isInDarkMode
{
if(isOSAtLeast10_14) {
NSString *match = [[self effectiveAppearance] bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
if ([NSAppearanceNameDarkAqua isEqualToString:match]) {
return YES;
}
}
return NO;
}

- (void)drawRect:(NSRect)dirtyRect
{
[super drawRect:dirtyRect];

NSImage *img = ([self isInDarkMode] ? darkImage : lightImage);
NSRect drawFrame = [self frame];
drawFrame.origin.x = dirtyRect.origin.x;
drawFrame.size.width = dirtyRect.size.width;
[img drawInRect:drawFrame fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
}

@end
@@ -153,6 +153,9 @@
3876E1541CC0B26700D85154 /* button_add_folder@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3876E1531CC0B26700D85154 /* button_add_folder@2x.png */; };
3876E15D1CC0BA0300D85154 /* SPTableFooterPopUpButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 3876E15C1CC0BA0300D85154 /* SPTableFooterPopUpButtonCell.m */; };
387BBBA80FBCB6CB00B31746 /* SPTableRelations.m in Sources */ = {isa = PBXBuildFile; fileRef = 387BBBA70FBCB6CB00B31746 /* SPTableRelations.m */; };
3E10740420FC25B7006DBDFD /* SPButtonBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 3E10740320FC25B7006DBDFD /* SPButtonBar.m */; };
3E242D4F20FEB44D0015470D /* button_bar_spacer_dark.png in Resources */ = {isa = PBXBuildFile; fileRef = 3E242D4B20FEB44D0015470D /* button_bar_spacer_dark.png */; };
3E242D5020FEB44D0015470D /* button_bar_spacer_dark@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3E242D4E20FEB44D0015470D /* button_bar_spacer_dark@2x.png */; };
4D90B79A101E0CDF00D116A1 /* SPUserManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D90B799101E0CDF00D116A1 /* SPUserManager.m */; };
4D90B79E101E0CF200D116A1 /* SPUserManager.xcdatamodel in Sources */ = {isa = PBXBuildFile; fileRef = 4D90B79B101E0CF200D116A1 /* SPUserManager.xcdatamodel */; };
4D90B79F101E0CF200D116A1 /* SPUserMO.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D90B79D101E0CF200D116A1 /* SPUserMO.m */; };
@@ -867,6 +870,10 @@
38C613701C89777B00B3B6EF /* libz.1.2.5.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.1.2.5.tbd; path = usr/lib/libz.1.2.5.tbd; sourceTree = SDKROOT; };
38C613721C8977E600B3B6EF /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
38F37194182F0621008EB031 /* readme.md */ = {isa = PBXFileReference; lastKnownFileType = text; path = readme.md; sourceTree = "<group>"; };
3E10740220FC25B7006DBDFD /* SPButtonBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SPButtonBar.h; sourceTree = "<group>"; };
3E10740320FC25B7006DBDFD /* SPButtonBar.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SPButtonBar.m; sourceTree = "<group>"; };
3E242D4B20FEB44D0015470D /* button_bar_spacer_dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = button_bar_spacer_dark.png; sourceTree = "<group>"; };
3E242D4E20FEB44D0015470D /* button_bar_spacer_dark@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "button_bar_spacer_dark@2x.png"; sourceTree = "<group>"; };
4D90B798101E0CDF00D116A1 /* SPUserManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SPUserManager.h; sourceTree = "<group>"; };
4D90B799101E0CDF00D116A1 /* SPUserManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SPUserManager.m; sourceTree = "<group>"; };
4D90B79B101E0CF200D116A1 /* SPUserManager.xcdatamodel */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = wrapper.xcdatamodel; name = SPUserManager.xcdatamodel; path = Models/SPUserManager.xcdatamodel; sourceTree = SOURCE_ROOT; };
@@ -2003,6 +2010,8 @@
17DC8828126B332F00E9AAEC /* Accessory Views */,
9BE768F3989033CEDDC2027E /* SPFillView.m */,
9BE76CC0CCE3A4A74E3E8D5E /* SPFillView.h */,
3E10740220FC25B7006DBDFD /* SPButtonBar.h */,
3E10740320FC25B7006DBDFD /* SPButtonBar.m */,
);
name = Views;
sourceTree = "<group>";
@@ -2046,6 +2055,8 @@
17E6418B0EF01FF7001BC333 /* Images */ = {
isa = PBXGroup;
children = (
3E242D4B20FEB44D0015470D /* button_bar_spacer_dark.png */,
3E242D4E20FEB44D0015470D /* button_bar_spacer_dark@2x.png */,
C9AD7C8116761B3300234EEE /* button_action.png */,
C9AD7C8216761B3300234EEE /* button_action@2x.png */,
582E93F5168298C6003459FD /* button_add_folder.png */,
@@ -2892,6 +2903,7 @@
B58DA73C0FF8BBA500FDDACD /* PrintAccessory.xib in Resources */,
B58DA73A0FF8BB9E00FDDACD /* SSHQuestionDialog.xib in Resources */,
B54F25E60FD909C400E2CF36 /* toolbar-switch-to-table-relations.png in Resources */,
3E242D4F20FEB44D0015470D /* button_bar_spacer_dark.png in Resources */,
588B2CC80FE5641E00EC5FC0 /* ssh-connected.png in Resources */,
588B2CC90FE5641E00EC5FC0 /* ssh-connecting.png in Resources */,
588B2CCA0FE5641E00EC5FC0 /* ssh-disconnected.png in Resources */,
@@ -2988,6 +3000,7 @@
C9C9944E1678BCFA001F5DA8 /* table-small@2x.png in Resources */,
582E939D168296F3003459FD /* link-arrow-clicked@2x.png in Resources */,
582E939E168296F3003459FD /* link-arrow-highlighted-clicked@2x.png in Resources */,
3E242D5020FEB44D0015470D /* button_bar_spacer_dark@2x.png in Resources */,
582E939F168296F3003459FD /* link-arrow-highlighted@2x.png in Resources */,
582E93A0168296F3003459FD /* link-arrow@2x.png in Resources */,
582E93F6168298C6003459FD /* button_add_folder.png in Resources */,
@@ -3261,6 +3274,7 @@
BC85F5D012193B7D00E255B5 /* SPColorAdditions.m in Sources */,
BC878A71121A836F00AE5066 /* SPColorWellCell.m in Sources */,
BC398A2D121D526200BE3EF4 /* SPCopyTable.m in Sources */,
3E10740420FC25B7006DBDFD /* SPButtonBar.m in Sources */,
BC32F242121D66260067305E /* SPFileManagerAdditions.m in Sources */,
17A20AC6124F9B110095CEFB /* SPServerSupport.m in Sources */,
BC2898F3125F4488001B50E1 /* SPGeometryDataView.m in Sources */,

0 comments on commit 658d82a

Please sign in to comment.
You can’t perform that action at this time.