Do less work in timeline table cell views, which should make scrolling imperceptibly faster.

This commit is contained in:
Brent Simmons 2019-02-07 22:01:31 -08:00
parent 6f41b2a728
commit 2ece915ac3
2 changed files with 12 additions and 14 deletions

View File

@ -11,6 +11,8 @@ import DB5
struct TimelineCellAppearance: Equatable { struct TimelineCellAppearance: Equatable {
let showAvatar: Bool
let cellPadding: NSEdgeInsets let cellPadding: NSEdgeInsets
let feedNameColor: NSColor let feedNameColor: NSColor
@ -45,7 +47,6 @@ struct TimelineCellAppearance: Equatable {
let avatarMarginLeft: CGFloat let avatarMarginLeft: CGFloat
let avatarAdjustmentTop: CGFloat let avatarAdjustmentTop: CGFloat
let avatarCornerRadius: CGFloat let avatarCornerRadius: CGFloat
let showAvatar: Bool
let boxLeftMargin: CGFloat let boxLeftMargin: CGFloat

View File

@ -32,11 +32,14 @@ class TimelineTableCellView: NSTableCellView {
var cellAppearance: TimelineCellAppearance! { var cellAppearance: TimelineCellAppearance! {
didSet { didSet {
updateTextFields() if cellAppearance != oldValue {
updateTextFieldColors()
updateTextFieldFonts()
avatarImageView.layer?.cornerRadius = cellAppearance.avatarCornerRadius avatarImageView.layer?.cornerRadius = cellAppearance.avatarCornerRadius
needsLayout = true needsLayout = true
} }
} }
}
var cellData: TimelineCellData! { var cellData: TimelineCellData! {
didSet { didSet {
@ -187,10 +190,10 @@ private extension TimelineTableCellView {
func updateTextFieldColors() { func updateTextFieldColors() {
updateTitleView() // updateTitleView()
if #available(macOS 10.14, *) { if #available(macOS 10.14, *) {
makeTextFieldColorsNormal() //makeTextFieldColorsNormal()
} }
else { else {
// Pre-Mojave: manually set colors to white when needed. // Pre-Mojave: manually set colors to white when needed.
@ -220,12 +223,6 @@ private extension TimelineTableCellView {
textView.font = cellAppearance.textOnlyFont textView.font = cellAppearance.textOnlyFont
} }
func updateTextFields() {
updateTextFieldColors()
updateTextFieldFonts()
}
func addSubviewAtInit(_ view: NSView, hidden: Bool) { func addSubviewAtInit(_ view: NSView, hidden: Bool) {
addSubview(view) addSubview(view)
@ -234,7 +231,6 @@ private extension TimelineTableCellView {
} }
func commonInit() { func commonInit() {
addSubviewAtInit(titleView, hidden: false) addSubviewAtInit(titleView, hidden: false)
addSubviewAtInit(summaryView, hidden: true) addSubviewAtInit(summaryView, hidden: true)
addSubviewAtInit(textView, hidden: true) addSubviewAtInit(textView, hidden: true)
@ -243,6 +239,8 @@ private extension TimelineTableCellView {
addSubviewAtInit(feedNameView, hidden: true) addSubviewAtInit(feedNameView, hidden: true)
addSubviewAtInit(avatarImageView, hidden: true) addSubviewAtInit(avatarImageView, hidden: true)
addSubviewAtInit(starView, hidden: true) addSubviewAtInit(starView, hidden: true)
makeTextFieldColorsNormal()
} }
func updatedLayoutRects() -> TimelineCellLayout { func updatedLayoutRects() -> TimelineCellLayout {
@ -356,7 +354,6 @@ private extension TimelineTableCellView {
} }
func updateSubviews() { func updateSubviews() {
updateTitleView() updateTitleView()
updateSummaryView() updateSummaryView()
updateTextView() updateTextView()