2017-05-27 10:43:27 -07:00
|
|
|
|
//
|
|
|
|
|
|
// TimelineTableRowView.swift
|
2018-08-28 22:18:24 -07:00
|
|
|
|
// NetNewsWire
|
2017-05-27 10:43:27 -07:00
|
|
|
|
//
|
|
|
|
|
|
// Created by Brent Simmons on 8/31/15.
|
|
|
|
|
|
// Copyright © 2015 Ranchero Software, LLC. All rights reserved.
|
|
|
|
|
|
//
|
|
|
|
|
|
|
2018-02-02 22:51:32 -08:00
|
|
|
|
import AppKit
|
2017-05-27 10:43:27 -07:00
|
|
|
|
|
2026-01-01 18:07:54 -08:00
|
|
|
|
final class TimelineTableRowView: NSTableRowView {
|
2017-05-27 10:43:27 -07:00
|
|
|
|
|
2026-11-06 08:25:07 -08:00
|
|
|
|
/// The last row has no separator below it.
|
|
|
|
|
|
var isLastRow = false {
|
2026-11-05 21:05:45 -08:00
|
|
|
|
didSet {
|
2026-11-06 08:25:07 -08:00
|
|
|
|
if isLastRow != oldValue {
|
|
|
|
|
|
needsDisplay = true
|
2026-11-05 21:05:45 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-06 08:25:07 -08:00
|
|
|
|
private static let separatorInsetLeft: CGFloat = 20.0
|
|
|
|
|
|
private static let separatorInsetRight: CGFloat = 4.0
|
|
|
|
|
|
private static let separatorHeight: CGFloat = 1.0
|
|
|
|
|
|
|
2019-05-13 21:42:47 -07:00
|
|
|
|
override var isOpaque: Bool {
|
|
|
|
|
|
return true
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-05-21 16:08:16 -05:00
|
|
|
|
override var isEmphasized: Bool {
|
|
|
|
|
|
didSet {
|
|
|
|
|
|
cellView?.isEmphasized = isEmphasized
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-05 11:22:10 -08:00
|
|
|
|
|
2019-05-21 16:08:16 -05:00
|
|
|
|
override var isSelected: Bool {
|
|
|
|
|
|
didSet {
|
|
|
|
|
|
cellView?.isSelected = isSelected
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-05 11:22:10 -08:00
|
|
|
|
|
2019-02-13 21:33:50 -08:00
|
|
|
|
init() {
|
|
|
|
|
|
super.init(frame: NSRect.zero)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
|
|
super.init(coder: coder)
|
|
|
|
|
|
}
|
2025-11-05 11:22:10 -08:00
|
|
|
|
|
2017-05-27 10:43:27 -07:00
|
|
|
|
private var cellView: TimelineTableCellView? {
|
2018-02-14 13:14:25 -08:00
|
|
|
|
for oneSubview in subviews {
|
|
|
|
|
|
if let foundView = oneSubview as? TimelineTableCellView {
|
|
|
|
|
|
return foundView
|
2017-05-27 10:43:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-02-14 13:14:25 -08:00
|
|
|
|
return nil
|
2017-05-27 10:43:27 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-11-06 08:25:07 -08:00
|
|
|
|
/// Called only when the table’s `gridStyleMask` includes horizontal lines. Inset to line up with the cell’s content.
|
|
|
|
|
|
override func drawSeparator(in dirtyRect: NSRect) {
|
|
|
|
|
|
guard !isLastRow, !isSelected, let cellView else {
|
|
|
|
|
|
return
|
2020-11-19 13:44:08 -06:00
|
|
|
|
}
|
2026-11-06 08:25:07 -08:00
|
|
|
|
let separatorRect = NSRect(x: cellView.frame.minX + Self.separatorInsetLeft, y: bounds.maxY - Self.separatorHeight, width: cellView.frame.width - Self.separatorInsetLeft - Self.separatorInsetRight, height: Self.separatorHeight)
|
|
|
|
|
|
let gridColor = (superview as? NSTableView)?.gridColor ?? .gridColor
|
|
|
|
|
|
gridColor.setFill()
|
|
|
|
|
|
separatorRect.fill(using: .sourceOver)
|
2020-11-19 13:44:08 -06:00
|
|
|
|
}
|
2017-05-27 10:43:27 -07:00
|
|
|
|
}
|