diff --git a/Mac/Base.lproj/MainWindow.storyboard b/Mac/Base.lproj/MainWindow.storyboard index 395954ad2..72d27d2ce 100644 --- a/Mac/Base.lproj/MainWindow.storyboard +++ b/Mac/Base.lproj/MainWindow.storyboard @@ -1,7 +1,8 @@ - + - + + @@ -314,20 +315,20 @@ - + - - + + - + @@ -340,7 +341,7 @@ - + @@ -358,7 +359,7 @@ - + @@ -616,9 +617,9 @@ - - - + + + diff --git a/Mac/MainWindow/Sidebar/Cell/SidebarCellAppearance.swift b/Mac/MainWindow/Sidebar/Cell/SidebarCellAppearance.swift index a2fe6f262..88b6e77b3 100644 --- a/Mac/MainWindow/Sidebar/Cell/SidebarCellAppearance.swift +++ b/Mac/MainWindow/Sidebar/Cell/SidebarCellAppearance.swift @@ -10,14 +10,29 @@ import AppKit struct SidebarCellAppearance: Equatable { - let imageSize = CGSize(width: 16, height: 16) + let imageSize: CGSize let imageMarginRight: CGFloat = 4.0 let unreadCountMarginLeft: CGFloat = 10.0 let textFieldFontSize: CGFloat let textFieldFont: NSFont - init(fontSize: FontSize) { - self.textFieldFontSize = AppDefaults.shared.actualFontSize(for: fontSize) + init(rowSizeStyle: NSTableView.RowSizeStyle) { + switch rowSizeStyle { + case .small: + imageSize = CGSize(width: 16, height: 16) + textFieldFontSize = 11 + case .large: + imageSize = CGSize(width: 24, height: 24) + if #available(macOS 10.16, *) { + textFieldFontSize = 15 + } else { + textFieldFontSize = 13 + } + default: + imageSize = CGSize(width: 20, height: 20) + textFieldFontSize = 13 + } + self.textFieldFont = NSFont.systemFont(ofSize: textFieldFontSize) } } diff --git a/Mac/MainWindow/Sidebar/SidebarViewController.swift b/Mac/MainWindow/Sidebar/SidebarViewController.swift index da708afc7..25fce6d31 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController.swift @@ -12,6 +12,10 @@ import Articles import Account import RSCore +extension Notification.Name { + static let appleSideBarDefaultIconSizeChanged = Notification.Name("AppleSideBarDefaultIconSizeChanged") +} + protocol SidebarDelegate: class { func sidebarSelectionDidChange(_: SidebarViewController, selectedObjects: [AnyObject]?) func unreadCount(for: AnyObject) -> Int @@ -46,7 +50,6 @@ protocol SidebarDelegate: class { var undoableCommands = [UndoableCommand]() private var animatingChanges = false - private var sidebarCellAppearance: SidebarCellAppearance! var renameWindowController: RenameWindowController? @@ -57,8 +60,6 @@ protocol SidebarDelegate: class { // MARK: - NSViewController override func viewDidLoad() { - sidebarCellAppearance = SidebarCellAppearance(fontSize: AppDefaults.shared.sidebarFontSize) - outlineView.dataSource = dataSource outlineView.doubleAction = #selector(doubleClickedSidebar(_:)) outlineView.setDraggingSourceOperationMask([.move, .copy], forLocal: true) @@ -76,6 +77,7 @@ protocol SidebarDelegate: class { NotificationCenter.default.addObserver(self, selector: #selector(webFeedIconDidBecomeAvailable(_:)), name: .WebFeedIconDidBecomeAvailable, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(webFeedSettingDidChange(_:)), name: .WebFeedSettingDidChange, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(displayNameDidChange(_:)), name: .DisplayNameDidChange, object: nil) + DistributedNotificationCenter.default().addObserver(self, selector: #selector(appleSideBarDefaultIconSizeChanged(_:)), name: .appleSideBarDefaultIconSizeChanged, object: nil) outlineView.reloadData() @@ -216,11 +218,14 @@ protocol SidebarDelegate: class { restoreSelection(to: savedSelection, sendNotificationIfChanged: true) } - @objc func userDidRequestSidebarSelection(_ note: Notification) { - guard let feed = note.userInfo?[UserInfoKey.webFeed] else { - return + @objc func appleSideBarDefaultIconSizeChanged(_ note: Notification) { + // The outline view doesn't have the new row style size set yet when we get + // this notification, so give it half a second to catch up. + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + let savedSelection = self.selectedNodes + self.outlineView.reloadData() + self.restoreSelection(to: savedSelection, sendNotificationIfChanged: true) } - revealAndSelectRepresentedObject(feed as AnyObject) } // MARK: - Actions @@ -727,7 +732,7 @@ private extension SidebarViewController { } func configure(_ cell: SidebarCell, _ node: Node) { - cell.cellAppearance = sidebarCellAppearance + cell.cellAppearance = SidebarCellAppearance(rowSizeStyle: outlineView.effectiveRowSizeStyle) cell.name = nameFor(node) configureUnreadCount(cell, node) configureFavicon(cell, node)