From af09a6327a6240863e2e475f1c4eefccb7651683 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 2 Apr 2023 11:46:31 +1200 Subject: [PATCH] Fix add icon sizing on macOS 10.14 --- ResForge/Classes/ResourceDataSource.swift | 2 +- ResForge/Classes/ResourceDocument.swift | 8 ++++---- ResForge/Template Editor/Elements/ElementRREF.swift | 2 +- ResForge/Template Editor/LinkingComboBox.swift | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ResForge/Classes/ResourceDataSource.swift b/ResForge/Classes/ResourceDataSource.swift index 916783d9..ed96c0cc 100644 --- a/ResForge/Classes/ResourceDataSource.swift +++ b/ResForge/Classes/ResourceDataSource.swift @@ -209,7 +209,7 @@ extension ResourceDataSource: NSOutlineViewDelegate, NSOutlineViewDataSource { } else { view = outlineView.makeView(withIdentifier: NSUserInterfaceItemIdentifier("HeaderCell"), owner: nil) as! NSTableCellView } - if #available(OSX 11.0, *) { + if #available(macOS 11.0, *) { // Remove leading/trailing spacing on macOS 11 for constraint in view.constraints { if constraint.firstAttribute == .leading || constraint.firstAttribute == .trailing { diff --git a/ResForge/Classes/ResourceDocument.swift b/ResForge/Classes/ResourceDocument.swift index a22d6d09..4153835d 100644 --- a/ResForge/Classes/ResourceDocument.swift +++ b/ResForge/Classes/ResourceDocument.swift @@ -348,7 +348,7 @@ class ResourceDocument: NSDocument, NSWindowDelegate, NSDraggingDestination, NST .flexibleSpace, .searchField ] - if #available(OSX 11.0, *) { + if #available(macOS 11.0, *) { defaults.removeFirst(.space) } return defaults @@ -356,7 +356,7 @@ class ResourceDocument: NSDocument, NSWindowDelegate, NSDraggingDestination, NST // Get a system symbol if on 11.0 or later, otherwise a standard image private func symbolImage(named name: String, fallback: String? = nil) -> NSImage? { - if #available(OSX 11.0, *) { + if #available(macOS 11.0, *) { return NSImage(systemSymbolName: name, accessibilityDescription: nil) } let image = NSImage(named: fallback ?? name) @@ -368,7 +368,7 @@ class ResourceDocument: NSDocument, NSWindowDelegate, NSDraggingDestination, NST // Create the toolbar items. On macOS 11 we use the special search toolbar item as well as the system symbol images. let item: NSToolbarItem if itemIdentifier == .searchField { - if #available(OSX 11.0, *) { + if #available(macOS 11.0, *) { let searchItem = NSSearchToolbarItem(itemIdentifier: itemIdentifier) searchItem.preferredWidthForSearchField = 180 searchField = searchItem.searchField @@ -461,7 +461,7 @@ class ResourceDocument: NSDocument, NSWindowDelegate, NSDraggingDestination, NST windowController.window?.registerForDraggedTypes([.RKResource]) self.updateStatus() NotificationCenter.default.addObserver(self, selector: #selector(validateToolbarItems(_:)), name: .DocumentSelectionDidChange, object: self) - if #available(OSX 11.0, *) { + if #available(macOS 11.0, *) { (statusText.superview?.superview as? NSBox)?.fillColor = .windowBackgroundColor } } diff --git a/ResForge/Template Editor/Elements/ElementRREF.swift b/ResForge/Template Editor/Elements/ElementRREF.swift index c33155a8..e9cfb899 100644 --- a/ResForge/Template Editor/Elements/ElementRREF.swift +++ b/ResForge/Template Editor/Elements/ElementRREF.swift @@ -53,7 +53,7 @@ class ElementRREF: BaseElement { if resource == nil { // The add icon isn't strictly supposed to be used outside of the touch bar - // It works fine on macOS 11 but for appropriate sizing on 10.14 we need to set the size explicitly (default is 18x30) - button.image?.size = NSSize(width: 14, height: 23) + button.image?.size = NSSize(width: 14, height: 24) } button.imagePosition = .imageRight button.target = self diff --git a/ResForge/Template Editor/LinkingComboBox.swift b/ResForge/Template Editor/LinkingComboBox.swift index 9b4cf5a3..4b1463d3 100644 --- a/ResForge/Template Editor/LinkingComboBox.swift +++ b/ResForge/Template Editor/LinkingComboBox.swift @@ -14,7 +14,8 @@ class LinkingComboBox: NSComboBox { } override init(frame frameRect: NSRect) { - let buttonFrame = NSRect(x: frameRect.size.width - 36, y: 6, width: 12, height: 12) + // To accommodate the touch bar add icon on macOS 10.14, we need to allow a height of 22 + let buttonFrame = NSRect(x: frameRect.size.width - 36, y: 1, width: 12, height: 22) linkButton = NSButton(frame: buttonFrame) super.init(frame: frameRect) linkButton.isBordered = false