2017-05-27 10:43:27 -07:00
|
|
|
|
//
|
|
|
|
|
// SidebarOutlineView.swift
|
2018-08-28 22:18:24 -07:00
|
|
|
|
// NetNewsWire
|
2017-05-27 10:43:27 -07:00
|
|
|
|
//
|
|
|
|
|
// Created by Brent Simmons on 11/17/15.
|
|
|
|
|
// Copyright © 2015 Ranchero Software, LLC. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import AppKit
|
2017-10-21 10:55:20 -07:00
|
|
|
|
import RSCore
|
2017-11-18 16:56:36 -08:00
|
|
|
|
import RSTree
|
2017-05-27 10:43:27 -07:00
|
|
|
|
|
|
|
|
|
class SidebarOutlineView : NSOutlineView {
|
2017-10-21 12:13:20 -07:00
|
|
|
|
|
2017-12-20 12:59:31 -08:00
|
|
|
|
@IBOutlet var keyboardDelegate: KeyboardDelegate!
|
2017-10-21 12:13:20 -07:00
|
|
|
|
|
2018-02-07 13:11:40 -08:00
|
|
|
|
// MARK: NSTableView
|
2017-11-18 16:56:36 -08:00
|
|
|
|
|
|
|
|
|
override func frameOfCell(atColumn column: Int, row: Int) -> NSRect {
|
|
|
|
|
|
2017-11-19 20:42:37 -08:00
|
|
|
|
// Don’t allow the pseudo-feeds at the top level to be indented.
|
|
|
|
|
|
2017-11-18 16:56:36 -08:00
|
|
|
|
var frame = super.frameOfCell(atColumn: column, row: row)
|
2018-02-23 23:05:51 -08:00
|
|
|
|
frame.origin.x += 4.0
|
|
|
|
|
frame.size.width -= 4.0
|
2017-11-18 16:56:36 -08:00
|
|
|
|
|
|
|
|
|
let node = item(atRow: row) as! Node
|
2017-11-19 20:42:37 -08:00
|
|
|
|
guard let parentNode = node.parent, parentNode.isRoot else {
|
|
|
|
|
return frame
|
|
|
|
|
}
|
|
|
|
|
guard node.representedObject is PseudoFeed else {
|
2017-11-18 16:56:36 -08:00
|
|
|
|
return frame
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
frame.origin.x -= indentationPerLevel
|
|
|
|
|
frame.size.width += indentationPerLevel
|
|
|
|
|
return frame
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-07 13:11:40 -08:00
|
|
|
|
// MARK: NSView
|
|
|
|
|
|
2017-05-27 10:43:27 -07: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()
|
|
|
|
|
}
|
2018-02-07 13:11:40 -08:00
|
|
|
|
|
|
|
|
|
// MARK: NSResponder
|
|
|
|
|
|
|
|
|
|
override func keyDown(with event: NSEvent) {
|
|
|
|
|
|
|
|
|
|
if keyboardDelegate.keydown(event, in: self) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
super.keyDown(with: event)
|
|
|
|
|
}
|
2017-05-27 10:43:27 -07:00
|
|
|
|
}
|