Skip to content

Commit b56a096

Browse files
committed
Preparing for the color palette viewer
1 parent 89c8734 commit b56a096

File tree

5 files changed

+150
-0
lines changed

5 files changed

+150
-0
lines changed

ColorSet.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
0556FA602342156500EB91DB /* ColorItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0556FA5F2342156500EB91DB /* ColorItem.swift */; };
3333
0556FA63234215A100EB91DB /* ColorItem.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0556FA61234215A100EB91DB /* ColorItem.xib */; };
3434
0556FA652342169D00EB91DB /* DrawingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0556FA642342169D00EB91DB /* DrawingView.swift */; };
35+
0556FA67234275CF00EB91DB /* PaletteViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0556FA66234275CF00EB91DB /* PaletteViewController.swift */; };
36+
0556FA6A2342761000EB91DB /* ColorSet.PaletteViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0556FA682342761000EB91DB /* ColorSet.PaletteViewController.xib */; };
3537
0564590220E4DDFD001EA86F /* HexColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0564590120E4DDFD001EA86F /* HexColor.swift */; };
3638
057DC44E22B1492200BA6727 /* Test.swift in Sources */ = {isa = PBXBuildFile; fileRef = 057DC44D22B1492200BA6727 /* Test.swift */; };
3739
057DC45022B1492200BA6727 /* ColorSetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05CD4ABA20ED7CD100DBDE99 /* ColorSetKit.framework */; };
@@ -175,6 +177,8 @@
175177
0556FA5F2342156500EB91DB /* ColorItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorItem.swift; sourceTree = "<group>"; };
176178
0556FA62234215A100EB91DB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/ColorItem.xib; sourceTree = "<group>"; };
177179
0556FA642342169D00EB91DB /* DrawingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawingView.swift; sourceTree = "<group>"; };
180+
0556FA66234275CF00EB91DB /* PaletteViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaletteViewController.swift; sourceTree = "<group>"; };
181+
0556FA692342761000EB91DB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/ColorSet.PaletteViewController.xib; sourceTree = "<group>"; };
178182
0564590120E4DDFD001EA86F /* HexColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HexColor.swift; sourceTree = "<group>"; };
179183
057DC44B22B1492200BA6727 /* ColorSetKit-Test.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "ColorSetKit-Test.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
180184
057DC44D22B1492200BA6727 /* Test.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Test.swift; sourceTree = "<group>"; };
@@ -428,6 +432,7 @@
428432
0530C42220E1213500F5B259 /* NSView.swift */,
429433
05D11EC020E1359C00A621B5 /* RGBColorComponent.swift */,
430434
059F8C78233CDB3300C9B83F /* SLColorComponent.swift */,
435+
0556FA66234275CF00EB91DB /* PaletteViewController.swift */,
431436
);
432437
path = Classes;
433438
sourceTree = "<group>";
@@ -439,6 +444,7 @@
439444
05A6D8C32340EA880079AF3B /* ColorSet.LightnessPairCollectionViewItem.xib */,
440445
05A6D893233F805C0079AF3B /* ColorSet.LightnessPairWindowController.xib */,
441446
0543AE7E20DC35CC00284E99 /* ColorSet.MainWindowController.xib */,
447+
0556FA682342761000EB91DB /* ColorSet.PaletteViewController.xib */,
442448
05D11ECD20E165FB00A621B5 /* File.icns */,
443449
05D11EC620E13B9400A621B5 /* Icon.icns */,
444450
0543AE7720DC33DF00284E99 /* MainMenu.xib */,
@@ -636,6 +642,7 @@
636642
files = (
637643
05A6D8C52340EA880079AF3B /* ColorSet.LightnessPairCollectionViewItem.xib in Resources */,
638644
05D11EC720E13B9400A621B5 /* Icon.icns in Resources */,
645+
0556FA6A2342761000EB91DB /* ColorSet.PaletteViewController.xib in Resources */,
639646
0543AE8020DC35CC00284E99 /* ColorSet.MainWindowController.xib in Resources */,
640647
05D11ECE20E165FB00A621B5 /* File.icns in Resources */,
641648
0543AE7B20DC33DF00284E99 /* MainMenu.xib in Resources */,
@@ -703,6 +710,7 @@
703710
05A6D897233F8A300079AF3B /* LightnessString.swift in Sources */,
704711
05A6D8C22340EA740079AF3B /* LightnessPairCollectionViewItem.swift in Sources */,
705712
0530C41F20E10FEA00F5B259 /* ArrayIsEmpty.swift in Sources */,
713+
0556FA67234275CF00EB91DB /* PaletteViewController.swift in Sources */,
706714
059F8C79233CDB3300C9B83F /* HColorComponent.swift in Sources */,
707715
0530C42120E1112C00F5B259 /* ArrayIsNotEmpty.swift in Sources */,
708716
05D11EC120E1359C00A621B5 /* RGBColorComponent.swift in Sources */,
@@ -807,6 +815,14 @@
807815
name = ColorItem.xib;
808816
sourceTree = "<group>";
809817
};
818+
0556FA682342761000EB91DB /* ColorSet.PaletteViewController.xib */ = {
819+
isa = PBXVariantGroup;
820+
children = (
821+
0556FA692342761000EB91DB /* Base */,
822+
);
823+
name = ColorSet.PaletteViewController.xib;
824+
sourceTree = "<group>";
825+
};
810826
05A6D893233F805C0079AF3B /* ColorSet.LightnessPairWindowController.xib */ = {
811827
isa = PBXVariantGroup;
812828
children = (

ColorSet/Classes/MainWindowController.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ class MainWindowController: NSWindowController, NSTableViewDelegate, NSTableView
3838
private var searchField: NSSearchField?
3939
private var timer: Timer?
4040
private var lightnessPairWindowController: LightnessPairWindowController?
41+
private var paletteViewController: PaletteViewController?
4142

4243
@IBOutlet public var colorsArrayController: NSArrayController!
4344
@IBOutlet public var lightnessPairsArrayController: NSArrayController!
4445
@IBOutlet public var collectionView: NSCollectionView!
46+
@IBOutlet public var paletteViewContainer: NSView!
4547

4648
convenience init( colors: [ ColorItem ] )
4749
{
@@ -110,6 +112,8 @@ class MainWindowController: NSWindowController, NSTableViewDelegate, NSTableView
110112
self.selectedColor = nil
111113
self.hasVariant = false
112114

115+
self.paletteViewController?.reload()
116+
113117
return
114118
}
115119

@@ -144,6 +148,21 @@ class MainWindowController: NSWindowController, NSTableViewDelegate, NSTableView
144148
}
145149

146150
self.observations.append( contentsOf: [ o1, o2, o3 ] )
151+
152+
self.paletteViewController = PaletteViewController()
153+
154+
if let view = self.paletteViewController?.view
155+
{
156+
view.translatesAutoresizingMaskIntoConstraints = false
157+
view.frame = self.paletteViewContainer.bounds
158+
159+
self.paletteViewContainer.addSubview( view )
160+
161+
self.paletteViewContainer.addConstraint( NSLayoutConstraint( item: view, attribute: .centerX, relatedBy: .equal, toItem: self.paletteViewContainer, attribute: .centerX, multiplier: 1, constant: 0 ) )
162+
self.paletteViewContainer.addConstraint( NSLayoutConstraint( item: view, attribute: .centerY, relatedBy: .equal, toItem: self.paletteViewContainer, attribute: .centerY, multiplier: 1, constant: 0 ) )
163+
self.paletteViewContainer.addConstraint( NSLayoutConstraint( item: view, attribute: .width, relatedBy: .equal, toItem: self.paletteViewContainer, attribute: .width , multiplier: 1, constant: 0 ) )
164+
self.paletteViewContainer.addConstraint( NSLayoutConstraint( item: view, attribute: .height, relatedBy: .equal, toItem: self.paletteViewContainer, attribute: .height, multiplier: 1, constant: 0 ) )
165+
}
147166
}
148167

149168
private func updateLightnesses()
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*******************************************************************************
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2019 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+
class PaletteViewController: NSViewController
28+
{
29+
override var nibName: NSNib.Name?
30+
{
31+
return NSNib.Name( NSStringFromClass( type( of: self ) ) )
32+
}
33+
34+
public func reload()
35+
{}
36+
}

ColorSet/Interface/Base.lproj/ColorSet.MainWindowController.xib

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<outlet property="collectionView" destination="mhX-g4-VRX" id="rTI-iD-w0B"/>
1212
<outlet property="colorsArrayController" destination="awq-PE-ook" id="yeb-ma-uCR"/>
1313
<outlet property="lightnessPairsArrayController" destination="DHM-XC-Kf0" id="ZXr-Fj-3gp"/>
14+
<outlet property="paletteViewContainer" destination="de0-Td-j1L" id="9Te-ze-tdZ"/>
1415
<outlet property="window" destination="QvC-M9-y7g" id="OIr-lX-POC"/>
1516
</connections>
1617
</customObject>
@@ -202,6 +203,25 @@
202203
<visualEffectView blendingMode="behindWindow" material="appearanceBased" state="followsWindowActiveState" translatesAutoresizingMaskIntoConstraints="NO" id="bH4-hY-KH6">
203204
<rect key="frame" x="0.0" y="0.0" width="746" height="700"/>
204205
<subviews>
206+
<customView translatesAutoresizingMaskIntoConstraints="NO" id="de0-Td-j1L">
207+
<rect key="frame" x="0.0" y="0.0" width="746" height="700"/>
208+
<connections>
209+
<binding destination="awq-PE-ook" name="hidden2" keyPath="arrangedObjects" previousBinding="5ih-ct-4gf" id="qKl-pX-mO7">
210+
<dictionary key="options">
211+
<integer key="NSMultipleValuesPlaceholder" value="-1"/>
212+
<integer key="NSNoSelectionPlaceholder" value="-1"/>
213+
<integer key="NSNotApplicablePlaceholder" value="-1"/>
214+
<integer key="NSNullPlaceholder" value="-1"/>
215+
<string key="NSValueTransformerName">ColorSet.ArrayIsEmpty</string>
216+
</dictionary>
217+
</binding>
218+
<binding destination="-2" name="hidden" keyPath="selectedColor" id="5ih-ct-4gf">
219+
<dictionary key="options">
220+
<string key="NSValueTransformerName">NSIsNotNil</string>
221+
</dictionary>
222+
</binding>
223+
</connections>
224+
</customView>
205225
<textField identifier="ColorNameTextField" focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="yMG-Op-8D1">
206226
<rect key="frame" x="18" y="645" width="710" height="35"/>
207227
<textFieldCell key="cell" lineBreakMode="truncatingMiddle" selectable="YES" editable="YES" continuous="YES" sendsActionOnEndEditing="YES" focusRingType="none" alignment="center" title="Label" id="B9Y-7F-72Z">
@@ -233,6 +253,15 @@
233253
</constraints>
234254
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="File" id="BOZ-Aq-hR9"/>
235255
<connections>
256+
<binding destination="awq-PE-ook" name="hidden2" keyPath="arrangedObjects" previousBinding="z0Z-cg-1c7" id="0st-iJ-HhA">
257+
<dictionary key="options">
258+
<integer key="NSMultipleValuesPlaceholder" value="-1"/>
259+
<integer key="NSNoSelectionPlaceholder" value="-1"/>
260+
<integer key="NSNotApplicablePlaceholder" value="-1"/>
261+
<integer key="NSNullPlaceholder" value="-1"/>
262+
<string key="NSValueTransformerName">ColorSet.ArrayIsNotEmpty</string>
263+
</dictionary>
264+
</binding>
236265
<binding destination="awq-PE-ook" name="hidden" keyPath="selectedObjects" id="z0Z-cg-1c7">
237266
<dictionary key="options">
238267
<string key="NSValueTransformerName">ColorSet.ArrayIsNotEmpty</string>
@@ -251,6 +280,15 @@
251280
</allowedInputSourceLocales>
252281
</textFieldCell>
253282
<connections>
283+
<binding destination="awq-PE-ook" name="hidden2" keyPath="arrangedObjects" previousBinding="xCI-Bo-QRm" id="uqS-hM-i0W">
284+
<dictionary key="options">
285+
<integer key="NSMultipleValuesPlaceholder" value="-1"/>
286+
<integer key="NSNoSelectionPlaceholder" value="-1"/>
287+
<integer key="NSNotApplicablePlaceholder" value="-1"/>
288+
<integer key="NSNullPlaceholder" value="-1"/>
289+
<string key="NSValueTransformerName">ColorSet.ArrayIsNotEmpty</string>
290+
</dictionary>
291+
</binding>
254292
<binding destination="-2" name="hidden" keyPath="selectedColor" id="xCI-Bo-QRm">
255293
<dictionary key="options">
256294
<string key="NSValueTransformerName">NSIsNotNil</string>
@@ -1501,7 +1539,10 @@
15011539
<constraint firstItem="WxH-Cw-E69" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="bH4-hY-KH6" secondAttribute="leading" id="2OL-rN-2fg"/>
15021540
<constraint firstAttribute="trailing" secondItem="yIK-pa-iAO" secondAttribute="trailing" constant="20" id="2UG-Pc-aJV"/>
15031541
<constraint firstItem="p4I-Zg-0zJ" firstAttribute="centerX" secondItem="bH4-hY-KH6" secondAttribute="centerX" id="6dg-qn-rMt"/>
1542+
<constraint firstItem="de0-Td-j1L" firstAttribute="centerY" secondItem="bH4-hY-KH6" secondAttribute="centerY" id="7Yp-ex-0Jr"/>
15041543
<constraint firstItem="yMG-Op-8D1" firstAttribute="top" secondItem="bH4-hY-KH6" secondAttribute="top" constant="20" id="9TS-mu-uJI"/>
1544+
<constraint firstItem="de0-Td-j1L" firstAttribute="centerX" secondItem="bH4-hY-KH6" secondAttribute="centerX" id="Auk-oC-jsO"/>
1545+
<constraint firstItem="de0-Td-j1L" firstAttribute="width" secondItem="bH4-hY-KH6" secondAttribute="width" id="Ees-tG-0a3"/>
15051546
<constraint firstAttribute="trailing" secondItem="WxH-Cw-E69" secondAttribute="trailing" constant="20" id="Htr-MK-RV5"/>
15061547
<constraint firstItem="WxH-Cw-E69" firstAttribute="centerX" secondItem="p4I-Zg-0zJ" secondAttribute="centerX" id="J3u-u9-9H2"/>
15071548
<constraint firstItem="yIK-pa-iAO" firstAttribute="top" secondItem="yMG-Op-8D1" secondAttribute="bottom" constant="8" id="Jaz-Bh-621"/>
@@ -1511,6 +1552,7 @@
15111552
<constraint firstItem="p4I-Zg-0zJ" firstAttribute="centerY" secondItem="bH4-hY-KH6" secondAttribute="centerY" id="p4x-iP-b5x"/>
15121553
<constraint firstAttribute="bottom" secondItem="yIK-pa-iAO" secondAttribute="bottom" constant="20" id="pXg-Jj-sjV"/>
15131554
<constraint firstItem="yMG-Op-8D1" firstAttribute="leading" secondItem="bH4-hY-KH6" secondAttribute="leading" constant="20" id="r7B-Ew-prX"/>
1555+
<constraint firstItem="de0-Td-j1L" firstAttribute="height" secondItem="bH4-hY-KH6" secondAttribute="height" id="rco-uc-nxL"/>
15141556
</constraints>
15151557
</visualEffectView>
15161558
</subviews>

0 commit comments

Comments
 (0)