From 53ec85c6bbbd6b45f0d768dbf43bf422ea67529f Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 24 Feb 2018 11:04:47 -0800 Subject: [PATCH] Fix status bar color. --- .../Sidebar/SidebarStatusBarView.swift | 4 +-- .../Timeline/Cell/TimelineCellLayout.swift | 32 +++++++++++++++++++ .../Timeline/Cell/TimelineTableCellView.swift | 3 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Evergreen/MainWindow/Sidebar/SidebarStatusBarView.swift b/Evergreen/MainWindow/Sidebar/SidebarStatusBarView.swift index 6c85f50bc..dbd4df147 100644 --- a/Evergreen/MainWindow/Sidebar/SidebarStatusBarView.swift +++ b/Evergreen/MainWindow/Sidebar/SidebarStatusBarView.swift @@ -57,8 +57,8 @@ final class SidebarStatusBarView: NSView { return } -// let color = NSColor(calibratedWhite: 0.96, alpha: 1.0) - layer.backgroundColor = NSColor.white.cgColor + let color = NSColor(calibratedWhite: 0.96, alpha: 1.0) + layer.backgroundColor = color.cgColor didConfigureLayer = true } diff --git a/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift b/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift index 81b9b3bdc..9dd24cd62 100644 --- a/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift +++ b/Evergreen/MainWindow/Timeline/Cell/TimelineCellLayout.swift @@ -76,12 +76,44 @@ struct TimelineCellLayout { let layout = TimelineCellLayout(width: width, cellData: cellData, appearance: appearance) return layout.height } + + func adjustedForHeight(_ newHeight: CGFloat) -> TimelineCellLayout { + + // When the cell is laying out subviews, the height of the cell is known, + // and that height may not match the ideal height calculated in TimelineCellLayout. + // In that case we may need to adjust the layout. + + if abs(newHeight - height) < 0.01 { + return self + } + + return TimelineCellLayout(otherLayout: self, height: newHeight) + } } // MARK: - Calculate Rects private extension TimelineCellLayout { + private init(otherLayout: TimelineCellLayout, height: CGFloat) { + + self.width = otherLayout.width + self.feedNameRect = otherLayout.feedNameRect + self.dateRect = otherLayout.dateRect + self.titleRect = otherLayout.titleRect + self.numberOfLinesForTitle = otherLayout.numberOfLinesForTitle + self.summaryRect = otherLayout.summaryRect + self.textRect = otherLayout.textRect + self.unreadIndicatorRect = otherLayout.unreadIndicatorRect + self.starRect = otherLayout.starRect + self.paddingBottom = otherLayout.paddingBottom + + let bounds = NSRect(x: 0.0, y: 0.0, width: otherLayout.width, height: height) + self.avatarImageRect = RSRectCenteredVerticallyInRect(otherLayout.avatarImageRect, bounds) + + self.height = height + } + static func rectForTextBox(_ appearance: TimelineCellAppearance, _ cellData: TimelineCellData, _ width: CGFloat) -> NSRect { // Returned height is a placeholder. Not needed when this is calculated. diff --git a/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift b/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift index 4d0927a74..4516c0ad8 100644 --- a/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift +++ b/Evergreen/MainWindow/Timeline/Cell/TimelineTableCellView.swift @@ -237,7 +237,8 @@ private extension TimelineTableCellView { func updatedLayoutRects() -> TimelineCellLayout { - return TimelineCellLayout(width: bounds.width, cellData: cellData, appearance: cellAppearance) + let layout = TimelineCellLayout(width: bounds.width, cellData: cellData, appearance: cellAppearance) + return layout.adjustedForHeight(bounds.height) } func updateAppearance() {