git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit 27d42146baf52cd8346f7c24d2cb88b09c1618d7
parent 00e1c925a4e36b6a4fb492af4a6e89f37ecc5e18
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Mon, 18 Dec 2023 22:41:15 +0200

Fix compatibility with Catalina and older versions of macOS, improve printer UI

Diffstat:
MCocoa/Document.m14+++++++++++---
MCocoa/Document.xib19+++++++++++++------
ACocoa/NSToolbarItem+NoOverflow.m24++++++++++++++++++++++++
3 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/Cocoa/Document.m b/Cocoa/Document.m @@ -783,16 +783,22 @@ static unsigned *multiplication_table_for_frequency(unsigned frequency) if (@available(macOS 11.0, *)) { self.memoryWindow.toolbarStyle = NSWindowToolbarStyleExpanded; self.printerFeedWindow.toolbarStyle = NSWindowToolbarStyleUnifiedCompact; - self.printerFeedWindow.toolbar.items[0].image = + self.printerFeedWindow.toolbar.items[1].image = [NSImage imageWithSystemSymbolName:@"square.and.arrow.down" accessibilityDescription:@"Save"]; - self.printerFeedWindow.toolbar.items[1].image = + self.printerFeedWindow.toolbar.items[2].image = [NSImage imageWithSystemSymbolName:@"printer" accessibilityDescription:@"Print"]; - self.printerFeedWindow.toolbar.items[0].bordered = false; self.printerFeedWindow.toolbar.items[1].bordered = false; + self.printerFeedWindow.toolbar.items[2].bordered = false; } else { + NSToolbarItem *spinner = self.printerFeedWindow.toolbar.items[0]; + [self.printerFeedWindow.toolbar removeItemAtIndex:0]; + [self.printerFeedWindow.toolbar insertItemWithItemIdentifier:spinner.itemIdentifier atIndex:2]; + [self.printerFeedWindow.toolbar removeItemAtIndex:1]; + [self.printerFeedWindow.toolbar insertItemWithItemIdentifier:NSToolbarPrintItemIdentifier + atIndex:1]; [self.printerFeedWindow.toolbar insertItemWithItemIdentifier:NSToolbarFlexibleSpaceItemIdentifier atIndex:2]; } @@ -2239,9 +2245,11 @@ enum GBWindowResizeAction height:_currentPrinterImageData.length / 160 / sizeof(imageBytes[0]) scale:2.0]; NSRect frame = self.printerFeedWindow.frame; + double oldHeight = frame.size.height; frame.size = self.feedImageView.image.size; [self.printerFeedWindow setContentMaxSize:frame.size]; frame.size.height += self.printerFeedWindow.frame.size.height - self.printerFeedWindow.contentView.frame.size.height; + frame.origin.y -= frame.size.height - oldHeight; [self.printerFeedWindow setFrame:frame display:false animate: self.printerFeedWindow.isVisible]; [self.printerFeedWindow orderFront:NULL]; }); diff --git a/Cocoa/Document.xib b/Cocoa/Document.xib @@ -694,21 +694,27 @@ <action selector="savePrinterFeed:" target="-2" id="Dm3-h0-ch4"/> </connections> </toolbarItem> - <toolbarItem implicitItemIdentifier="NSToolbarPrintItem" explicitItemIdentifier="Print" id="mtd-zS-DXa"/> + <toolbarItem implicitItemIdentifier="0496ED81-2A03-445D-9818-97386BC78CBC" label="Print" paletteLabel="Print" tag="-1" image="printer" catalog="system" bordered="YES" id="L6N-6G-UWl"> + <size key="minSize" width="30" height="25"/> + <size key="maxSize" width="30" height="25"/> + <connections> + <action selector="printDocument:" target="-1" id="RLy-7k-iIR"/> + </connections> + </toolbarItem> <toolbarItem implicitItemIdentifier="NSToolbarSpaceItem" id="AoG-LH-J4b"/> <toolbarItem implicitItemIdentifier="NSToolbarFlexibleSpaceItem" id="Q0x-n5-Q2Y"/> - <toolbarItem implicitItemIdentifier="E8F74F8F-6DE2-4774-A690-F71D92CD932E" label="" paletteLabel="" tag="-1" sizingBehavior="auto" id="CJX-Ff-7iQ"> + <toolbarItem implicitItemIdentifier="E8F74F8F-6DE2-4774-A690-F71D92CD932E" label="" paletteLabel="" tag="-1" title="wtf" sizingBehavior="auto" id="CJX-Ff-7iQ"> <nil key="toolTip"/> - <progressIndicator key="view" wantsLayer="YES" maxValue="100" displayedWhenStopped="NO" indeterminate="YES" style="spinning" id="rrz-Uh-Nae"> - <rect key="frame" x="0.0" y="14" width="32" height="32"/> + <progressIndicator key="view" wantsLayer="YES" maxValue="100" displayedWhenStopped="NO" indeterminate="YES" controlSize="small" style="spinning" id="rrz-Uh-Nae"> + <rect key="frame" x="0.0" y="14" width="16" height="16"/> <autoresizingMask key="autoresizingMask"/> </progressIndicator> </toolbarItem> </allowedToolbarItems> <defaultToolbarItems> - <toolbarItem reference="CBz-1N-o0Q"/> - <toolbarItem reference="mtd-zS-DXa"/> <toolbarItem reference="CJX-Ff-7iQ"/> + <toolbarItem reference="CBz-1N-o0Q"/> + <toolbarItem reference="L6N-6G-UWl"/> </defaultToolbarItems> </toolbar> <point key="canvasLocation" x="-159" y="356"/> @@ -972,5 +978,6 @@ <image name="NSStopProgressFreestandingTemplate" width="15" height="15"/> <image name="NextTemplate" width="14" height="14"/> <image name="StepTemplate" width="14" height="14"/> + <image name="printer" catalog="system" width="18" height="16"/> </resources> </document> diff --git a/Cocoa/NSToolbarItem+NoOverflow.m b/Cocoa/NSToolbarItem+NoOverflow.m @@ -0,0 +1,24 @@ +#import <AppKit/AppKit.h> +#import <objc/runtime.h> + +static id nop(id self, SEL _cmd) +{ + return nil; +} + +static double blah(id self, SEL _cmd) +{ + return 80.0; +} + +@implementation NSToolbarItem (NoOverflow) + ++ (void)load +{ + // Prevent collapsing toolbar items into menu items, they don't work in that form + method_setImplementation(class_getInstanceMethod(self, @selector(menuFormRepresentation)), (IMP)nop); + // Prevent over-agressive collapsing of the Printer Feed menu + method_setImplementation(class_getInstanceMethod(NSClassFromString(@"NSToolbarTitleView"), @selector(minSize)), (IMP)blah); +} + +@end

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.