Skip to content

Commit

Permalink
Fix add icon sizing on macOS 10.14
Browse files Browse the repository at this point in the history
  • Loading branch information
andrews05 committed Apr 1, 2023
1 parent 9026010 commit af09a63
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ResForge/Classes/ResourceDataSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions ResForge/Classes/ResourceDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,15 @@ class ResourceDocument: NSDocument, NSWindowDelegate, NSDraggingDestination, NST
.flexibleSpace,
.searchField
]
if #available(OSX 11.0, *) {
if #available(macOS 11.0, *) {
defaults.removeFirst(.space)
}
return defaults
}

// 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)
Expand All @@ -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
Expand Down Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion ResForge/Template Editor/Elements/ElementRREF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion ResForge/Template Editor/LinkingComboBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit af09a63

Please sign in to comment.