From c2410a4ffc41388fd71aee6d6e308ff269ce9829 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 22 Aug 2020 03:27:57 +0300 Subject: [PATCH] Update UI for Big Sur --- Cocoa/BigSurToolbar.h | 30 ++++++++++++++++++++++++++++++ Cocoa/Document.m | 12 ++++++++++++ Cocoa/Document.xib | 10 ++++------ Cocoa/GBPreferencesWindow.m | 6 ++++++ 4 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 Cocoa/BigSurToolbar.h diff --git a/Cocoa/BigSurToolbar.h b/Cocoa/BigSurToolbar.h new file mode 100644 index 0000000..ea8b370 --- /dev/null +++ b/Cocoa/BigSurToolbar.h @@ -0,0 +1,30 @@ +#import +#ifndef BigSurToolbar_h +#define BigSurToolbar_h + +/* Backport the toolbarStyle property to allow compilation with older SDKs*/ +#ifndef __MAC_10_16 +typedef NS_ENUM(NSInteger, NSWindowToolbarStyle) { + // The default value. The style will be determined by the window's given configuration + NSWindowToolbarStyleAutomatic, + // The toolbar will appear below the window title + NSWindowToolbarStyleExpanded, + // The toolbar will appear below the window title and the items in the toolbar will attempt to have equal widths when possible + NSWindowToolbarStylePreference, + // The window title will appear inline with the toolbar when visible + NSWindowToolbarStyleUnified, + // Same as NSWindowToolbarStyleUnified, but with reduced margins in the toolbar allowing more focus to be on the contents of the window + NSWindowToolbarStyleUnifiedCompact +} API_AVAILABLE(macos(11.0)); + +@interface NSWindow (toolbarStyle) +@property NSWindowToolbarStyle toolbarStyle API_AVAILABLE(macos(11.0)); +@end + +@interface NSImage (SFSymbols) ++ (instancetype)imageWithSystemSymbolName:(NSString *)symbolName accessibilityDescription:(NSString *)description API_AVAILABLE(macos(11.0)); +@end + +#endif + +#endif diff --git a/Cocoa/Document.m b/Cocoa/Document.m index c7c1e35..2c11833 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -9,6 +9,7 @@ #include "GBWarningPopover.h" #include "GBCheatWindowController.h" #include "GBTerminalTextFieldCell.h" +#include "BigSurToolbar.h" /* Todo: The general Objective-C coding style conflicts with SameBoy's. This file needs a cleanup. */ /* Todo: Split into category files! This is so messy!!! */ @@ -569,6 +570,17 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) self.consoleWindow.title = [NSString stringWithFormat:@"Debug Console – %@", [[self.fileURL path] lastPathComponent]]; self.debuggerSplitView.dividerColor = [NSColor clearColor]; + if (@available(macOS 11.0, *)) { + self.memoryWindow.toolbarStyle = NSWindowToolbarStyleExpanded; + self.printerFeedWindow.toolbarStyle = NSWindowToolbarStyleUnifiedCompact; + [self.printerFeedWindow.toolbar removeItemAtIndex:1]; + self.printerFeedWindow.toolbar.items.firstObject.image = + [NSImage imageWithSystemSymbolName:@"square.and.arrow.down" + accessibilityDescription:@"Save"]; + self.printerFeedWindow.toolbar.items.lastObject.image = + [NSImage imageWithSystemSymbolName:@"printer" + accessibilityDescription:@"Print"]; + } [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateHighpassFilter) diff --git a/Cocoa/Document.xib b/Cocoa/Document.xib index 1197c0f..d02f5bd 100644 --- a/Cocoa/Document.xib +++ b/Cocoa/Document.xib @@ -115,7 +115,7 @@ - + @@ -152,7 +152,7 @@ - + @@ -186,7 +186,7 @@ - + @@ -800,13 +800,11 @@ - - - + diff --git a/Cocoa/GBPreferencesWindow.m b/Cocoa/GBPreferencesWindow.m index aa219d8..491f0c0 100644 --- a/Cocoa/GBPreferencesWindow.m +++ b/Cocoa/GBPreferencesWindow.m @@ -1,6 +1,7 @@ #import "GBPreferencesWindow.h" #import "NSString+StringForKey.h" #import "GBButtons.h" +#import "BigSurToolbar.h" #import @implementation GBPreferencesWindow @@ -52,6 +53,11 @@ return filters; } +- (NSWindowToolbarStyle)toolbarStyle +{ + return NSWindowToolbarStylePreference; +} + - (void)close { joystick_configuration_state = -1;