NetNewsWire/Mac/MainWindow/Sidebar/SidebarOutlineView.swift

69 lines
1.4 KiB
Swift
Raw Normal View History

2017-05-27 19:43:27 +02:00
//
// SidebarOutlineView.swift
2018-08-29 07:18:24 +02:00
// NetNewsWire
2017-05-27 19:43:27 +02:00
//
// Created by Brent Simmons on 11/17/15.
// Copyright © 2015 Ranchero Software, LLC. All rights reserved.
//
import AppKit
2024-03-22 01:21:50 +01:00
import Tree
import AppKitExtras
2017-05-27 19:43:27 +02:00
2024-03-25 05:24:31 +01:00
final class SidebarOutlineView : NSOutlineView {
@IBOutlet var keyboardDelegate: KeyboardDelegate!
// MARK: NSTableView
2017-11-19 01:56:36 +01:00
override func frameOfCell(atColumn column: Int, row: Int) -> NSRect {
// Dont allow the pseudo-feeds at the top level to be indented.
2017-11-19 01:56:36 +01:00
var frame = super.frameOfCell(atColumn: column, row: row)
frame.origin.x += 4.0
frame.size.width -= 4.0
2017-11-19 01:56:36 +01:00
let node = item(atRow: row) as! Node
guard let parentNode = node.parent, parentNode.isRoot else {
return frame
}
guard node.representedObject is PseudoFeed else {
2017-11-19 01:56:36 +01:00
return frame
}
frame.origin.x -= indentationPerLevel
frame.size.width += indentationPerLevel
return frame
}
// MARK: NSView
2017-05-27 19:43:27 +02:00
override func viewWillStartLiveResize() {
if let scrollView = self.enclosingScrollView {
scrollView.hasVerticalScroller = false
}
super.viewWillStartLiveResize()
}
override func viewDidEndLiveResize() {
if let scrollView = self.enclosingScrollView {
scrollView.hasVerticalScroller = true
}
super.viewDidEndLiveResize()
}
// MARK: NSResponder
override func keyDown(with event: NSEvent) {
if keyboardDelegate.keydown(event, in: self) {
return
}
super.keyDown(with: event)
}
2017-05-27 19:43:27 +02:00
}