Files
NetNewsWire/Mac/MainWindow/Timeline/TimelineTableRowView.swift
T

69 lines
1.6 KiB
Swift
Raw Normal View History

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.
//
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
/// The last row has no separator below it.
var isLastRow = false {
didSet {
if isLastRow != oldValue {
needsDisplay = true
}
}
}
private static let separatorInsetLeft: CGFloat = 20.0
private static let separatorInsetRight: CGFloat = 4.0
private static let separatorHeight: CGFloat = 1.0
override var isOpaque: Bool {
return true
}
override var isEmphasized: Bool {
didSet {
cellView?.isEmphasized = isEmphasized
}
}
2025-11-05 11:22:10 -08:00
override var isSelected: Bool {
didSet {
cellView?.isSelected = isSelected
}
}
2025-11-05 11:22:10 -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? {
for oneSubview in subviews {
if let foundView = oneSubview as? TimelineTableCellView {
return foundView
2017-05-27 10:43:27 -07:00
}
}
return nil
2017-05-27 10:43:27 -07: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
}
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)
}
2017-05-27 10:43:27 -07:00
}