From 2ece915ac35a8599dbfc0fe9f566870fc4a970ab Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Thu, 7 Feb 2019 22:01:31 -0800 Subject: [PATCH] Do less work in timeline table cell views, which should make scrolling imperceptibly faster. --- .../Cell/TimelineCellAppearance.swift | 3 ++- .../Timeline/Cell/TimelineTableCellView.swift | 23 ++++++++----------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/NetNewsWire/MainWindow/Timeline/Cell/TimelineCellAppearance.swift b/NetNewsWire/MainWindow/Timeline/Cell/TimelineCellAppearance.swift index 0c6b7eaa7..2dabdd0ca 100644 --- a/NetNewsWire/MainWindow/Timeline/Cell/TimelineCellAppearance.swift +++ b/NetNewsWire/MainWindow/Timeline/Cell/TimelineCellAppearance.swift @@ -11,6 +11,8 @@ import DB5 struct TimelineCellAppearance: Equatable { + let showAvatar: Bool + let cellPadding: NSEdgeInsets let feedNameColor: NSColor @@ -45,7 +47,6 @@ struct TimelineCellAppearance: Equatable { let avatarMarginLeft: CGFloat let avatarAdjustmentTop: CGFloat let avatarCornerRadius: CGFloat - let showAvatar: Bool let boxLeftMargin: CGFloat diff --git a/NetNewsWire/MainWindow/Timeline/Cell/TimelineTableCellView.swift b/NetNewsWire/MainWindow/Timeline/Cell/TimelineTableCellView.swift index 848864e1a..4ea1aac9b 100644 --- a/NetNewsWire/MainWindow/Timeline/Cell/TimelineTableCellView.swift +++ b/NetNewsWire/MainWindow/Timeline/Cell/TimelineTableCellView.swift @@ -32,9 +32,12 @@ class TimelineTableCellView: NSTableCellView { var cellAppearance: TimelineCellAppearance! { didSet { - updateTextFields() - avatarImageView.layer?.cornerRadius = cellAppearance.avatarCornerRadius - needsLayout = true + if cellAppearance != oldValue { + updateTextFieldColors() + updateTextFieldFonts() + avatarImageView.layer?.cornerRadius = cellAppearance.avatarCornerRadius + needsLayout = true + } } } @@ -187,10 +190,10 @@ private extension TimelineTableCellView { func updateTextFieldColors() { - updateTitleView() +// updateTitleView() if #available(macOS 10.14, *) { - makeTextFieldColorsNormal() + //makeTextFieldColorsNormal() } else { // Pre-Mojave: manually set colors to white when needed. @@ -220,12 +223,6 @@ private extension TimelineTableCellView { textView.font = cellAppearance.textOnlyFont } - func updateTextFields() { - - updateTextFieldColors() - updateTextFieldFonts() - } - func addSubviewAtInit(_ view: NSView, hidden: Bool) { addSubview(view) @@ -234,7 +231,6 @@ private extension TimelineTableCellView { } func commonInit() { - addSubviewAtInit(titleView, hidden: false) addSubviewAtInit(summaryView, hidden: true) addSubviewAtInit(textView, hidden: true) @@ -243,6 +239,8 @@ private extension TimelineTableCellView { addSubviewAtInit(feedNameView, hidden: true) addSubviewAtInit(avatarImageView, hidden: true) addSubviewAtInit(starView, hidden: true) + + makeTextFieldColorsNormal() } func updatedLayoutRects() -> TimelineCellLayout { @@ -356,7 +354,6 @@ private extension TimelineTableCellView { } func updateSubviews() { - updateTitleView() updateSummaryView() updateTextView()