Make detail status bar show only on mouseover of a link. Don’t have an always-present view of the permalink. (We’ll see how this goes.)
This commit is contained in:
parent
953a97afd7
commit
a210dd2318
|
@ -612,44 +612,51 @@
|
|||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="cJ9-6s-66u" customClass="DetailContainerView" customModule="Evergreen" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="28" width="450" height="272"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
|
||||
<subviews>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="xI5-lx-RD8" customClass="DetailStatusBarView" customModule="Evergreen" customModuleProvider="target">
|
||||
<rect key="frame" x="6" y="2" width="12" height="20"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="850" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Dim-ed-Dcz" userLabel="URL Label">
|
||||
<rect key="frame" x="4" y="2" width="4" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" usesSingleLineMode="YES" id="znU-Fh-L7H">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="Dim-ed-Dcz" firstAttribute="centerY" secondItem="xI5-lx-RD8" secondAttribute="centerY" id="Hna-uB-3F7"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Dim-ed-Dcz" secondAttribute="trailing" constant="6" id="O5q-ZN-DjZ"/>
|
||||
<constraint firstAttribute="height" constant="20" id="Sfk-Ri-WoD"/>
|
||||
<constraint firstItem="Dim-ed-Dcz" firstAttribute="leading" secondItem="xI5-lx-RD8" secondAttribute="leading" constant="6" id="Y9c-WR-ZBY"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<outlet property="urlLabel" destination="Dim-ed-Dcz" id="8fY-oo-cGT"/>
|
||||
</connections>
|
||||
</customView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="xI5-lx-RD8" firstAttribute="leading" secondItem="cJ9-6s-66u" secondAttribute="leading" constant="6" id="5vz-ys-CAo"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="xI5-lx-RD8" secondAttribute="trailing" constant="6" id="pbD-LN-Gk1"/>
|
||||
<constraint firstAttribute="bottom" secondItem="xI5-lx-RD8" secondAttribute="bottom" constant="2" id="zsv-B0-ChW"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="color" keyPath="backgroundColor">
|
||||
<color key="value" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</customView>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="xI5-lx-RD8" customClass="DetailStatusBarView" customModule="Evergreen" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="0.0" width="450" height="28"/>
|
||||
<subviews>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="Dim-ed-Dcz" userLabel="URL Label">
|
||||
<rect key="frame" x="18" y="6" width="414" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="center" usesSingleLineMode="YES" id="znU-Fh-L7H">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="Dim-ed-Dcz" firstAttribute="centerY" secondItem="xI5-lx-RD8" secondAttribute="centerY" id="Hna-uB-3F7"/>
|
||||
<constraint firstAttribute="trailing" secondItem="Dim-ed-Dcz" secondAttribute="trailing" constant="20" symbolic="YES" id="O5q-ZN-DjZ"/>
|
||||
<constraint firstAttribute="height" constant="28" id="Sfk-Ri-WoD"/>
|
||||
<constraint firstItem="Dim-ed-Dcz" firstAttribute="leading" secondItem="xI5-lx-RD8" secondAttribute="leading" constant="20" symbolic="YES" id="Y9c-WR-ZBY"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<outlet property="urlLabel" destination="Dim-ed-Dcz" id="8fY-oo-cGT"/>
|
||||
<outlet property="detailStatusBarView" destination="xI5-lx-RD8" id="yIZ-aP-fKF"/>
|
||||
</connections>
|
||||
</customView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="xI5-lx-RD8" secondAttribute="trailing" id="9M9-ef-mCr"/>
|
||||
<constraint firstItem="cJ9-6s-66u" firstAttribute="leading" secondItem="37A-bp-izR" secondAttribute="leading" id="AM2-YB-J0B"/>
|
||||
<constraint firstAttribute="bottom" secondItem="xI5-lx-RD8" secondAttribute="bottom" id="DGH-Hk-TSv"/>
|
||||
<constraint firstItem="cJ9-6s-66u" firstAttribute="top" secondItem="37A-bp-izR" secondAttribute="top" id="DXp-ju-WpM"/>
|
||||
<constraint firstItem="xI5-lx-RD8" firstAttribute="top" secondItem="cJ9-6s-66u" secondAttribute="bottom" id="JJw-J8-N57"/>
|
||||
<constraint firstAttribute="trailing" secondItem="cJ9-6s-66u" secondAttribute="trailing" id="hUh-Uk-62r"/>
|
||||
<constraint firstItem="xI5-lx-RD8" firstAttribute="leading" secondItem="37A-bp-izR" secondAttribute="leading" id="oCj-Mo-oMU"/>
|
||||
<constraint firstAttribute="bottom" secondItem="cJ9-6s-66u" secondAttribute="bottom" id="wzr-Ci-6A8"/>
|
||||
</constraints>
|
||||
</customView>
|
||||
<connections>
|
||||
|
|
|
@ -14,40 +14,51 @@ final class DetailStatusBarView: NSView {
|
|||
|
||||
@IBOutlet var urlLabel: NSTextField!
|
||||
|
||||
// private var didConfigureLayer = false
|
||||
|
||||
private var article: Article? {
|
||||
didSet {
|
||||
updateURLLabel()
|
||||
}
|
||||
}
|
||||
private var didConfigureLayer = false
|
||||
private var mouseoverLink: String? {
|
||||
didSet {
|
||||
updateURLLabel()
|
||||
updateLinkForDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
private let backgroundColor = appDelegate.currentTheme.color(forKey: "MainWindow.Detail.statusBar.backgroundColor")
|
||||
private var linkForDisplay: String? {
|
||||
didSet {
|
||||
needsLayout = true
|
||||
if let link = linkForDisplay {
|
||||
urlLabel.stringValue = link
|
||||
self.isHidden = false
|
||||
}
|
||||
else {
|
||||
urlLabel.stringValue = ""
|
||||
self.isHidden = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override var isOpaque: Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
override var isFlipped: Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// override var wantsUpdateLayer: Bool {
|
||||
// return true
|
||||
// }
|
||||
//
|
||||
// override func updateLayer() {
|
||||
//
|
||||
// guard !didConfigureLayer else {
|
||||
// return
|
||||
// }
|
||||
// if let layer = layer {
|
||||
// let color = appDelegate.currentTheme.color(forKey: "MainWindow.Detail.statusBar.backgroundColor")
|
||||
// layer.backgroundColor = color.cgColor
|
||||
// didConfigureLayer = true
|
||||
// }
|
||||
// }
|
||||
override var wantsUpdateLayer: Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
override func updateLayer() {
|
||||
|
||||
guard !didConfigureLayer else {
|
||||
return
|
||||
}
|
||||
if let layer = layer {
|
||||
let color = appDelegate.currentTheme.color(forKey: "MainWindow.Detail.statusBar.backgroundColor")
|
||||
layer.backgroundColor = color.cgColor
|
||||
layer.cornerRadius = 4.0
|
||||
didConfigureLayer = true
|
||||
}
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
|
||||
|
@ -55,6 +66,8 @@ final class DetailStatusBarView: NSView {
|
|||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(mouseDidEnterLink(_:)), name: .MouseDidEnterLink, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(mouseDidExitLink(_:)), name: .MouseDidExitLink, object: nil)
|
||||
|
||||
alphaValue = 0.9
|
||||
}
|
||||
|
||||
// MARK: - Notifications
|
||||
|
@ -84,24 +97,6 @@ final class DetailStatusBarView: NSView {
|
|||
return
|
||||
}
|
||||
mouseoverLink = nil
|
||||
article = notification.userInfo?[UserInfoKey.article] as? Article
|
||||
}
|
||||
|
||||
// MARK: Drawing
|
||||
|
||||
private let lineColor = NSColor(calibratedWhite: 0.85, alpha: 1.0)
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
|
||||
backgroundColor.set()
|
||||
dirtyRect.fill()
|
||||
|
||||
let path = NSBezierPath()
|
||||
path.lineWidth = 1.0
|
||||
path.move(to: NSPoint(x: NSMinX(bounds), y: NSMinY(bounds) + 0.5))
|
||||
path.line(to: NSPoint(x: NSMaxX(bounds), y: NSMinY(bounds) + 0.5))
|
||||
lineColor.set()
|
||||
path.stroke()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,32 +104,15 @@ private extension DetailStatusBarView {
|
|||
|
||||
// MARK: URL Label
|
||||
|
||||
func updateURLLabel() {
|
||||
|
||||
needsLayout = true
|
||||
|
||||
guard let article = article else {
|
||||
setURLLabel("")
|
||||
return
|
||||
}
|
||||
func updateLinkForDisplay() {
|
||||
|
||||
if let mouseoverLink = mouseoverLink, !mouseoverLink.isEmpty {
|
||||
setURLLabel(mouseoverLink)
|
||||
return
|
||||
}
|
||||
|
||||
if let s = article.preferredLink {
|
||||
setURLLabel(s)
|
||||
linkForDisplay = (mouseoverLink as NSString).rs_stringByStrippingHTTPOrHTTPSScheme()
|
||||
}
|
||||
else {
|
||||
setURLLabel("")
|
||||
linkForDisplay = nil
|
||||
}
|
||||
}
|
||||
|
||||
func setURLLabel(_ link: String) {
|
||||
|
||||
urlLabel.stringValue = (link as NSString).rs_stringByStrippingHTTPOrHTTPSScheme()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -224,6 +224,8 @@ private extension DetailViewController {
|
|||
|
||||
final class DetailContainerView: NSView {
|
||||
|
||||
@IBOutlet var detailStatusBarView: DetailStatusBarView!
|
||||
|
||||
weak var viewController: DetailViewController? = nil
|
||||
|
||||
private var didConfigureLayer = false
|
||||
|
@ -239,7 +241,7 @@ final class DetailContainerView: NSView {
|
|||
}
|
||||
if let contentView = contentView {
|
||||
contentView.translatesAutoresizingMaskIntoConstraints = false
|
||||
addSubview(contentView)
|
||||
addSubview(contentView, positioned: .below, relativeTo: detailStatusBarView)
|
||||
rs_addFullSizeConstraints(forSubview: contentView)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
<key>statusBar</key>
|
||||
<dict>
|
||||
<key>backgroundColor</key>
|
||||
<string>FFFFFF</string>
|
||||
<string>F0F0F0</string>
|
||||
</dict>
|
||||
<key>backgroundColor</key>
|
||||
<string>FFFFFF</string>
|
||||
|
|
Loading…
Reference in New Issue