Correctly align separator with contents of cell. Issue #2592
This commit is contained in:
parent
97bbb9d9d9
commit
006586ada6
|
@ -10,6 +10,8 @@ import AppKit
|
|||
|
||||
class TimelineTableRowView : NSTableRowView {
|
||||
|
||||
private var separator: NSView?
|
||||
|
||||
override var isOpaque: Bool {
|
||||
return true
|
||||
}
|
||||
|
@ -23,6 +25,7 @@ class TimelineTableRowView : NSTableRowView {
|
|||
override var isSelected: Bool {
|
||||
didSet {
|
||||
cellView?.isSelected = isSelected
|
||||
separator?.isHidden = isSelected
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,4 +46,38 @@ class TimelineTableRowView : NSTableRowView {
|
|||
return nil
|
||||
}
|
||||
|
||||
override func viewDidMoveToSuperview() {
|
||||
if #available(macOS 11.0, *) {
|
||||
addSeparatorView()
|
||||
} else {
|
||||
if AppDefaults.shared.timelineShowsSeparators {
|
||||
addSeparatorView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func addSeparatorView() {
|
||||
guard let cellView = cellView else { return }
|
||||
separator = NSView()
|
||||
separator!.translatesAutoresizingMaskIntoConstraints = false
|
||||
separator!.wantsLayer = true
|
||||
separator!.layer?.backgroundColor = NSColor.separatorColor.cgColor
|
||||
addSubview(separator!)
|
||||
if #available(macOS 11.0, *) {
|
||||
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)
|
||||
])
|
||||
} else {
|
||||
NSLayoutConstraint.activate([
|
||||
separator!.leadingAnchor.constraint(equalTo: cellView.leadingAnchor, constant: 34),
|
||||
separator!.trailingAnchor.constraint(equalTo: cellView.trailingAnchor, constant: -28),
|
||||
separator!.heightAnchor.constraint(equalToConstant: 1),
|
||||
separator!.bottomAnchor.constraint(equalTo: bottomAnchor, constant: 0)
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -209,11 +209,6 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||
|
||||
if #available(macOS 11.0, *) {
|
||||
tableView.style = .inset
|
||||
tableView.gridStyleMask = .solidHorizontalGridLineMask
|
||||
} else {
|
||||
if AppDefaults.shared.timelineShowsSeparators {
|
||||
tableView.gridStyleMask = .solidHorizontalGridLineMask
|
||||
}
|
||||
}
|
||||
|
||||
if !didRegisterForNotifications {
|
||||
|
|
Loading…
Reference in New Issue