NetNewsWire/Evergreen/MainWindow/Sidebar/SidebarOutlineView.swift

67 lines
1.3 KiB
Swift
Raw Normal View History

2017-05-27 19:43:27 +02:00
//
// SidebarOutlineView.swift
// Evergreen
//
// Created by Brent Simmons on 11/17/15.
// Copyright © 2015 Ranchero Software, LLC. All rights reserved.
//
import AppKit
2017-10-21 19:55:20 +02:00
import RSCore
2017-11-19 01:56:36 +01:00
import RSTree
2017-05-27 19:43:27 +02:00
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)
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
}