Skip to content

Commit

Permalink
Add background color to UsageStackView
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmeuli committed Apr 16, 2020
1 parent 0afe89a commit 8fca295
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
4 changes: 4 additions & 0 deletions Glance.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
7E04C0472448E0BD00B54ED1 /* UsageStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E04C0462448E0BD00B54ED1 /* UsageStackView.swift */; };
7E1DC515240E5A4B00D0A061 /* shared-main.css in Resources */ = {isa = PBXBuildFile; fileRef = 7E1DC50A240E5A4B00D0A061 /* shared-main.css */; };
7E1DC51F240E6CE300D0A061 /* Renderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E1DC51E240E6CE300D0A061 /* Renderer.swift */; };
7E1DC521240E6D8000D0A061 /* MarkdownRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E1DC520240E6D8000D0A061 /* MarkdownRenderer.swift */; };
Expand Down Expand Up @@ -147,6 +148,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
7E04C0462448E0BD00B54ED1 /* UsageStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UsageStackView.swift; sourceTree = "<group>"; };
7E1DC50A240E5A4B00D0A061 /* shared-main.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = "shared-main.css"; sourceTree = "<group>"; };
7E1DC51E240E6CE300D0A061 /* Renderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Renderer.swift; sourceTree = "<group>"; };
7E1DC520240E6D8000D0A061 /* MarkdownRenderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkdownRenderer.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -538,6 +540,7 @@
7E3DF744242CBE7F00DE7CD6 /* Main.storyboard */,
7ECC8CF1240CB4CC000D6970 /* AppDelegate.swift */,
7ECC8CF3240CB4CC000D6970 /* ViewController.swift */,
7E04C0462448E0BD00B54ED1 /* UsageStackView.swift */,
);
path = Glance;
sourceTree = "<group>";
Expand Down Expand Up @@ -756,6 +759,7 @@
7E458AF52439481F0091BD0F /* Menu.swift in Sources */,
7E21C88D2438CAA500818EB2 /* Stats.swift in Sources */,
7ECC8CF2240CB4CC000D6970 /* AppDelegate.swift in Sources */,
7E04C0472448E0BD00B54ED1 /* UsageStackView.swift in Sources */,
7E458AF22439474E0091BD0F /* NSMenuItem.swift in Sources */,
7E21C89124390E3100818EB2 /* Date.swift in Sources */,
);
Expand Down
33 changes: 17 additions & 16 deletions Glance/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
<window key="window" title="Glance" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" titleVisibility="hidden" id="IQv-IB-iLA">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<rect key="contentRect" x="196" y="240" width="1040" height="560"/>
<rect key="contentRect" x="196" y="240" width="1040" height="600"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
<connections>
<outlet property="delegate" destination="B8D-0N-5wS" id="98r-iN-zZc"/>
Expand All @@ -388,17 +388,17 @@
<objects>
<viewController id="XfG-lQ-9wD" userLabel="MainViewController" customClass="ViewController" customModule="Glance" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="m2S-Jp-Qdl" userLabel="MainView">
<rect key="frame" x="0.0" y="0.0" width="1040" height="560"/>
<rect key="frame" x="0.0" y="0.0" width="1040" height="600"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<stackView distribution="equalSpacing" orientation="vertical" alignment="centerX" spacing="0.0" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="lK5-aM-ivS" userLabel="MainStackView">
<rect key="frame" x="40" y="40" width="960" height="480"/>
<rect key="frame" x="0.0" y="40" width="1040" height="520"/>
<subviews>
<stackView distribution="equalCentering" orientation="horizontal" alignment="centerY" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ptx-j9-3J7" userLabel="TitleOuterStackView">
<rect key="frame" x="0.0" y="430" width="960" height="50"/>
<rect key="frame" x="0.0" y="470" width="1040" height="50"/>
<subviews>
<stackView distribution="fill" orientation="horizontal" alignment="centerY" spacing="5" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="tdk-Iw-lqp" userLabel="TitleInnerStackView">
<rect key="frame" x="403" y="0.0" width="155" height="50"/>
<rect key="frame" x="442" y="0.0" width="157" height="50"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="vAk-NQ-xW6" userLabel="AppIconImageView">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
Expand All @@ -409,9 +409,9 @@
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="NSMobileMe" id="Xj9-Zy-3Ec" userLabel="AppIconImage"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="gMP-oA-EKJ" userLabel="AppNameLabel">
<rect key="frame" x="53" y="8" width="104" height="35"/>
<rect key="frame" x="53" y="8" width="106" height="35"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" alignment="center" title="Glance" id="NSJ-Vq-LPH">
<font key="font" metaFont="systemSemibold" size="30"/>
<font key="font" metaFont="systemBold" size="30"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
Expand All @@ -438,18 +438,18 @@
</customSpacing>
</stackView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="LNw-oW-7Vx">
<rect key="frame" x="409" y="380" width="142" height="16"/>
<rect key="frame" x="449" y="420" width="142" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Glance is ready to use!" id="gAo-UL-jRb">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<stackView distribution="fillEqually" orientation="horizontal" alignment="top" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="43y-hB-GSd" userLabel="UsageStackView">
<rect key="frame" x="0.0" y="106" width="960" height="240"/>
<stackView distribution="fillEqually" orientation="horizontal" alignment="top" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="43y-hB-GSd" userLabel="UsageStackView" customClass="UsageStackView" customModule="Glance" customModuleProvider="target">
<rect key="frame" x="0.0" y="106" width="1040" height="280"/>
<subviews>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="KBr-oC-Xwv" userLabel="FinderUsageStackView">
<rect key="frame" x="0.0" y="0.0" width="307" height="240"/>
<rect key="frame" x="40" y="20" width="307" height="240"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="we8-J8-KCq" userLabel="FinderUsageImageView">
<rect key="frame" x="0.0" y="78" width="300" height="162"/>
Expand Down Expand Up @@ -499,7 +499,7 @@
</customSpacing>
</stackView>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="I55-cO-0ho" userLabel="SpotlightUsageStackView">
<rect key="frame" x="327" y="0.0" width="306" height="240"/>
<rect key="frame" x="367" y="20" width="306" height="240"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="VTx-m2-UO1" userLabel="SpotlightUsageImageView">
<rect key="frame" x="0.0" y="78" width="300" height="162"/>
Expand Down Expand Up @@ -549,7 +549,7 @@
</customSpacing>
</stackView>
<stackView distribution="fill" orientation="vertical" alignment="leading" spacing="20" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Sj5-GY-onb" userLabel="QLUsageStackView">
<rect key="frame" x="653" y="0.0" width="307" height="240"/>
<rect key="frame" x="693" y="20" width="307" height="240"/>
<subviews>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="nkp-iN-Z3v" userLabel="QLUsageImageView">
<rect key="frame" x="0.0" y="78" width="300" height="162"/>
Expand Down Expand Up @@ -599,6 +599,7 @@
</customSpacing>
</stackView>
</subviews>
<edgeInsets key="edgeInsets" left="40" right="40" top="20" bottom="20"/>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
Expand All @@ -611,7 +612,7 @@
</customSpacing>
</stackView>
<stackView distribution="fillEqually" orientation="vertical" alignment="centerX" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Dz1-sz-nAq" userLabel="StatsStackView">
<rect key="frame" x="372" y="0.0" width="217" height="72"/>
<rect key="frame" x="412" y="0.0" width="217" height="72"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="2Yh-l8-rvY">
<rect key="frame" x="75" y="56" width="66" height="16"/>
Expand Down Expand Up @@ -753,9 +754,9 @@
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="lK5-aM-ivS" secondAttribute="trailing" constant="40" id="BJv-q8-uKV"/>
<constraint firstAttribute="trailing" secondItem="lK5-aM-ivS" secondAttribute="trailing" id="BJv-q8-uKV"/>
<constraint firstItem="lK5-aM-ivS" firstAttribute="top" secondItem="m2S-Jp-Qdl" secondAttribute="top" constant="40" id="LPL-cP-rkd"/>
<constraint firstItem="lK5-aM-ivS" firstAttribute="leading" secondItem="m2S-Jp-Qdl" secondAttribute="leading" constant="40" id="Ws1-to-cAo"/>
<constraint firstItem="lK5-aM-ivS" firstAttribute="leading" secondItem="m2S-Jp-Qdl" secondAttribute="leading" id="Ws1-to-cAo"/>
<constraint firstAttribute="bottom" secondItem="lK5-aM-ivS" secondAttribute="bottom" constant="40" id="xiv-ze-oty"/>
</constraints>
</view>
Expand Down
18 changes: 18 additions & 0 deletions Glance/UsageStackView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import Cocoa

class UsageStackView: NSStackView {
override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)

configure()
}

func configure() {
wantsLayer = true
if #available(OSX 10.14, *) {
self.layer?.backgroundColor = NSColor.alternatingContentBackgroundColors[0].cgColor
} else {
layer?.backgroundColor = NSColor.white.cgColor
}
}
}

0 comments on commit 8fca295

Please sign in to comment.