2017-05-27 19:43:27 +02:00
|
|
|
//
|
|
|
|
// TimelineTableRowView.swift
|
2018-08-29 07:18:24 +02:00
|
|
|
// NetNewsWire
|
2017-05-27 19:43:27 +02:00
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 8/31/15.
|
|
|
|
// Copyright © 2015 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2018-02-03 07:51:32 +01:00
|
|
|
import AppKit
|
2017-05-27 19:43:27 +02:00
|
|
|
|
|
|
|
class TimelineTableRowView : NSTableRowView {
|
|
|
|
|
2020-11-19 20:44:08 +01:00
|
|
|
private var separator: NSView?
|
|
|
|
|
2019-05-14 06:42:47 +02:00
|
|
|
override var isOpaque: Bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2019-05-21 23:08:16 +02:00
|
|
|
override var isEmphasized: Bool {
|
|
|
|
didSet {
|
|
|
|
cellView?.isEmphasized = isEmphasized
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override var isSelected: Bool {
|
|
|
|
didSet {
|
|
|
|
cellView?.isSelected = isSelected
|
2020-11-19 20:44:08 +01:00
|
|
|
separator?.isHidden = isSelected
|
2019-05-21 23:08:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-14 06:33:50 +01:00
|
|
|
init() {
|
|
|
|
super.init(frame: NSRect.zero)
|
|
|
|
}
|
|
|
|
|
|
|
|
required init?(coder: NSCoder) {
|
|
|
|
super.init(coder: coder)
|
|
|
|
}
|
|
|
|
|
2017-05-27 19:43:27 +02:00
|
|
|
private var cellView: TimelineTableCellView? {
|
2018-02-14 22:14:25 +01:00
|
|
|
for oneSubview in subviews {
|
|
|
|
if let foundView = oneSubview as? TimelineTableCellView {
|
|
|
|
return foundView
|
2017-05-27 19:43:27 +02:00
|
|
|
}
|
|
|
|
}
|
2018-02-14 22:14:25 +01:00
|
|
|
return nil
|
2017-05-27 19:43:27 +02:00
|
|
|
}
|
|
|
|
|
2020-11-19 20:44:08 +01:00
|
|
|
override func viewDidMoveToSuperview() {
|
2020-12-06 01:26:18 +01:00
|
|
|
if AppDefaults.shared.timelineShowsSeparators {
|
2020-11-19 20:44:08 +01:00
|
|
|
addSeparatorView()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private func addSeparatorView() {
|
2024-02-28 05:02:31 +01:00
|
|
|
|
2020-11-19 23:25:06 +01:00
|
|
|
guard let cellView = cellView, separator == nil else { return }
|
2024-02-28 05:02:31 +01:00
|
|
|
|
2020-11-19 20:44:08 +01:00
|
|
|
separator = NSView()
|
|
|
|
separator!.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
separator!.wantsLayer = true
|
2020-11-19 20:53:51 +01:00
|
|
|
separator!.layer?.backgroundColor = AppAssets.timelineSeparatorColor.cgColor
|
2024-02-28 05:02:31 +01:00
|
|
|
|
2020-11-19 20:44:08 +01:00
|
|
|
addSubview(separator!)
|
2024-02-28 05:02:31 +01:00
|
|
|
|
|
|
|
NSLayoutConstraint.activate([
|
|
|
|
separator!.leadingAnchor.constraint(equalTo: cellView.leadingAnchor, constant: 20),
|
|
|
|
separator!.trailingAnchor.constraint(equalTo: cellView.trailingAnchor, constant: -4),
|
|
|
|
separator!.heightAnchor.constraint(equalToConstant: 1),
|
|
|
|
separator!.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0)
|
|
|
|
])
|
2020-11-19 20:44:08 +01:00
|
|
|
}
|
2017-05-27 19:43:27 +02:00
|
|
|
}
|