diff --git a/Evergreen/AppDelegate.swift b/Evergreen/AppDelegate.swift index fa8c115b0..669bda6db 100644 --- a/Evergreen/AppDelegate.swift +++ b/Evergreen/AppDelegate.swift @@ -31,6 +31,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { var addFeedController: AddFeedController? var addFolderWindowController: AddFolderWindowController? var keyboardShortcutsWindowController: WebViewWindowController? + var inspectorWindowController: InspectorWindowController? let log = Log() let themeLoader = VSThemeLoader() private let appNewsURLString = "https://ranchero.com/evergreen/feed.json" @@ -247,7 +248,21 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations { } keyboardShortcutsWindowController!.showWindow(self) } - + + @IBAction func toggleInspectorWindow(_ sender: Any?) { + + if inspectorWindowController == nil { + inspectorWindowController = InspectorWindowController() + } + + if inspectorWindowController!.isOpen { + inspectorWindowController!.window!.performClose(self) + } + else { + inspectorWindowController!.showWindow(self) + } + } + @IBAction func importOPMLFromFile(_ sender: AnyObject) { let panel = NSOpenPanel() diff --git a/Evergreen/Base.lproj/Main.storyboard b/Evergreen/Base.lproj/Main.storyboard index de7304ceb..657d259e8 100644 --- a/Evergreen/Base.lproj/Main.storyboard +++ b/Evergreen/Base.lproj/Main.storyboard @@ -1,7 +1,7 @@ - + - + @@ -457,6 +457,11 @@ + + + + + diff --git a/Frameworks/RSCore/RSCore.xcodeproj/project.pbxproj b/Frameworks/RSCore/RSCore.xcodeproj/project.pbxproj index 04bda9754..281133ecb 100755 --- a/Frameworks/RSCore/RSCore.xcodeproj/project.pbxproj +++ b/Frameworks/RSCore/RSCore.xcodeproj/project.pbxproj @@ -150,6 +150,11 @@ 84CFF56D1AC3D20A00CEA6C8 /* NSImage+RSCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 84CFF56B1AC3D20A00CEA6C8 /* NSImage+RSCore.h */; settings = {ATTRIBUTES = (Public, ); }; }; 84CFF56E1AC3D20A00CEA6C8 /* NSImage+RSCore.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CFF56C1AC3D20A00CEA6C8 /* NSImage+RSCore.m */; }; 84E34DA61F9FA1070077082F /* UndoableCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E34DA51F9FA1070077082F /* UndoableCommand.swift */; }; + 84E72E151FBD647500B873C1 /* InspectorItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E72E101FBD647500B873C1 /* InspectorItem.swift */; }; + 84E72E161FBD647500B873C1 /* InspectorItemContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E72E111FBD647500B873C1 /* InspectorItemContainerView.swift */; }; + 84E72E171FBD647500B873C1 /* InspectorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E72E121FBD647500B873C1 /* InspectorView.swift */; }; + 84E72E181FBD647500B873C1 /* InspectorWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84E72E131FBD647500B873C1 /* InspectorWindow.xib */; }; + 84E72E191FBD647500B873C1 /* InspectorWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E72E141FBD647500B873C1 /* InspectorWindowController.swift */; }; 84F20F831F16BA6200D8E682 /* PropertyList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84F20F821F16BA6200D8E682 /* PropertyList.swift */; }; 84FE9FC31C00453900081CE9 /* NSStoryboard+RSCore.h in Headers */ = {isa = PBXBuildFile; fileRef = 84FE9FC11C00453900081CE9 /* NSStoryboard+RSCore.h */; settings = {ATTRIBUTES = (Public, ); }; }; 84FE9FC41C00453900081CE9 /* NSStoryboard+RSCore.m in Sources */ = {isa = PBXBuildFile; fileRef = 84FE9FC21C00453900081CE9 /* NSStoryboard+RSCore.m */; }; @@ -260,6 +265,11 @@ 84CFF56B1AC3D20A00CEA6C8 /* NSImage+RSCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSImage+RSCore.h"; sourceTree = ""; }; 84CFF56C1AC3D20A00CEA6C8 /* NSImage+RSCore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSImage+RSCore.m"; sourceTree = ""; }; 84E34DA51F9FA1070077082F /* UndoableCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = UndoableCommand.swift; path = RSCore/UndoableCommand.swift; sourceTree = ""; }; + 84E72E101FBD647500B873C1 /* InspectorItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InspectorItem.swift; sourceTree = ""; }; + 84E72E111FBD647500B873C1 /* InspectorItemContainerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InspectorItemContainerView.swift; sourceTree = ""; }; + 84E72E121FBD647500B873C1 /* InspectorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InspectorView.swift; sourceTree = ""; }; + 84E72E131FBD647500B873C1 /* InspectorWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = InspectorWindow.xib; sourceTree = ""; }; + 84E72E141FBD647500B873C1 /* InspectorWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InspectorWindowController.swift; sourceTree = ""; }; 84F20F821F16BA6200D8E682 /* PropertyList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PropertyList.swift; sourceTree = ""; }; 84FE9FC11C00453900081CE9 /* NSStoryboard+RSCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSStoryboard+RSCore.h"; sourceTree = ""; }; 84FE9FC21C00453900081CE9 /* NSStoryboard+RSCore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSStoryboard+RSCore.m"; sourceTree = ""; }; @@ -338,6 +348,7 @@ 8402047D1FBCE77900D94C1A /* BatchUpdate.swift */, 84CFF5241AC3C8A200CEA6C8 /* Foundation */, 84CFF5551AC3CF4A00CEA6C8 /* AppKit */, + 84E72E0F1FBD647500B873C1 /* Inspector */, 84CFF5661AC3D13F00CEA6C8 /* Images */, 84CFF4F81AC3C69700CEA6C8 /* Info.plist */, 84CFF5031AC3C69700CEA6C8 /* RSCoreTests */, @@ -462,6 +473,19 @@ path = RSCore; sourceTree = ""; }; + 84E72E0F1FBD647500B873C1 /* Inspector */ = { + isa = PBXGroup; + children = ( + 84E72E131FBD647500B873C1 /* InspectorWindow.xib */, + 84E72E141FBD647500B873C1 /* InspectorWindowController.swift */, + 84E72E121FBD647500B873C1 /* InspectorView.swift */, + 84E72E111FBD647500B873C1 /* InspectorItemContainerView.swift */, + 84E72E101FBD647500B873C1 /* InspectorItem.swift */, + ); + name = Inspector; + path = RSCore/Inspector; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -652,6 +676,7 @@ files = ( 84C687301FBAA30800345C9E /* LogWindow.xib in Resources */, 8479213C1FBA426B004AD08C /* WebViewWindow.xib in Resources */, + 84E72E181FBD647500B873C1 /* InspectorWindow.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -713,6 +738,7 @@ 849BF8BA1C9130150071D1DA /* DiskSaver.swift in Sources */, 84FE9FC41C00453900081CE9 /* NSStoryboard+RSCore.m in Sources */, 84CFF5341AC3CB6800CEA6C8 /* NSDictionary+RSCore.m in Sources */, + 84E72E161FBD647500B873C1 /* InspectorItemContainerView.swift in Sources */, 84CFF54C1AC3CDAC00CEA6C8 /* NSString+RSCore.m in Sources */, 84CFF5171AC3C73000CEA6C8 /* RSConstants.m in Sources */, 8432B1881DACA2060057D6DF /* NSWindow-Extensions.swift in Sources */, @@ -739,6 +765,7 @@ 84CFF5611AC3D0CE00CEA6C8 /* RSBinaryCache.m in Sources */, 84CFF5301AC3CB1900CEA6C8 /* NSDate+RSCore.m in Sources */, 84CFF5281AC3C9A200CEA6C8 /* NSArray+RSCore.m in Sources */, + 84E72E171FBD647500B873C1 /* InspectorView.swift in Sources */, 84CFF5591AC3CF9100CEA6C8 /* NSView+RSCore.m in Sources */, 84CFF56A1AC3D1B000CEA6C8 /* RSScaling.m in Sources */, 84FEB4AC1D19D7F4004727E5 /* Date+Extensions.swift in Sources */, @@ -751,9 +778,11 @@ 844C915C1B65753E0051FC1B /* RSPlist.m in Sources */, 84CFF5231AC3C89D00CEA6C8 /* NSObject+RSCore.m in Sources */, 8414CBA71C95F2EA00333C12 /* Set+Extensions.swift in Sources */, + 84E72E191FBD647500B873C1 /* InspectorWindowController.swift in Sources */, 84B99C9A1FAE650100ECDEDB /* OPMLRepresentable.swift in Sources */, 84E34DA61F9FA1070077082F /* UndoableCommand.swift in Sources */, 844F91D61D90D86100820C48 /* RSTransparentContainerView.m in Sources */, + 84E72E151FBD647500B873C1 /* InspectorItem.swift in Sources */, 84CFF56E1AC3D20A00CEA6C8 /* NSImage+RSCore.m in Sources */, 8453F7DF1BDF337800B1C8ED /* RSMacroProcessor.m in Sources */, 842E45CC1ED623C7000A8B52 /* UniqueIdentifier.swift in Sources */, diff --git a/Frameworks/RSCore/RSCore/Inspector/InspectorItem.swift b/Frameworks/RSCore/RSCore/Inspector/InspectorItem.swift new file mode 100644 index 000000000..a14d4a9ea --- /dev/null +++ b/Frameworks/RSCore/RSCore/Inspector/InspectorItem.swift @@ -0,0 +1,19 @@ +// +// InspectorItem.swift +// Evergreen +// +// Created by Brent Simmons on 11/15/17. +// Copyright © 2017 Ranchero Software. All rights reserved. +// + +import Foundation + +protocol InspectorItem: class { + + var localizedTitle: String { get } + var view: NSView { get } + var inspectedObjects: [Any]? { get set } + var expanded: Bool { get set } + + func canInspect(_ objects: [Any]) -> Bool +} diff --git a/Frameworks/RSCore/RSCore/Inspector/InspectorItemContainerView.swift b/Frameworks/RSCore/RSCore/Inspector/InspectorItemContainerView.swift new file mode 100644 index 000000000..586d0a944 --- /dev/null +++ b/Frameworks/RSCore/RSCore/Inspector/InspectorItemContainerView.swift @@ -0,0 +1,20 @@ +// +// InspectorItemContainerView.swift +// Evergreen +// +// Created by Brent Simmons on 11/15/17. +// Copyright © 2017 Ranchero Software. All rights reserved. +// + +import Cocoa + + +class InspectorItemContainerView: NSView { + + override func draw(_ dirtyRect: NSRect) { + super.draw(dirtyRect) + + // Drawing code here. + } + +} diff --git a/Frameworks/RSCore/RSCore/Inspector/InspectorView.swift b/Frameworks/RSCore/RSCore/Inspector/InspectorView.swift new file mode 100644 index 000000000..f289abdb2 --- /dev/null +++ b/Frameworks/RSCore/RSCore/Inspector/InspectorView.swift @@ -0,0 +1,29 @@ +// +// InspectorView.swift +// Evergreen +// +// Created by Brent Simmons on 11/15/17. +// Copyright © 2017 Ranchero Software. All rights reserved. +// + +import Cocoa + +// The content view for the window. +// +// InspectorWindow +// InspectorView +// InspectorItemContainerView +// NSView (inspector item) +// InspectorItemContainerView +// NSView (inspector item) +// etc. + +class InspectorView: NSView { + + override func draw(_ dirtyRect: NSRect) { + super.draw(dirtyRect) + + // Drawing code here. + } + +} diff --git a/Frameworks/RSCore/RSCore/Inspector/InspectorWindow.xib b/Frameworks/RSCore/RSCore/Inspector/InspectorWindow.xib new file mode 100644 index 000000000..f9d5105db --- /dev/null +++ b/Frameworks/RSCore/RSCore/Inspector/InspectorWindow.xib @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Frameworks/RSCore/RSCore/Inspector/InspectorWindowController.swift b/Frameworks/RSCore/RSCore/Inspector/InspectorWindowController.swift new file mode 100644 index 000000000..5ea9b33fa --- /dev/null +++ b/Frameworks/RSCore/RSCore/Inspector/InspectorWindowController.swift @@ -0,0 +1,23 @@ +// +// InspectorWindowController.swift +// Evergreen +// +// Created by Brent Simmons on 11/15/17. +// Copyright © 2017 Ranchero Software. All rights reserved. +// + +import Cocoa + +public class InspectorWindowController: NSWindowController { + + public var isOpen: Bool { + get { + return isWindowLoaded && window!.isVisible + } + } + + public convenience init() { + + self.init(windowNibName: NSNib.Name(rawValue: "InspectorWindow")) + } +} diff --git a/Frameworks/RSCore/RSCore/LogItem.swift b/Frameworks/RSCore/RSCore/LogItem.swift index d5be961ba..5d50cf144 100644 --- a/Frameworks/RSCore/RSCore/LogItem.swift +++ b/Frameworks/RSCore/RSCore/LogItem.swift @@ -8,7 +8,7 @@ import Foundation -public struct LogItem: Hashable { +public struct LogItem { public enum ItemType { case debug, notification, warning, error @@ -17,19 +17,11 @@ public struct LogItem: Hashable { public let type: ItemType public let message: String public let date: Date - public let hashValue: Int public init(type: ItemType, message: String) { self.type = type self.message = message - let date = Date() - self.date = date - self.hashValue = message.hashValue + date.hashValue - } - - static public func ==(lhs: LogItem, rhs: LogItem) -> Bool { - - return lhs.type == rhs.type && lhs.message == rhs.message && lhs.date == rhs.date + self.date = Date() } }