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
|
2024-03-21 04:49:15 +01:00
|
|
|
|
import AppKitExtras
|
2017-05-27 19:43:27 +02:00
|
|
|
|
|
|
|
|
|
class SidebarOutlineView : NSOutlineView {
|
2017-10-21 21:13:20 +02:00
|
|
|
|
|
2017-12-20 21:59:31 +01:00
|
|
|
|
@IBOutlet var keyboardDelegate: KeyboardDelegate!
|
2017-10-21 21:13:20 +02:00
|
|
|
|
|
2018-02-07 22:11:40 +01:00
|
|
|
|
// MARK: NSTableView
|
2017-11-19 01:56:36 +01:00
|
|
|
|
|
|
|
|
|
override func frameOfCell(atColumn column: Int, row: Int) -> NSRect {
|
|
|
|
|
|
2017-11-20 05:42:37 +01:00
|
|
|
|
// Don’t 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)
|
2018-02-24 08:05:51 +01:00
|
|
|
|
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
|
2017-11-20 05:42:37 +01:00
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-07 22:11:40 +01:00
|
|
|
|
// 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()
|
|
|
|
|
}
|
2018-02-07 22:11:40 +01:00
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|