Continue progress on inspector.
This commit is contained in:
parent
a8cee0d803
commit
394274f1e5
|
@ -310,6 +310,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||
inspectorWindowController!.window!.performClose(self)
|
||||
}
|
||||
else {
|
||||
var selectedObjects: [Any]? = nil
|
||||
if let window = NSApplication.shared.mainWindow {
|
||||
if let windowController = window.windowController as? MainWindowController {
|
||||
selectedObjects = windowController.selectedObjectsInSidebar()
|
||||
}
|
||||
}
|
||||
inspectorWindowController!.objects = selectedObjects
|
||||
inspectorWindowController!.showWindow(self)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,26 +21,13 @@
|
|||
</connections>
|
||||
</window>
|
||||
<connections>
|
||||
<segue destination="VUU-wH-gjh" kind="relationship" relationship="window.shadowedContentViewController" id="YF3-J6-BnJ"/>
|
||||
<segue destination="Fdj-2F-Kl1" kind="relationship" relationship="window.shadowedContentViewController" id="AOI-cR-OVA"/>
|
||||
</connections>
|
||||
</windowController>
|
||||
<customObject id="THC-Ye-xbS" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-349" y="-167"/>
|
||||
</scene>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="KfF-qz-jtB">
|
||||
<objects>
|
||||
<viewController showSeguePresentationStyle="single" id="VUU-wH-gjh" sceneMemberID="viewController">
|
||||
<view key="view" id="E15-dH-my9">
|
||||
<rect key="frame" x="0.0" y="0.0" width="256" height="270"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</view>
|
||||
</viewController>
|
||||
<customObject id="kLX-um-NVe" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-8" y="-174"/>
|
||||
</scene>
|
||||
<!--Feed-->
|
||||
<scene sceneID="vUh-Rc-fPi">
|
||||
<objects>
|
||||
|
@ -128,7 +115,7 @@ Field</string>
|
|||
</viewController>
|
||||
<customObject id="1ho-ZO-Gkb" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-52" y="182"/>
|
||||
<point key="canvasLocation" x="67" y="30"/>
|
||||
</scene>
|
||||
<!--Folder-->
|
||||
<scene sceneID="8By-fa-WDQ">
|
||||
|
@ -173,7 +160,7 @@ Field</string>
|
|||
</viewController>
|
||||
<customObject id="4SD-ni-Scy" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-52" y="471"/>
|
||||
<point key="canvasLocation" x="67" y="329"/>
|
||||
</scene>
|
||||
<!--Builtin Smart Feed-->
|
||||
<scene sceneID="dFq-3d-JKW">
|
||||
|
@ -212,7 +199,7 @@ Field</string>
|
|||
</viewController>
|
||||
<customObject id="3Xn-vX-2s9" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-52" y="685"/>
|
||||
<point key="canvasLocation" x="67" y="553"/>
|
||||
</scene>
|
||||
<!--Nothing to inspect-->
|
||||
<scene sceneID="lUc-e1-dN7">
|
||||
|
@ -240,7 +227,7 @@ Field</string>
|
|||
</viewController>
|
||||
<customObject id="B1q-CC-IfW" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-52" y="868"/>
|
||||
<point key="canvasLocation" x="67" y="-213"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
|
|
|
@ -18,11 +18,14 @@ protocol Inspector: class {
|
|||
func willEndInspectingObjects() // Called on the current inspector right before objects is about to change.
|
||||
}
|
||||
|
||||
typealias InspectorViewController = Inspector & NSViewController
|
||||
|
||||
|
||||
final class InspectorWindowController: NSWindowController {
|
||||
|
||||
private var inspectors: [Inspector]!
|
||||
private var inspectors: [InspectorViewController]!
|
||||
|
||||
private var currentInspector: Inspector! {
|
||||
private var currentInspector: InspectorViewController! {
|
||||
didSet {
|
||||
if let oldInspector = oldValue {
|
||||
oldInspector.willEndInspectingObjects()
|
||||
|
@ -39,6 +42,7 @@ final class InspectorWindowController: NSWindowController {
|
|||
|
||||
var objects: [Any]? {
|
||||
didSet {
|
||||
let _ = window
|
||||
currentInspector = inspector(for: objects)
|
||||
}
|
||||
}
|
||||
|
@ -51,17 +55,20 @@ final class InspectorWindowController: NSWindowController {
|
|||
|
||||
override func windowDidLoad() {
|
||||
|
||||
let nothingInspector = window?.contentViewController as! InspectorViewController
|
||||
|
||||
let storyboard = NSStoryboard(name: NSStoryboard.Name(rawValue: "Inspector"), bundle: nil)
|
||||
let feedInspector = inspector("Feed", storyboard)
|
||||
let folderInspector = inspector("Folder", storyboard)
|
||||
let builtinSmartFeedInspector = inspector("BuiltinSmartFeed", storyboard)
|
||||
let nothingInspector = inspector("Nothing", storyboard)
|
||||
|
||||
inspectors = [feedInspector, folderInspector, builtinSmartFeedInspector, nothingInspector]
|
||||
currentInspector = nothingInspector
|
||||
}
|
||||
|
||||
func inspector(for objects: [Any]?) -> Inspector {
|
||||
func inspector(for objects: [Any]?) -> InspectorViewController {
|
||||
|
||||
var fallbackInspector: Inspector? = nil
|
||||
var fallbackInspector: InspectorViewController? = nil
|
||||
|
||||
for inspector in inspectors {
|
||||
if inspector.isFallbackInspector {
|
||||
|
@ -78,13 +85,16 @@ final class InspectorWindowController: NSWindowController {
|
|||
|
||||
private extension InspectorWindowController {
|
||||
|
||||
func inspector(_ identifier: String, _ storyboard: NSStoryboard) -> Inspector {
|
||||
func inspector(_ identifier: String, _ storyboard: NSStoryboard) -> InspectorViewController {
|
||||
|
||||
return storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: identifier)) as! Inspector
|
||||
return storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: identifier)) as! InspectorViewController
|
||||
}
|
||||
|
||||
func show(_ inspector: Inspector) {
|
||||
func show(_ inspector: InspectorViewController) {
|
||||
|
||||
// TODO
|
||||
guard let window = window, inspector !== window.contentViewController else {
|
||||
return
|
||||
}
|
||||
window.contentViewController = inspector
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,14 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||
self.updateWindowTitle()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: Sidebar
|
||||
|
||||
func selectedObjectsInSidebar() -> [AnyObject]? {
|
||||
|
||||
return sidebarViewController?.selectedObjects
|
||||
}
|
||||
|
||||
// MARK: Notifications
|
||||
|
||||
@objc func applicationWillTerminate(_ note: Notification) {
|
||||
|
|
|
@ -23,6 +23,10 @@ import RSCore
|
|||
private var animatingChanges = false
|
||||
private var sidebarCellAppearance: SidebarCellAppearance!
|
||||
|
||||
var selectedObjects: [AnyObject] {
|
||||
return selectedNodes.representedObjects()
|
||||
}
|
||||
|
||||
//MARK: NSViewController
|
||||
|
||||
override func viewDidLoad() {
|
||||
|
|
|
@ -190,3 +190,11 @@ public func ==(lhs: Node, rhs: Node) -> Bool {
|
|||
|
||||
return lhs === rhs
|
||||
}
|
||||
|
||||
public extension Array where Element == Node {
|
||||
|
||||
public func representedObjects() -> [AnyObject] {
|
||||
|
||||
return self.map{ $0.representedObject }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue