From 52b1ef2350eca5e4d13cd62d5538e3e46ba3e2d3 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 12 May 2019 20:42:52 -0700 Subject: [PATCH] Place avatars on the left in the timeline. --- .../Cell/TimelineCellAppearance.swift | 1 + .../Timeline/Cell/TimelineCellLayout.swift | 19 ++++++------------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/Mac/MainWindow/Timeline/Cell/TimelineCellAppearance.swift b/Mac/MainWindow/Timeline/Cell/TimelineCellAppearance.swift index 61e7caa4d..32954075c 100644 --- a/Mac/MainWindow/Timeline/Cell/TimelineCellAppearance.swift +++ b/Mac/MainWindow/Timeline/Cell/TimelineCellAppearance.swift @@ -37,6 +37,7 @@ struct TimelineCellAppearance: Equatable { let avatarSize = NSSize(width: 48, height: 48) let avatarMarginLeft: CGFloat = 8.0 + let avatarMarginRight: CGFloat = 8.0 let avatarAdjustmentTop: CGFloat = 4.0 let avatarCornerRadius: CGFloat = 4.0 diff --git a/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift b/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift index ce39bd8fa..fcefc3420 100644 --- a/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift +++ b/Mac/MainWindow/Timeline/Cell/TimelineCellLayout.swift @@ -50,7 +50,7 @@ struct TimelineCellLayout { // If height == 0.0, then height is calculated. - let showAvatar = hasAvatar && cellData.showAvatar + let showAvatar = cellData.showAvatar var textBoxRect = TimelineCellLayout.rectForTextBox(appearance, cellData, showAvatar, width) let (titleRect, numberOfLinesForTitle) = TimelineCellLayout.rectForTitle(textBoxRect, appearance, cellData) @@ -94,8 +94,9 @@ private extension TimelineCellLayout { // Returned height is a placeholder. Not needed when this is calculated. - let textBoxOriginX = appearance.cellPadding.left + appearance.unreadCircleDimension + appearance.unreadCircleMarginRight - let textBoxMaxX = floor((width - appearance.cellPadding.right) - (showAvatar ? appearance.avatarSize.width + appearance.avatarMarginLeft : 0.0)) + let avatarSpace = showAvatar ? appearance.avatarSize.width + appearance.avatarMarginRight : 0.0 + let textBoxOriginX = appearance.cellPadding.left + appearance.unreadCircleDimension + appearance.unreadCircleMarginRight + avatarSpace + let textBoxMaxX = floor(width - appearance.cellPadding.right) let textBoxWidth = floor(textBoxMaxX - textBoxOriginX) let textBoxRect = NSRect(x: textBoxOriginX, y: appearance.cellPadding.top, width: textBoxWidth, height: 1000000) @@ -204,16 +205,8 @@ private extension TimelineCellLayout { return r } r.size = appearance.avatarSize - r.origin.x = (width - appearance.cellPadding.right) - r.size.width - r.origin.y = textBoxRect.origin.y + 4.0 -// r = RSRectCenteredVerticallyInRect(r, textBoxRect) -// if height > 0.1 { -// let bounds = NSRect(x: 0.0, y: 0.0, width: width, height: height) -// r = RSRectCenteredVerticallyInRect(r, bounds) -// } -// else { -// r = RSRectCenteredVerticallyInRect(r, textBoxRect) -// } + r.origin.x = appearance.cellPadding.left + appearance.unreadCircleDimension + appearance.unreadCircleMarginRight + r.origin.y = textBoxRect.origin.y + appearance.avatarAdjustmentTop return r }