Change any glyphs in the sidebar to white when selected to make them visible regardless of use control color selection
This commit is contained in:
parent
c652486663
commit
73b120a91c
|
@ -118,15 +118,16 @@ struct AppAssets {
|
|||
return NSColor(named: NSColor.Name("iconDarkBackgroundColor"))!
|
||||
}()
|
||||
|
||||
static var masterFolderImage: IconImage = {
|
||||
static var masterFolderImage: IconImage {
|
||||
if #available(macOS 11.0, *) {
|
||||
let image = NSImage(systemSymbolName: "folder", accessibilityDescription: nil)!
|
||||
let coloredImage = image.tinted(with: NSColor(named: "AccentColor")!)
|
||||
return IconImage(coloredImage, isSymbol: true)
|
||||
let preferredColor = NSColor(named: "AccentColor")!
|
||||
let coloredImage = image.tinted(with: preferredColor)
|
||||
return IconImage(coloredImage, isSymbol: true, preferredColor: preferredColor.cgColor)
|
||||
} else {
|
||||
return IconImage(RSImage(named: NSImage.folderName)!)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
static var markAllAsReadImage: RSImage = {
|
||||
return RSImage(named: "markAllAsRead")!
|
||||
|
@ -211,8 +212,9 @@ struct AppAssets {
|
|||
static var starredFeedImage: IconImage = {
|
||||
if #available(macOS 11.0, *) {
|
||||
let image = NSImage(systemSymbolName: "star.fill", accessibilityDescription: nil)!
|
||||
let coloredImage = image.tinted(with: NSColor(named: "StarColor")!)
|
||||
return IconImage(coloredImage, isSymbol: true)
|
||||
let preferredColor = NSColor(named: "StarColor")!
|
||||
let coloredImage = image.tinted(with: preferredColor)
|
||||
return IconImage(coloredImage, isSymbol: true, preferredColor: preferredColor.cgColor)
|
||||
} else {
|
||||
return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!, isSymbol: true)
|
||||
}
|
||||
|
@ -231,8 +233,9 @@ struct AppAssets {
|
|||
static var todayFeedImage: IconImage = {
|
||||
if #available(macOS 11.0, *) {
|
||||
let image = NSImage(systemSymbolName: "sun.max.fill", accessibilityDescription: nil)!
|
||||
let coloredImage = image.tinted(with: .orange)
|
||||
return IconImage(coloredImage, isSymbol: true)
|
||||
let preferredColor = NSColor.orange
|
||||
let coloredImage = image.tinted(with: preferredColor)
|
||||
return IconImage(coloredImage, isSymbol: true, preferredColor: preferredColor.cgColor)
|
||||
} else {
|
||||
return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!, isSymbol: true)
|
||||
}
|
||||
|
@ -241,8 +244,9 @@ struct AppAssets {
|
|||
static var unreadFeedImage: IconImage = {
|
||||
if #available(macOS 11.0, *) {
|
||||
let image = NSImage(systemSymbolName: "largecircle.fill.circle", accessibilityDescription: nil)!
|
||||
let coloredImage = image.tinted(with: NSColor(named: "AccentColor")!)
|
||||
return IconImage(coloredImage, isSymbol: true)
|
||||
let preferredColor = NSColor(named: "AccentColor")!
|
||||
let coloredImage = image.tinted(with: preferredColor)
|
||||
return IconImage(coloredImage, isSymbol: true, preferredColor: preferredColor.cgColor)
|
||||
} else {
|
||||
return IconImage(RSImage(named: NSImage.smartBadgeTemplateName)!, isSymbol: true)
|
||||
}
|
||||
|
|
|
@ -15,12 +15,7 @@ class SidebarCell : NSTableCellView {
|
|||
|
||||
var iconImage: IconImage? {
|
||||
didSet {
|
||||
if let image = iconImage {
|
||||
faviconImageView.iconImage = shouldShowImage ? image : nil
|
||||
}
|
||||
else {
|
||||
faviconImageView.iconImage = nil
|
||||
}
|
||||
updateFaviconImage()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +28,6 @@ class SidebarCell : NSTableCellView {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
var cellAppearance: SidebarCellAppearance? {
|
||||
didSet {
|
||||
if cellAppearance != oldValue {
|
||||
|
@ -68,6 +62,12 @@ class SidebarCell : NSTableCellView {
|
|||
}
|
||||
}
|
||||
|
||||
var isSelected: Bool = false {
|
||||
didSet {
|
||||
updateFaviconImage()
|
||||
}
|
||||
}
|
||||
|
||||
private let titleView: NSTextField = {
|
||||
let textField = NSTextField(labelWithString: "")
|
||||
textField.usesSingleLineMode = true
|
||||
|
@ -79,7 +79,6 @@ class SidebarCell : NSTableCellView {
|
|||
}()
|
||||
|
||||
private let faviconImageView = IconView()
|
||||
|
||||
private let unreadCountView = UnreadCountView(frame: NSZeroRect)
|
||||
|
||||
override var isFlipped: Bool {
|
||||
|
@ -137,5 +136,31 @@ private extension SidebarCell {
|
|||
titleView.setFrame(ifNotEqualTo: layout.titleRect)
|
||||
unreadCountView.setFrame(ifNotEqualTo: layout.unreadCountRect)
|
||||
}
|
||||
|
||||
func updateFaviconImage() {
|
||||
var updatedIconImage = iconImage
|
||||
|
||||
if let iconImage = iconImage, iconImage.isSymbol {
|
||||
if isSelected {
|
||||
let image = iconImage.image.tinted(with: .white)
|
||||
updatedIconImage = IconImage(image, isSymbol: true)
|
||||
} else {
|
||||
if let preferredColor = iconImage.preferredColor {
|
||||
let image = iconImage.image.tinted(with: NSColor(cgColor: preferredColor)!)
|
||||
updatedIconImage = IconImage(image, isSymbol: true)
|
||||
} else {
|
||||
let image = iconImage.image.tinted(with: .controlAccentColor)
|
||||
updatedIconImage = IconImage(image, isSymbol: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let image = updatedIconImage {
|
||||
faviconImageView.iconImage = shouldShowImage ? image : nil
|
||||
} else {
|
||||
faviconImageView.iconImage = nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// SidebarTableRowView.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Maurice Parker on 8/10/20.
|
||||
// Copyright © 2020 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import AppKit
|
||||
|
||||
class SidebarTableRowView : NSTableRowView {
|
||||
|
||||
override var isSelected: Bool {
|
||||
didSet {
|
||||
cellView?.isSelected = isSelected
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
super.init(frame: NSRect.zero)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
}
|
||||
|
||||
private var cellView: SidebarCell? {
|
||||
for oneSubview in subviews {
|
||||
if let foundView = oneSubview as? SidebarCell {
|
||||
return foundView
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
|
@ -57,6 +57,8 @@ protocol SidebarDelegate: class {
|
|||
return selectedNodes.representedObjects()
|
||||
}
|
||||
|
||||
private static let rowViewIdentifier = NSUserInterfaceItemIdentifier(rawValue: "sidebarRow")
|
||||
|
||||
// MARK: - NSViewController
|
||||
|
||||
override func viewDidLoad() {
|
||||
|
@ -340,6 +342,15 @@ protocol SidebarDelegate: class {
|
|||
|
||||
// MARK: - NSOutlineViewDelegate
|
||||
|
||||
func outlineView(_ outlineView: NSOutlineView, rowViewForItem item: Any) -> NSTableRowView? {
|
||||
if let rowView = outlineView.makeView(withIdentifier: SidebarViewController.rowViewIdentifier, owner: nil) as? SidebarTableRowView {
|
||||
return rowView
|
||||
}
|
||||
let rowView = SidebarTableRowView()
|
||||
rowView.identifier = SidebarViewController.rowViewIdentifier
|
||||
return rowView
|
||||
}
|
||||
|
||||
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
|
||||
let node = item as! Node
|
||||
|
||||
|
|
|
@ -303,6 +303,8 @@
|
|||
5194736F24BBB937001A2939 /* HiddenModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5194736D24BBB937001A2939 /* HiddenModifier.swift */; };
|
||||
5194737124BBCAF4001A2939 /* TimelineSortOrderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5194737024BBCAF4001A2939 /* TimelineSortOrderView.swift */; };
|
||||
519B8D332143397200FA689C /* SharingServiceDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519B8D322143397200FA689C /* SharingServiceDelegate.swift */; };
|
||||
519D2F2524E1C03300AD7D8A /* SidebarTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519D2F2424E1C03300AD7D8A /* SidebarTableRowView.swift */; };
|
||||
519D2F2624E1C03300AD7D8A /* SidebarTableRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519D2F2424E1C03300AD7D8A /* SidebarTableRowView.swift */; };
|
||||
519E743D22C663F900A78E47 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519E743422C663F900A78E47 /* SceneDelegate.swift */; };
|
||||
519ED456244828C3007F8E94 /* AddExtensionPointViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519ED455244828C3007F8E94 /* AddExtensionPointViewController.swift */; };
|
||||
519ED47A24482AEB007F8E94 /* EnableExtensionPointViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 519ED47924482AEB007F8E94 /* EnableExtensionPointViewController.swift */; };
|
||||
|
@ -1595,6 +1597,7 @@
|
|||
5194736D24BBB937001A2939 /* HiddenModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HiddenModifier.swift; sourceTree = "<group>"; };
|
||||
5194737024BBCAF4001A2939 /* TimelineSortOrderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineSortOrderView.swift; sourceTree = "<group>"; };
|
||||
519B8D322143397200FA689C /* SharingServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingServiceDelegate.swift; sourceTree = "<group>"; };
|
||||
519D2F2424E1C03300AD7D8A /* SidebarTableRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarTableRowView.swift; sourceTree = "<group>"; };
|
||||
519E743422C663F900A78E47 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
|
||||
519ED455244828C3007F8E94 /* AddExtensionPointViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddExtensionPointViewController.swift; sourceTree = "<group>"; };
|
||||
519ED47924482AEB007F8E94 /* EnableExtensionPointViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnableExtensionPointViewController.swift; sourceTree = "<group>"; };
|
||||
|
@ -3050,16 +3053,17 @@
|
|||
849A975F1ED9EB95007D329B /* Sidebar */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
849A97621ED9EB96007D329B /* SidebarViewController.swift */,
|
||||
84B7178B201E66580091657D /* SidebarViewController+ContextualMenus.swift */,
|
||||
84AD1EA92031617300BC20B7 /* PasteboardFolder.swift */,
|
||||
848D578D21543519005FFAD5 /* PasteboardWebFeed.swift */,
|
||||
84AD1EBB2032AF5C00BC20B7 /* SidebarOutlineDataSource.swift */,
|
||||
849A97601ED9EB96007D329B /* SidebarOutlineView.swift */,
|
||||
849A97631ED9EB96007D329B /* UnreadCountView.swift */,
|
||||
848D578D21543519005FFAD5 /* PasteboardWebFeed.swift */,
|
||||
84AD1EA92031617300BC20B7 /* PasteboardFolder.swift */,
|
||||
849A97821ED9EC63007D329B /* SidebarStatusBarView.swift */,
|
||||
844B5B6A1FEA224000C7C76A /* Keyboard */,
|
||||
519D2F2424E1C03300AD7D8A /* SidebarTableRowView.swift */,
|
||||
849A97621ED9EB96007D329B /* SidebarViewController.swift */,
|
||||
84B7178B201E66580091657D /* SidebarViewController+ContextualMenus.swift */,
|
||||
849A97631ED9EB96007D329B /* UnreadCountView.swift */,
|
||||
845A29251FC928C7007B49E3 /* Cell */,
|
||||
844B5B6A1FEA224000C7C76A /* Keyboard */,
|
||||
84A37CB3201ECD610087C5AF /* Renaming */,
|
||||
);
|
||||
path = Sidebar;
|
||||
|
@ -4748,6 +4752,7 @@
|
|||
65ED3FED235DEF6C0081F399 /* SendToMarsEditCommand.swift in Sources */,
|
||||
514A89A6244FD6640085E65D /* AddTwitterFeedWindowController.swift in Sources */,
|
||||
65ED3FEE235DEF6C0081F399 /* UserNotificationManager.swift in Sources */,
|
||||
519D2F2624E1C03300AD7D8A /* SidebarTableRowView.swift in Sources */,
|
||||
65ED3FEF235DEF6C0081F399 /* ScriptingObjectContainer.swift in Sources */,
|
||||
65ED3FF0235DEF6C0081F399 /* ArticleStylesManager.swift in Sources */,
|
||||
65ED3FF1235DEF6C0081F399 /* DetailContainerView.swift in Sources */,
|
||||
|
@ -5150,6 +5155,7 @@
|
|||
848D578E21543519005FFAD5 /* PasteboardWebFeed.swift in Sources */,
|
||||
5144EA2F2279FAB600D19003 /* AccountsDetailViewController.swift in Sources */,
|
||||
849A97801ED9EC42007D329B /* DetailViewController.swift in Sources */,
|
||||
519D2F2524E1C03300AD7D8A /* SidebarTableRowView.swift in Sources */,
|
||||
518C3193237B00D9004D740F /* DetailIconSchemeHandler.swift in Sources */,
|
||||
84C9FC6722629B9000D921D6 /* AppDelegate.swift in Sources */,
|
||||
84C9FC7A22629E1200D921D6 /* PreferencesTableViewBackgroundView.swift in Sources */,
|
||||
|
|
|
@ -25,11 +25,13 @@ final class IconImage {
|
|||
}()
|
||||
|
||||
let image: RSImage
|
||||
var isSymbol: Bool
|
||||
let isSymbol: Bool
|
||||
let preferredColor: CGColor?
|
||||
|
||||
init(_ image: RSImage, isSymbol: Bool = false) {
|
||||
init(_ image: RSImage, isSymbol: Bool = false, preferredColor: CGColor? = nil) {
|
||||
self.image = image
|
||||
self.isSymbol = isSymbol
|
||||
self.preferredColor = preferredColor
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue