2017-05-27 19:43:27 +02:00
|
|
|
//
|
|
|
|
// TimelineCellAppearance.swift
|
|
|
|
// Evergreen
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 2/6/16.
|
|
|
|
// Copyright © 2016 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2018-02-03 07:51:32 +01:00
|
|
|
import AppKit
|
2017-05-27 19:43:27 +02:00
|
|
|
import DB5
|
|
|
|
|
2018-01-05 06:20:09 +01:00
|
|
|
struct TimelineCellAppearance: Equatable {
|
2017-05-27 19:43:27 +02:00
|
|
|
|
2017-09-17 21:34:10 +02:00
|
|
|
let cellPadding: NSEdgeInsets
|
2017-05-27 19:43:27 +02:00
|
|
|
|
|
|
|
let feedNameColor: NSColor
|
|
|
|
let feedNameFont: NSFont
|
2018-01-05 06:20:09 +01:00
|
|
|
|
2017-05-27 19:43:27 +02:00
|
|
|
let dateColor: NSColor
|
|
|
|
let dateMarginLeft: CGFloat
|
|
|
|
let dateFont: NSFont
|
|
|
|
|
|
|
|
let titleColor: NSColor
|
|
|
|
let titleFont: NSFont
|
|
|
|
let titleBottomMargin: CGFloat
|
2018-02-22 07:48:34 +01:00
|
|
|
let titleNumberOfLines: Int
|
2017-05-27 19:43:27 +02:00
|
|
|
|
|
|
|
let textColor: NSColor
|
|
|
|
let textFont: NSFont
|
2018-02-19 01:13:58 +01:00
|
|
|
|
|
|
|
let textOnlyColor: NSColor
|
|
|
|
let textOnlyFont: NSFont
|
|
|
|
|
2017-05-27 19:43:27 +02:00
|
|
|
let unreadCircleColor: NSColor
|
|
|
|
let unreadCircleDimension: CGFloat
|
|
|
|
let unreadCircleMarginRight: CGFloat
|
2018-02-18 06:46:19 +01:00
|
|
|
|
|
|
|
let starDimension: CGFloat
|
|
|
|
|
2017-05-27 19:43:27 +02:00
|
|
|
let gridColor: NSColor
|
2018-02-18 22:00:54 +01:00
|
|
|
let drawsGrid: Bool
|
2017-11-29 06:39:09 +01:00
|
|
|
|
|
|
|
let avatarSize: NSSize
|
|
|
|
let avatarMarginRight: CGFloat
|
2018-02-19 00:13:47 +01:00
|
|
|
let avatarMarginLeft: CGFloat
|
2017-11-29 06:39:09 +01:00
|
|
|
let avatarAdjustmentTop: CGFloat
|
2017-12-31 21:10:30 +01:00
|
|
|
let avatarCornerRadius: CGFloat
|
2018-01-05 06:20:09 +01:00
|
|
|
let showAvatar: Bool
|
|
|
|
|
|
|
|
let boxLeftMargin: CGFloat
|
|
|
|
|
|
|
|
init(theme: VSTheme, showAvatar: Bool, fontSize: FontSize) {
|
2017-05-27 19:43:27 +02:00
|
|
|
|
2017-11-25 06:39:59 +01:00
|
|
|
let actualFontSize = AppDefaults.actualFontSize(for: fontSize)
|
2018-02-19 05:28:31 +01:00
|
|
|
let smallItemFontSize = floor(actualFontSize * 0.95)
|
|
|
|
let largeItemFontSize = floor(actualFontSize * 1.1)
|
|
|
|
|
2017-11-29 06:39:09 +01:00
|
|
|
self.cellPadding = theme.edgeInsets(forKey: "MainWindow.Timeline.cell.padding")
|
2017-05-27 19:43:27 +02:00
|
|
|
|
2017-11-29 06:39:09 +01:00
|
|
|
self.feedNameColor = theme.color(forKey: "MainWindow.Timeline.cell.feedNameColor")
|
2018-02-19 05:28:31 +01:00
|
|
|
self.feedNameFont = NSFont.systemFont(ofSize: smallItemFontSize)
|
2017-05-27 19:43:27 +02:00
|
|
|
|
2017-11-29 06:39:09 +01:00
|
|
|
self.dateColor = theme.color(forKey: "MainWindow.Timeline.cell.dateColor")
|
2018-02-19 05:28:31 +01:00
|
|
|
self.dateFont = NSFont.systemFont(ofSize: smallItemFontSize)
|
2017-11-29 06:39:09 +01:00
|
|
|
self.dateMarginLeft = theme.float(forKey: "MainWindow.Timeline.cell.dateMarginLeft")
|
2017-05-27 19:43:27 +02:00
|
|
|
|
2017-11-29 06:39:09 +01:00
|
|
|
self.titleColor = theme.color(forKey: "MainWindow.Timeline.cell.titleColor")
|
2018-02-19 05:28:31 +01:00
|
|
|
self.titleFont = NSFont.systemFont(ofSize: largeItemFontSize, weight: NSFont.Weight.semibold)
|
2017-11-29 06:39:09 +01:00
|
|
|
self.titleBottomMargin = theme.float(forKey: "MainWindow.Timeline.cell.titleMarginBottom")
|
2018-02-22 07:48:34 +01:00
|
|
|
self.titleNumberOfLines = theme.integer(forKey: "MainWindow.Timeline.cell.titleMaximumLines")
|
|
|
|
|
2017-11-29 06:39:09 +01:00
|
|
|
self.textColor = theme.color(forKey: "MainWindow.Timeline.cell.textColor")
|
2018-02-19 05:28:31 +01:00
|
|
|
self.textFont = NSFont.systemFont(ofSize: largeItemFontSize)
|
2018-02-19 01:13:58 +01:00
|
|
|
|
|
|
|
self.textOnlyColor = theme.color(forKey: "MainWindow.Timeline.cell.textOnlyColor")
|
2018-02-19 05:28:31 +01:00
|
|
|
self.textOnlyFont = NSFont.systemFont(ofSize: largeItemFontSize)
|
|
|
|
|
2017-11-29 06:39:09 +01:00
|
|
|
self.unreadCircleColor = theme.color(forKey: "MainWindow.Timeline.cell.unreadCircleColor")
|
|
|
|
self.unreadCircleDimension = theme.float(forKey: "MainWindow.Timeline.cell.unreadCircleDimension")
|
|
|
|
self.unreadCircleMarginRight = theme.float(forKey: "MainWindow.Timeline.cell.unreadCircleMarginRight")
|
2018-02-18 06:46:19 +01:00
|
|
|
|
|
|
|
self.starDimension = theme.float(forKey: "MainWindow.Timeline.cell.starDimension")
|
2017-05-27 19:43:27 +02:00
|
|
|
|
2017-11-29 06:39:09 +01:00
|
|
|
self.gridColor = theme.colorWithAlpha(forKey: "MainWindow.Timeline.gridColor")
|
2018-02-18 22:00:54 +01:00
|
|
|
self.drawsGrid = theme.bool(forKey: "MainWindow.Timeline.drawsGrid")
|
|
|
|
|
2017-11-29 06:39:09 +01:00
|
|
|
self.avatarSize = theme.size(forKey: "MainWindow.Timeline.cell.avatar")
|
|
|
|
self.avatarMarginRight = theme.float(forKey: "MainWindow.Timeline.cell.avatarMarginRight")
|
2018-02-19 00:13:47 +01:00
|
|
|
self.avatarMarginLeft = theme.float(forKey: "MainWindow.Timeline.cell.avatarMarginLeft")
|
2017-11-29 06:39:09 +01:00
|
|
|
self.avatarAdjustmentTop = theme.float(forKey: "MainWindow.Timeline.cell.avatarAdjustmentTop")
|
2017-12-31 21:10:30 +01:00
|
|
|
self.avatarCornerRadius = theme.float(forKey: "MainWindow.Timeline.cell.avatarCornerRadius")
|
2018-01-05 06:20:09 +01:00
|
|
|
self.showAvatar = showAvatar
|
|
|
|
|
2018-02-19 00:13:47 +01:00
|
|
|
let margin = self.cellPadding.left + self.unreadCircleDimension + self.unreadCircleMarginRight
|
2018-01-05 06:20:09 +01:00
|
|
|
self.boxLeftMargin = margin
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:48:34 +01:00
|
|
|
// TODO: update the below
|
2018-01-05 06:20:09 +01:00
|
|
|
static func ==(lhs: TimelineCellAppearance, rhs: TimelineCellAppearance) -> Bool {
|
|
|
|
|
|
|
|
return lhs.boxLeftMargin == rhs.boxLeftMargin && lhs.showAvatar == rhs.showAvatar && lhs.cellPadding == rhs.cellPadding && lhs.feedNameColor == rhs.feedNameColor && lhs.feedNameFont == rhs.feedNameFont && lhs.dateColor == rhs.dateColor && lhs.dateMarginLeft == rhs.dateMarginLeft && lhs.dateFont == rhs.dateFont && lhs.titleColor == rhs.titleColor && lhs.titleFont == rhs.titleFont && lhs.titleBottomMargin == rhs.titleBottomMargin && lhs.textColor == rhs.textColor && lhs.textFont == rhs.textFont && lhs.unreadCircleColor == rhs.unreadCircleColor && lhs.unreadCircleDimension == rhs.unreadCircleDimension && lhs.unreadCircleMarginRight == rhs.unreadCircleMarginRight && lhs.gridColor == rhs.gridColor && lhs.avatarSize == rhs.avatarSize && lhs.avatarMarginRight == rhs.avatarMarginRight && lhs.avatarAdjustmentTop == rhs.avatarAdjustmentTop && lhs.avatarCornerRadius == rhs.avatarCornerRadius
|
2017-05-27 19:43:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-05 06:20:09 +01:00
|
|
|
extension NSEdgeInsets: Equatable {
|
|
|
|
|
|
|
|
public static func ==(lhs: NSEdgeInsets, rhs: NSEdgeInsets) -> Bool {
|
|
|
|
|
|
|
|
return lhs.left == rhs.left && lhs.top == rhs.top && lhs.right == rhs.right && lhs.bottom == rhs.bottom
|
|
|
|
}
|
|
|
|
}
|