diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index 69f5a5582..7a85f7e75 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -16,6 +16,10 @@ 6581C74220CED60100F4AD34 /* ToolbarItemIcon.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 6581C74120CED60100F4AD34 /* ToolbarItemIcon.pdf */; }; 8405DD8A2213E0E3008CE1BF /* DetailContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8405DD892213E0E3008CE1BF /* DetailContainerView.swift */; }; 8405DD8B2213E0E3008CE1BF /* DetailContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8405DD892213E0E3008CE1BF /* DetailContainerView.swift */; }; + 8405DD9922153B6B008CE1BF /* TimelineContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8405DD9822153B6B008CE1BF /* TimelineContainerView.swift */; }; + 8405DD9A22153B6B008CE1BF /* TimelineContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8405DD9822153B6B008CE1BF /* TimelineContainerView.swift */; }; + 8405DD9C22153BD7008CE1BF /* NSView-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8405DD9B22153BD7008CE1BF /* NSView-Extensions.swift */; }; + 8405DD9D22153BD7008CE1BF /* NSView-Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8405DD9B22153BD7008CE1BF /* NSView-Extensions.swift */; }; 840958632201629A002C1579 /* Subscribe to Feed.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 6581C73320CED60000F4AD34 /* Subscribe to Feed.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 840BEE4121D70E64009BBAFA /* CrashReportWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840BEE4021D70E64009BBAFA /* CrashReportWindowController.swift */; }; 840D617F2029031C009BC708 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 840D617E2029031C009BC708 /* AppDelegate.swift */; }; @@ -736,6 +740,8 @@ 6581C74320CED60100F4AD34 /* Subscribe_to_Feed.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Subscribe_to_Feed.entitlements; sourceTree = ""; }; 8403E75A201C4A79007F7246 /* FeedListKeyboardDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListKeyboardDelegate.swift; sourceTree = ""; }; 8405DD892213E0E3008CE1BF /* DetailContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailContainerView.swift; sourceTree = ""; }; + 8405DD9822153B6B008CE1BF /* TimelineContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineContainerView.swift; sourceTree = ""; }; + 8405DD9B22153BD7008CE1BF /* NSView-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSView-Extensions.swift"; sourceTree = ""; }; 840BEE4021D70E64009BBAFA /* CrashReportWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashReportWindowController.swift; sourceTree = ""; }; 840D617C2029031C009BC708 /* NetNewsWire.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = NetNewsWire.app; sourceTree = BUILT_PRODUCTS_DIR; }; 840D617E2029031C009BC708 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; @@ -1292,6 +1298,7 @@ isa = PBXGroup; children = ( 849A976B1ED9EBC8007D329B /* TimelineViewController.swift */, + 8405DD9822153B6B008CE1BF /* TimelineContainerView.swift */, 84E8E0DA202EC49300562D8F /* TimelineViewController+ContextualMenus.swift */, 84F204DF1FAACBB30076E152 /* ArticleArray.swift */, 849A97691ED9EBC8007D329B /* TimelineTableRowView.swift */, @@ -1374,6 +1381,7 @@ isa = PBXGroup; children = ( 849A97971ED9EFAA007D329B /* Node-Extensions.swift */, + 8405DD9B22153BD7008CE1BF /* NSView-Extensions.swift */, ); name = Extensions; path = NetNewsWire/Extensions; @@ -2403,6 +2411,7 @@ 840F7C5721BDA4B40057E851 /* StarredFeedDelegate.swift in Sources */, 840F7C5821BDA4B40057E851 /* FaviconDownloader.swift in Sources */, 840F7C5921BDA4B40057E851 /* FeedSpecifier.swift in Sources */, + 8405DD9A22153B6B008CE1BF /* TimelineContainerView.swift in Sources */, 840F7C5A21BDA4B40057E851 /* SharingServicePickerDelegate.swift in Sources */, 840F7C5B21BDA4B40057E851 /* Node-Extensions.swift in Sources */, 840F7C5C21BDA4B40057E851 /* AppImages.swift in Sources */, @@ -2411,6 +2420,7 @@ 840F7C6021BDA4B40057E851 /* TodayFeedDelegate.swift in Sources */, 840F7C6121BDA4B40057E851 /* FolderInspectorViewController.swift in Sources */, 840F7C6221BDA4B40057E851 /* ImageDownloader.swift in Sources */, + 8405DD9D22153BD7008CE1BF /* NSView-Extensions.swift in Sources */, 840F7C6321BDA4B40057E851 /* AddFolderWindowController.swift in Sources */, 840F7C6421BDA4B40057E851 /* MainWIndowKeyboardHandler.swift in Sources */, 840F7C6521BDA4B40057E851 /* PasteboardFeed.swift in Sources */, @@ -2487,6 +2497,7 @@ 84CC88181FE59CBF00644329 /* SmartFeedsController.swift in Sources */, 849A97661ED9EB96007D329B /* SidebarViewController.swift in Sources */, 849A97641ED9EB96007D329B /* SidebarOutlineView.swift in Sources */, + 8405DD9922153B6B008CE1BF /* TimelineContainerView.swift in Sources */, D5A2678C20130ECF00A8D3C0 /* Author+Scriptability.swift in Sources */, 84F2D5371FC22FCC00998D64 /* PseudoFeed.swift in Sources */, D57BE6E0204CD35F00D11AAC /* NSScriptCommand+NetNewsWire.swift in Sources */, @@ -2495,6 +2506,7 @@ 845EE7C11FC2488C00854A1F /* SmartFeed.swift in Sources */, 84702AA41FA27AC0006B8943 /* MarkStatusCommand.swift in Sources */, D5907D7F2004AC00005947E5 /* NSApplication+Scriptability.swift in Sources */, + 8405DD9C22153BD7008CE1BF /* NSView-Extensions.swift in Sources */, 849A979F1ED9F130007D329B /* SidebarCell.swift in Sources */, 849A97651ED9EB96007D329B /* SidebarTreeControllerDelegate.swift in Sources */, 849A97671ED9EB96007D329B /* UnreadCountView.swift in Sources */, diff --git a/NetNewsWire/Extensions/NSView-Extensions.swift b/NetNewsWire/Extensions/NSView-Extensions.swift new file mode 100644 index 000000000..2c5aff1d0 --- /dev/null +++ b/NetNewsWire/Extensions/NSView-Extensions.swift @@ -0,0 +1,20 @@ +// +// NSView-Extensions.swift +// NetNewsWire +// +// Created by Brent Simmons on 2/13/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import AppKit + +extension NSView { + + func constraintsToMakeSubViewFullSize(_ subview: NSView) -> [NSLayoutConstraint] { + let leadingConstraint = NSLayoutConstraint(item: subview, attribute: .leading, relatedBy: .equal, toItem: self, attribute: .leading, multiplier: 1.0, constant: 0.0) + let trailingConstraint = NSLayoutConstraint(item: subview, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1.0, constant: 0.0) + let topConstraint = NSLayoutConstraint(item: subview, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0.0) + let bottomConstraint = NSLayoutConstraint(item: subview, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0.0) + return [leadingConstraint, trailingConstraint, topConstraint, bottomConstraint] + } +} diff --git a/NetNewsWire/MainWindow/Detail/DetailContainerView.swift b/NetNewsWire/MainWindow/Detail/DetailContainerView.swift index 7bf67cc63..a33ee835b 100644 --- a/NetNewsWire/MainWindow/Detail/DetailContainerView.swift +++ b/NetNewsWire/MainWindow/Detail/DetailContainerView.swift @@ -6,7 +6,7 @@ // Copyright © 2019 Ranchero Software. All rights reserved. // -import Cocoa +import AppKit final class DetailContainerView: NSView { @@ -33,11 +33,7 @@ final class DetailContainerView: NSView { if let contentView = contentView { contentView.translatesAutoresizingMaskIntoConstraints = false addSubview(contentView, positioned: .below, relativeTo: detailStatusBarView) - let leadingConstraint = NSLayoutConstraint(item: contentView, attribute: .leading, relatedBy: .equal, toItem: self, attribute: .leading, multiplier: 1.0, constant: 0.0) - let trailingConstraint = NSLayoutConstraint(item: contentView, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1.0, constant: 0.0) - let topConstraint = NSLayoutConstraint(item: contentView, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0.0) - let bottomConstraint = NSLayoutConstraint(item: contentView, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0.0) - let constraints = [leadingConstraint, trailingConstraint, topConstraint, bottomConstraint] + let constraints = constraintsToMakeSubViewFullSize(contentView) NSLayoutConstraint.activate(constraints) contentViewConstraints = constraints } diff --git a/NetNewsWire/MainWindow/Timeline/TimelineContainerView.swift b/NetNewsWire/MainWindow/Timeline/TimelineContainerView.swift new file mode 100644 index 000000000..4f8a4bbe4 --- /dev/null +++ b/NetNewsWire/MainWindow/Timeline/TimelineContainerView.swift @@ -0,0 +1,45 @@ +// +// TimelineContainerView.swift +// NetNewsWire +// +// Created by Brent Simmons on 2/13/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import AppKit + +final class TimelineContainerView: NSView { + + override var isOpaque: Bool { + return true + } + + var contentViewConstraints: [NSLayoutConstraint]? + + var contentView: NSView? { + didSet { + if contentView == oldValue { + return + } + + if let currentConstraints = contentViewConstraints { + NSLayoutConstraint.deactivate(currentConstraints) + } + contentViewConstraints = nil + oldValue?.removeFromSuperviewWithoutNeedingDisplay() + + if let contentView = contentView { + contentView.translatesAutoresizingMaskIntoConstraints = false + addSubview(contentView) + let constraints = constraintsToMakeSubViewFullSize(contentView) + NSLayoutConstraint.activate(constraints) + contentViewConstraints = constraints + } + } + } + + override func draw(_ dirtyRect: NSRect) { + NSColor.textBackgroundColor.setFill() + dirtyRect.fill() + } +}