From b0b744168750afa73dbe628e1733dbe9c16e53f7 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Wed, 27 Dec 2017 17:29:22 -0800 Subject: [PATCH] Start rebuilding the Feed Directory window using a .xib instead of a storyboard. The storyboard was giving me major grief over the split view. This way I have much better control over the split view. --- Evergreen.xcodeproj/project.pbxproj | 20 +- Evergreen/AppDelegate.swift | 2 +- Evergreen/Base.lproj/FeedList.storyboard | 353 ------------------ .../FeedListSplitViewController.swift | 74 ++++ .../FeedList/FeedListViewController.swift | 3 + Evergreen/FeedList/FeedListWindow.xib | 203 ++++++++++ .../FeedList/FeedListWindowController.swift | 5 + Evergreen/Resources/DB5.plist | 12 + 8 files changed, 306 insertions(+), 366 deletions(-) delete mode 100644 Evergreen/Base.lproj/FeedList.storyboard create mode 100644 Evergreen/FeedList/FeedListSplitViewController.swift create mode 100644 Evergreen/FeedList/FeedListWindow.xib diff --git a/Evergreen.xcodeproj/project.pbxproj b/Evergreen.xcodeproj/project.pbxproj index ffc80d5d3..95ef17b16 100644 --- a/Evergreen.xcodeproj/project.pbxproj +++ b/Evergreen.xcodeproj/project.pbxproj @@ -38,6 +38,7 @@ 846E77411F6EF6A100A165E2 /* Database.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 846E77211F6EF5D100A165E2 /* Database.framework */; }; 846E77421F6EF6A100A165E2 /* Database.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 846E77211F6EF5D100A165E2 /* Database.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 84702AA41FA27AC0006B8943 /* MarkReadOrUnreadCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84702AA31FA27AC0006B8943 /* MarkReadOrUnreadCommand.swift */; }; + 847C4C9C1FF44F790090D517 /* FeedListSplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847C4C9B1FF44F790090D517 /* FeedListSplitViewController.swift */; }; 848F6AE51FC29CFB002D422E /* FaviconDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848F6AE41FC29CFA002D422E /* FaviconDownloader.swift */; }; 849A97431ED9EAA9007D329B /* AddFolderWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97421ED9EAA9007D329B /* AddFolderWindowController.swift */; }; 849A97531ED9EAC0007D329B /* AddFeedController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97511ED9EAC0007D329B /* AddFeedController.swift */; }; @@ -77,7 +78,6 @@ 849A97A61ED9F94D007D329B /* Preferences.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 849A97A41ED9F94D007D329B /* Preferences.storyboard */; }; 849A97A91ED9F9AA007D329B /* AddFeedSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 849A97A71ED9F9AA007D329B /* AddFeedSheet.xib */; }; 849A97AC1ED9F9BC007D329B /* AddFolderSheet.xib in Resources */ = {isa = PBXBuildFile; fileRef = 849A97AA1ED9F9BC007D329B /* AddFolderSheet.xib */; }; - 849A97AF1ED9FA08007D329B /* FeedList.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 849A97AD1ED9FA08007D329B /* FeedList.storyboard */; }; 849A97B21ED9FA69007D329B /* MainWindow.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 849A97B01ED9FA69007D329B /* MainWindow.storyboard */; }; 849B897C1F0349D000578A8D /* RSParser.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 849B89751F0349C100578A8D /* RSParser.framework */; }; 849B897D1F0349D000578A8D /* RSParser.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 849B89751F0349C100578A8D /* RSParser.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -99,6 +99,7 @@ 84B06FFE1ED3818D00F0B54B /* RSTree.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 84B06FFA1ED3818000F0B54B /* RSTree.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 84B0700A1ED3822600F0B54B /* RSTextDrawing.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84B070071ED3821900F0B54B /* RSTextDrawing.framework */; }; 84B0700B1ED3822600F0B54B /* RSTextDrawing.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 84B070071ED3821900F0B54B /* RSTextDrawing.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 84B2FAA41FF47BAC009C4878 /* FeedListWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84B2FAA31FF47BAC009C4878 /* FeedListWindow.xib */; }; 84B99C671FAE35E600ECDEDB /* FeedListTreeControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C661FAE35E600ECDEDB /* FeedListTreeControllerDelegate.swift */; }; 84B99C691FAE36B800ECDEDB /* FeedListFolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C681FAE36B800ECDEDB /* FeedListFolder.swift */; }; 84B99C6B1FAE370B00ECDEDB /* FeedListFeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C6A1FAE370B00ECDEDB /* FeedListFeed.swift */; }; @@ -443,6 +444,7 @@ 846E77161F6EF5D000A165E2 /* Database.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Database.xcodeproj; path = Frameworks/Database/Database.xcodeproj; sourceTree = ""; }; 846E77301F6EF5D600A165E2 /* Account.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Account.xcodeproj; path = Frameworks/Account/Account.xcodeproj; sourceTree = ""; }; 84702AA31FA27AC0006B8943 /* MarkReadOrUnreadCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkReadOrUnreadCommand.swift; sourceTree = ""; }; + 847C4C9B1FF44F790090D517 /* FeedListSplitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListSplitViewController.swift; sourceTree = ""; }; 848F6AE41FC29CFA002D422E /* FaviconDownloader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FaviconDownloader.swift; sourceTree = ""; }; 849A97421ED9EAA9007D329B /* AddFolderWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddFolderWindowController.swift; sourceTree = ""; }; 849A97511ED9EAC0007D329B /* AddFeedController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AddFeedController.swift; path = AddFeed/AddFeedController.swift; sourceTree = ""; }; @@ -482,7 +484,6 @@ 849A97A51ED9F94D007D329B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Evergreen/Base.lproj/Preferences.storyboard; sourceTree = ""; }; 849A97A81ED9F9AA007D329B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Evergreen/Base.lproj/AddFeedSheet.xib; sourceTree = SOURCE_ROOT; }; 849A97AB1ED9F9BC007D329B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Evergreen/Base.lproj/AddFolderSheet.xib; sourceTree = SOURCE_ROOT; }; - 849A97AE1ED9FA08007D329B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Evergreen/Base.lproj/FeedList.storyboard; sourceTree = SOURCE_ROOT; }; 849A97B11ED9FA69007D329B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Evergreen/Base.lproj/MainWindow.storyboard; sourceTree = SOURCE_ROOT; }; 849B89681F0349C100578A8D /* RSParser.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSParser.xcodeproj; path = Frameworks/RSParser/RSParser.xcodeproj; sourceTree = ""; }; 849C64601ED37A5D003D8FC0 /* Evergreen.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Evergreen.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -502,6 +503,7 @@ 84B06FE01ED3803200F0B54B /* RSFeedFinder.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSFeedFinder.xcodeproj; path = Frameworks/RSFeedFinder/RSFeedFinder.xcodeproj; sourceTree = ""; }; 84B06FF41ED3818000F0B54B /* RSTree.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSTree.xcodeproj; path = Frameworks/RSTree/RSTree.xcodeproj; sourceTree = ""; }; 84B070011ED3821800F0B54B /* RSTextDrawing.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSTextDrawing.xcodeproj; path = Frameworks/RSTextDrawing/RSTextDrawing.xcodeproj; sourceTree = ""; }; + 84B2FAA31FF47BAC009C4878 /* FeedListWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FeedListWindow.xib; sourceTree = ""; }; 84B99C661FAE35E600ECDEDB /* FeedListTreeControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListTreeControllerDelegate.swift; sourceTree = ""; }; 84B99C681FAE36B800ECDEDB /* FeedListFolder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListFolder.swift; sourceTree = ""; }; 84B99C6A1FAE370B00ECDEDB /* FeedListFeed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListFeed.swift; sourceTree = ""; }; @@ -787,10 +789,11 @@ 849A978B1ED9EE4D007D329B /* Feed List */ = { isa = PBXGroup; children = ( - 849A97AD1ED9FA08007D329B /* FeedList.storyboard */, + 84B2FAA31FF47BAC009C4878 /* FeedListWindow.xib */, 849A978C1ED9EE4D007D329B /* FeedListWindowController.swift */, 84F204CD1FAACB660076E152 /* FeedListViewController.swift */, 84F204DD1FAACB8B0076E152 /* FeedListTimelineViewController.swift */, + 847C4C9B1FF44F790090D517 /* FeedListSplitViewController.swift */, 84513F8F1FAA63950023A1A9 /* FeedListControlsView.swift */, 84B99C661FAE35E600ECDEDB /* FeedListTreeControllerDelegate.swift */, 84B99C681FAE36B800ECDEDB /* FeedListFolder.swift */, @@ -1363,7 +1366,7 @@ 842E45E71ED8C747000A8B52 /* DB5.plist in Resources */, 844B5B691FEA20DF00C7C76A /* SidebarKeyboardShortcuts.plist in Resources */, 849A97AC1ED9F9BC007D329B /* AddFolderSheet.xib in Resources */, - 849A97AF1ED9FA08007D329B /* FeedList.storyboard in Resources */, + 84B2FAA41FF47BAC009C4878 /* FeedListWindow.xib in Resources */, 84E95CF71FABB3C800552D99 /* FeedList.plist in Resources */, 849C64681ED37A5D003D8FC0 /* Assets.xcassets in Resources */, 849C646B1ED37A5D003D8FC0 /* Main.storyboard in Resources */, @@ -1441,6 +1444,7 @@ 84B99C6B1FAE370B00ECDEDB /* FeedListFeed.swift in Sources */, 842611A01FCB72600086A189 /* FeaturedImageDownloader.swift in Sources */, 849A97781ED9EC04007D329B /* TimelineCellLayout.swift in Sources */, + 847C4C9C1FF44F790090D517 /* FeedListSplitViewController.swift in Sources */, 849A976C1ED9EBC8007D329B /* TimelineTableRowView.swift in Sources */, 849A977B1ED9EC04007D329B /* UnreadIndicatorView.swift in Sources */, 84B99C9D1FAE83C600ECDEDB /* DeleteFromSidebarCommand.swift in Sources */, @@ -1570,14 +1574,6 @@ name = AddFolderSheet.xib; sourceTree = ""; }; - 849A97AD1ED9FA08007D329B /* FeedList.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 849A97AE1ED9FA08007D329B /* Base */, - ); - name = FeedList.storyboard; - sourceTree = ""; - }; 849A97B01ED9FA69007D329B /* MainWindow.storyboard */ = { isa = PBXVariantGroup; children = ( diff --git a/Evergreen/AppDelegate.swift b/Evergreen/AppDelegate.swift index c99727c12..fa837ed38 100644 --- a/Evergreen/AppDelegate.swift +++ b/Evergreen/AppDelegate.swift @@ -267,7 +267,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, @IBAction func showFeedList(_ sender: AnyObject) { if feedListWindowController == nil { - feedListWindowController = windowControllerWithName("FeedList") + feedListWindowController = FeedListWindowController() } feedListWindowController!.showWindow(self) } diff --git a/Evergreen/Base.lproj/FeedList.storyboard b/Evergreen/Base.lproj/FeedList.storyboard deleted file mode 100644 index 9e5a0ed33..000000000 --- a/Evergreen/Base.lproj/FeedList.storyboard +++ /dev/null @@ -1,353 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Evergreen/FeedList/FeedListSplitViewController.swift b/Evergreen/FeedList/FeedListSplitViewController.swift new file mode 100644 index 000000000..ef0f9c178 --- /dev/null +++ b/Evergreen/FeedList/FeedListSplitViewController.swift @@ -0,0 +1,74 @@ +// +// FeedListSplitViewController.swift +// Evergreen +// +// Created by Brent Simmons on 12/27/17. +// Copyright © 2017 Ranchero Software. All rights reserved. +// + +import Cocoa +import DB5 + +final class FeedListSplitViewController: NSSplitViewController { + + @IBOutlet var sidebarSplitViewItem: NSSplitViewItem! + @IBOutlet var timelineSplitViewItem: NSSplitViewItem! + + private var sidebarView: NSView { + return sidebarSplitViewItem.viewController.view + } + + private var timelineView: NSView { + return timelineSplitViewItem.viewController.view + } + + override func viewDidLoad() { + + super.viewDidLoad() + + sidebarView.translatesAutoresizingMaskIntoConstraints = false + timelineView.translatesAutoresizingMaskIntoConstraints = false + + sidebarSplitViewItem.preferredThicknessFraction = NSSplitViewItem.unspecifiedDimension + sidebarSplitViewItem.canCollapse = false + timelineSplitViewItem.preferredThicknessFraction = NSSplitViewItem.unspecifiedDimension + timelineSplitViewItem.canCollapse = false + + let sidebarMinimumThickness = appDelegate.currentTheme.float(forKey: "FeedDirectory.sidebar.minimumThickness") + sidebarSplitViewItem.minimumThickness = sidebarMinimumThickness + let sidebarMaximumThickness = appDelegate.currentTheme.float(forKey: "FeedDirectory.sidebar.maximumThickness") + timelineSplitViewItem.maximumThickness = sidebarMaximumThickness + + let sidebarWidth = appDelegate.currentTheme.float(forKey: "FeedDirectory.sidebar.initialWidth") + splitView.setPosition(sidebarWidth, ofDividerAt: 0) + + let constraints = timelineView.constraintsAffectingLayout(for: .horizontal) + print(constraints) + } + + // MARK: - NSSplitViewDelegate + + override func splitView(_ splitView: NSSplitView, canCollapseSubview subview: NSView) -> Bool { + + super.splitView(splitView, canCollapseSubview: subview) + let constraints = timelineView.constraintsAffectingLayout(for: .horizontal) + print(constraints) + return false + } + + override func splitView(_ splitView: NSSplitView, shouldCollapseSubview subview: NSView, forDoubleClickOnDividerAt dividerIndex: Int) -> Bool { + + super.splitView(splitView, shouldCollapseSubview: view, forDoubleClickOnDividerAt: dividerIndex) + let constraints = timelineView.constraintsAffectingLayout(for: .horizontal) + print(constraints) + return false + } + + override func splitView(_ splitView: NSSplitView, shouldHideDividerAt dividerIndex: Int) -> Bool { + + super.splitView(splitView, shouldHideDividerAt: dividerIndex) + let constraints = timelineView.constraintsAffectingLayout(for: .horizontal) + print(constraints) + return false + } +} diff --git a/Evergreen/FeedList/FeedListViewController.swift b/Evergreen/FeedList/FeedListViewController.swift index 351b7da50..76c8f5713 100644 --- a/Evergreen/FeedList/FeedListViewController.swift +++ b/Evergreen/FeedList/FeedListViewController.swift @@ -27,6 +27,9 @@ final class FeedListViewController: NSViewController { NotificationCenter.default.addObserver(self, selector: #selector(faviconDidBecomeAvailable(_:)), name: .FaviconDidBecomeAvailable, object: nil) } + override func viewWillLayout() { + super.viewWillLayout() + } // MARK: - Notifications @objc func faviconDidBecomeAvailable(_ note: Notification) { diff --git a/Evergreen/FeedList/FeedListWindow.xib b/Evergreen/FeedList/FeedListWindow.xib new file mode 100644 index 000000000..3e3250dd4 --- /dev/null +++ b/Evergreen/FeedList/FeedListWindow.xib @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Evergreen/FeedList/FeedListWindowController.swift b/Evergreen/FeedList/FeedListWindowController.swift index 2f4a0c2f5..515ad1fae 100644 --- a/Evergreen/FeedList/FeedListWindowController.swift +++ b/Evergreen/FeedList/FeedListWindowController.swift @@ -11,6 +11,11 @@ import Cocoa class FeedListWindowController : NSWindowController { + public convenience init() { + + self.init(windowNibName: NSNib.Name(rawValue: "FeedListWindow")) + } + @IBAction func addToFeeds(_ sender: AnyObject) { } diff --git a/Evergreen/Resources/DB5.plist b/Evergreen/Resources/DB5.plist index cd3c6fbdb..b0f6d6b8b 100644 --- a/Evergreen/Resources/DB5.plist +++ b/Evergreen/Resources/DB5.plist @@ -129,6 +129,18 @@ FFFFFF + FeedDirectory + + sidebar + + initialWidth + 285 + minimumThickness + 220 + maximumThickness + 512 + +