mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-24 22:33:52 +03:00
Play around with colors
This commit is contained in:
parent
11e00760d3
commit
c357517ed5
@ -53,7 +53,10 @@ class Tab: NSView {
|
||||
required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") }
|
||||
|
||||
var isSelected: Bool = false {
|
||||
didSet { self.needsDisplay = true }
|
||||
didSet {
|
||||
self.adjustToSelectionChange()
|
||||
self.needsDisplay = true
|
||||
}
|
||||
}
|
||||
|
||||
weak var delegate: TabDelegate?
|
||||
@ -69,6 +72,16 @@ class Tab: NSView {
|
||||
}
|
||||
|
||||
extension Tab {
|
||||
private func adjustToSelectionChange() {
|
||||
if self.isSelected {
|
||||
self.layer?.backgroundColor = self.theme.selectedBackgroundColor.cgColor
|
||||
self.titleView.textColor = self.theme.selectedForegroundColor
|
||||
} else {
|
||||
self.layer?.backgroundColor = self.theme.backgroundColor.cgColor
|
||||
self.titleView.textColor = self.theme.foregroundColor
|
||||
}
|
||||
}
|
||||
|
||||
private func adjustWidth() {
|
||||
let idealWidth = 4 * self.theme.tabHorizontalPadding + 2 * self.theme.iconDimension.width
|
||||
+ self.titleView.intrinsicContentSize.width
|
||||
@ -143,14 +156,19 @@ extension Tab {
|
||||
left.fill()
|
||||
}
|
||||
|
||||
if !self.isSelected { bottom.fill() }
|
||||
bottom.fill()
|
||||
}
|
||||
|
||||
private func drawSelectionIndicator() {
|
||||
guard self.isSelected else { return }
|
||||
|
||||
let b = self.bounds
|
||||
let rect = CGRect(x: 0, y: 0, width: b.width, height: self.theme.tabSelectionIndicatorThickness)
|
||||
let rect = CGRect(
|
||||
x: self.theme.separatorThickness,
|
||||
y: self.theme.separatorThickness,
|
||||
width: b.width,
|
||||
height: self.theme.tabSelectionIndicatorThickness
|
||||
)
|
||||
|
||||
guard let context = NSGraphicsContext.current?.cgContext else { return }
|
||||
context.saveGState()
|
||||
|
@ -12,7 +12,10 @@ public struct Theme {
|
||||
public var backgroundColor = NSColor.controlBackgroundColor
|
||||
public var separatorColor = NSColor.controlShadowColor
|
||||
|
||||
public var tabSelectedIndicatorColor = NSColor.selectedControlColor
|
||||
public var selectedForegroundColor = NSColor.textColor
|
||||
public var selectedBackgroundColor = NSColor.selectedControlColor
|
||||
|
||||
public var tabSelectedIndicatorColor = NSColor.blue
|
||||
|
||||
public var titleFont = NSFont.systemFont(ofSize: 11)
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11134" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="17506" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11134"/>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17506"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
@ -10,8 +12,8 @@
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSApplication"/>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider="target">
|
||||
<customObject id="-3" userLabel="Application"/>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="TabsSupport" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
|
||||
</connections>
|
||||
@ -677,16 +679,18 @@
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
<point key="canvasLocation" x="24" y="154"/>
|
||||
</menu>
|
||||
<window title="TabsSupport" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="2880" height="1597"/>
|
||||
<view key="contentView" id="EiT-Mj-1SZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</view>
|
||||
<point key="canvasLocation" x="24" y="-120"/>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
||||
|
Loading…
Reference in New Issue
Block a user