Skip to content

Commit 4990a57

Browse files
committed
About window
1 parent 14b67d0 commit 4990a57

File tree

5 files changed

+189
-1
lines changed

5 files changed

+189
-1
lines changed

ColorSet.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
0543AE9E20E0FFD000284E99 /* ColorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0543AE9D20E0FFD000284E99 /* ColorView.swift */; };
2020
05D11EC120E1359C00A621B5 /* ColorComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05D11EC020E1359C00A621B5 /* ColorComponent.swift */; };
2121
05D11EC720E13B9400A621B5 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 05D11EC620E13B9400A621B5 /* Icon.icns */; };
22+
05D11ECA20E13DFF00A621B5 /* ColorSet.AboutWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 05D11EC820E13DFF00A621B5 /* ColorSet.AboutWindowController.xib */; };
23+
05D11ECC20E13E0900A621B5 /* AboutWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05D11ECB20E13E0800A621B5 /* AboutWindowController.swift */; };
2224
/* End PBXBuildFile section */
2325

2426
/* Begin PBXFileReference section */
@@ -39,6 +41,8 @@
3941
0543AE9D20E0FFD000284E99 /* ColorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorView.swift; sourceTree = "<group>"; };
4042
05D11EC020E1359C00A621B5 /* ColorComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorComponent.swift; sourceTree = "<group>"; };
4143
05D11EC620E13B9400A621B5 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = "<group>"; };
44+
05D11EC920E13DFF00A621B5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/ColorSet.AboutWindowController.xib; sourceTree = "<group>"; };
45+
05D11ECB20E13E0800A621B5 /* AboutWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutWindowController.swift; sourceTree = "<group>"; };
4246
/* End PBXFileReference section */
4347

4448
/* Begin PBXFrameworksBuildPhase section */
@@ -82,6 +86,7 @@
8286
0543AE7320DC33DF00284E99 /* Classes */ = {
8387
isa = PBXGroup;
8488
children = (
89+
05D11ECB20E13E0800A621B5 /* AboutWindowController.swift */,
8590
0543AE7420DC33DF00284E99 /* ApplicationDelegate.swift */,
8691
0543AE7C20DC345200284E99 /* MainWindowController.swift */,
8792
0543AE8120DC382A00284E99 /* ColorItem.swift */,
@@ -103,6 +108,7 @@
103108
05D11EC620E13B9400A621B5 /* Icon.icns */,
104109
0543AE7720DC33DF00284E99 /* MainMenu.xib */,
105110
0543AE7E20DC35CC00284E99 /* ColorSet.MainWindowController.xib */,
111+
05D11EC820E13DFF00A621B5 /* ColorSet.AboutWindowController.xib */,
106112
);
107113
path = Interface;
108114
sourceTree = "<group>";
@@ -169,6 +175,7 @@
169175
05D11EC720E13B9400A621B5 /* Icon.icns in Resources */,
170176
0543AE8020DC35CC00284E99 /* ColorSet.MainWindowController.xib in Resources */,
171177
0543AE7B20DC33DF00284E99 /* MainMenu.xib in Resources */,
178+
05D11ECA20E13DFF00A621B5 /* ColorSet.AboutWindowController.xib in Resources */,
172179
);
173180
runOnlyForDeploymentPostprocessing = 0;
174181
};
@@ -180,6 +187,7 @@
180187
buildActionMask = 2147483647;
181188
files = (
182189
0530C42320E1213500F5B259 /* NSView.swift in Sources */,
190+
05D11ECC20E13E0900A621B5 /* AboutWindowController.swift in Sources */,
183191
0543AE9E20E0FFD000284E99 /* ColorView.swift in Sources */,
184192
0543AE8220DC382A00284E99 /* ColorItem.swift in Sources */,
185193
0530C41F20E10FEA00F5B259 /* ArrayIsEmpty.swift in Sources */,
@@ -210,6 +218,14 @@
210218
name = ColorSet.MainWindowController.xib;
211219
sourceTree = "<group>";
212220
};
221+
05D11EC820E13DFF00A621B5 /* ColorSet.AboutWindowController.xib */ = {
222+
isa = PBXVariantGroup;
223+
children = (
224+
05D11EC920E13DFF00A621B5 /* Base */,
225+
);
226+
name = ColorSet.AboutWindowController.xib;
227+
sourceTree = "<group>";
228+
};
213229
/* End PBXVariantGroup section */
214230

215231
/* Begin XCBuildConfiguration section */
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*******************************************************************************
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2018 Jean-David Gadina - www.xs-labs.com
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
******************************************************************************/
24+
25+
import Cocoa
26+
27+
@objc class AboutWindowController: NSWindowController
28+
{
29+
@objc private dynamic var name: String?
30+
@objc private dynamic var version: String?
31+
@objc private dynamic var copyright: String?
32+
33+
override var windowNibName: NSNib.Name?
34+
{
35+
return NSNib.Name( NSStringFromClass( type( of: self ) ) )
36+
}
37+
38+
override func windowDidLoad()
39+
{
40+
super.windowDidLoad()
41+
42+
self.window?.titlebarAppearsTransparent = true
43+
self.window?.titleVisibility = .hidden
44+
45+
self.name = Bundle.main.object( forInfoDictionaryKey: "CFBundleName" ) as? String
46+
self.version = Bundle.main.object( forInfoDictionaryKey: "CFBundleShortVersionString" ) as? String
47+
self.copyright = Bundle.main.object( forInfoDictionaryKey: "NSHumanReadableCopyright" ) as? String
48+
}
49+
}

ColorSet/Classes/ApplicationDelegate.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import Cocoa
2929
class ApplicationDelegate: NSResponder, NSApplicationDelegate
3030
{
3131
private var controllers = [ NSWindowController ]()
32+
private var aboutWindowController: NSWindowController?
3233

3334
func applicationDidFinishLaunching( _ notification: Notification )
3435
{
@@ -47,4 +48,16 @@ class ApplicationDelegate: NSResponder, NSApplicationDelegate
4748

4849
self.controllers.append( controller )
4950
}
51+
52+
@IBAction public func showAboutWindow( _ sender: Any? )
53+
{
54+
if( self.aboutWindowController == nil )
55+
{
56+
self.aboutWindowController = AboutWindowController()
57+
58+
self.aboutWindowController?.window?.center()
59+
}
60+
61+
self.aboutWindowController?.window?.makeKeyAndOrderFront( sender )
62+
}
5063
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14269.12" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
3+
<dependencies>
4+
<deployment identifier="macosx"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14269.12"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
7+
</dependencies>
8+
<objects>
9+
<customObject id="-2" userLabel="File's Owner" customClass="AboutWindowController" customModule="ColorSet" customModuleProvider="target">
10+
<connections>
11+
<outlet property="window" destination="QvC-M9-y7g" id="3uC-xA-AhB"/>
12+
</connections>
13+
</customObject>
14+
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
15+
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
16+
<window title="About" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g">
17+
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" fullSizeContentView="YES"/>
18+
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
19+
<rect key="contentRect" x="196" y="240" width="395" height="296"/>
20+
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1178"/>
21+
<view key="contentView" wantsLayer="YES" misplaced="YES" id="EiT-Mj-1SZ">
22+
<rect key="frame" x="0.0" y="0.0" width="503" height="296"/>
23+
<autoresizingMask key="autoresizingMask"/>
24+
<subviews>
25+
<visualEffectView appearanceType="vibrantDark" blendingMode="behindWindow" material="appearanceBased" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="2na-Z2-u9Y">
26+
<rect key="frame" x="0.0" y="0.0" width="503" height="296"/>
27+
<subviews>
28+
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="H8T-8E-DDN">
29+
<rect key="frame" x="20" y="20" width="256" height="256"/>
30+
<constraints>
31+
<constraint firstAttribute="width" constant="256" id="HER-vU-ej4"/>
32+
<constraint firstAttribute="height" constant="256" id="tEO-yL-v7f"/>
33+
</constraints>
34+
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="NSApplicationIcon" id="6bs-kJ-2MD"/>
35+
</imageView>
36+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="eUO-Xh-gcg">
37+
<rect key="frame" x="282" y="176" width="203" height="24"/>
38+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="n4t-G6-Fj5">
39+
<font key="font" metaFont="systemThin" size="20"/>
40+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
41+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
42+
</textFieldCell>
43+
<connections>
44+
<binding destination="-2" name="value" keyPath="version" id="9GC-rX-a5S"/>
45+
</connections>
46+
</textField>
47+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zOn-oh-QdP">
48+
<rect key="frame" x="282" y="55" width="203" height="17"/>
49+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="JEk-lW-tk0">
50+
<font key="font" metaFont="systemThin" size="13"/>
51+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
52+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
53+
</textFieldCell>
54+
<connections>
55+
<binding destination="-2" name="value" keyPath="copyright" id="j3k-9t-5tC"/>
56+
</connections>
57+
</textField>
58+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2ba-9s-ZV8">
59+
<rect key="frame" x="282" y="208" width="203" height="48"/>
60+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="UGy-b9-cuI">
61+
<font key="font" metaFont="systemThin" size="40"/>
62+
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
63+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
64+
</textFieldCell>
65+
<connections>
66+
<binding destination="-2" name="value" keyPath="name" id="OKL-6y-FGO"/>
67+
</connections>
68+
</textField>
69+
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ko5-dw-oga">
70+
<rect key="frame" x="282" y="30" width="203" height="17"/>
71+
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Pattern files from conwaylife.com" id="M60-WE-I8r">
72+
<font key="font" metaFont="systemThin" size="13"/>
73+
<color key="textColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
74+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
75+
</textFieldCell>
76+
</textField>
77+
</subviews>
78+
<constraints>
79+
<constraint firstItem="H8T-8E-DDN" firstAttribute="top" secondItem="2na-Z2-u9Y" secondAttribute="top" constant="20" id="3I5-PH-yU3"/>
80+
<constraint firstItem="ko5-dw-oga" firstAttribute="top" secondItem="zOn-oh-QdP" secondAttribute="bottom" constant="8" id="3WL-6S-SRg"/>
81+
<constraint firstItem="zOn-oh-QdP" firstAttribute="leading" secondItem="eUO-Xh-gcg" secondAttribute="leading" id="9z8-TQ-exV"/>
82+
<constraint firstItem="eUO-Xh-gcg" firstAttribute="top" secondItem="2ba-9s-ZV8" secondAttribute="bottom" constant="8" id="Ab9-it-JUm"/>
83+
<constraint firstAttribute="trailing" secondItem="ko5-dw-oga" secondAttribute="trailing" constant="20" id="Ay4-Pg-3jQ"/>
84+
<constraint firstAttribute="trailing" secondItem="zOn-oh-QdP" secondAttribute="trailing" constant="20" id="H1w-13-zMV"/>
85+
<constraint firstAttribute="bottom" secondItem="ko5-dw-oga" secondAttribute="bottom" constant="30" id="IFa-Dx-QfZ"/>
86+
<constraint firstItem="eUO-Xh-gcg" firstAttribute="leading" secondItem="2ba-9s-ZV8" secondAttribute="leading" id="QtV-Me-2JH"/>
87+
<constraint firstAttribute="trailing" secondItem="eUO-Xh-gcg" secondAttribute="trailing" constant="20" id="ZzX-cc-IvF"/>
88+
<constraint firstAttribute="trailing" secondItem="2ba-9s-ZV8" secondAttribute="trailing" constant="20" id="a49-qe-KTA"/>
89+
<constraint firstItem="2ba-9s-ZV8" firstAttribute="top" secondItem="H8T-8E-DDN" secondAttribute="top" constant="20" id="hUd-bj-u1o"/>
90+
<constraint firstItem="ko5-dw-oga" firstAttribute="leading" secondItem="zOn-oh-QdP" secondAttribute="leading" id="lQp-yw-gB7"/>
91+
<constraint firstItem="H8T-8E-DDN" firstAttribute="leading" secondItem="2na-Z2-u9Y" secondAttribute="leading" constant="20" id="qEC-HE-IWz"/>
92+
<constraint firstAttribute="bottom" secondItem="H8T-8E-DDN" secondAttribute="bottom" constant="20" id="sib-85-ry4"/>
93+
<constraint firstItem="2ba-9s-ZV8" firstAttribute="leading" secondItem="H8T-8E-DDN" secondAttribute="trailing" constant="8" id="zlY-3J-nRY"/>
94+
</constraints>
95+
</visualEffectView>
96+
</subviews>
97+
<constraints>
98+
<constraint firstItem="2na-Z2-u9Y" firstAttribute="width" secondItem="EiT-Mj-1SZ" secondAttribute="width" id="4dA-8n-C7v"/>
99+
<constraint firstItem="2na-Z2-u9Y" firstAttribute="centerY" secondItem="EiT-Mj-1SZ" secondAttribute="centerY" id="O55-qt-7R1"/>
100+
<constraint firstItem="2na-Z2-u9Y" firstAttribute="centerX" secondItem="EiT-Mj-1SZ" secondAttribute="centerX" id="dSe-Gv-BQM"/>
101+
<constraint firstItem="2na-Z2-u9Y" firstAttribute="height" secondItem="EiT-Mj-1SZ" secondAttribute="height" id="hu6-Xm-VtI"/>
102+
</constraints>
103+
</view>
104+
<point key="canvasLocation" x="-53.5" y="-162"/>
105+
</window>
106+
</objects>
107+
<resources>
108+
<image name="NSApplicationIcon" width="128" height="128"/>
109+
</resources>
110+
</document>

ColorSet/Interface/Base.lproj/MainMenu.xib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<menuItem title="About ColorSet" id="5kV-Vb-QxS">
2424
<modifierMask key="keyEquivalentModifierMask"/>
2525
<connections>
26-
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
26+
<action selector="showAboutWindow:" target="Voe-Tx-rLC" id="UZa-Hf-AqH"/>
2727
</connections>
2828
</menuItem>
2929
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>

0 commit comments

Comments
 (0)