diff --git a/Cocoa/BigSurToolbar.h b/Cocoa/BigSurToolbar.h new file mode 100644 index 00000000..ea8b3700 --- /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 c7c1e35c..2c118336 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 1197c0f1..d02f5bd7 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 aa219d86..491f0c0f 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;