Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyhoer committed Nov 29, 2015
1 parent 21d1ae2 commit d87478f
Show file tree
Hide file tree
Showing 15 changed files with 487 additions and 0 deletions.
265 changes: 265 additions & 0 deletions Colors.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
3178899F1C0B58EA00345AB8 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 3178899E1C0B58EA00345AB8 /* MainMenu.xib */; settings = {ASSET_TAGS = (); }; };
31F327221C055A3E0027DE25 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31F327211C055A3E0027DE25 /* AppDelegate.swift */; };
31F327241C055A3F0027DE25 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 31F327231C055A3F0027DE25 /* Assets.xcassets */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
3178899E1C0B58EA00345AB8 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = "<group>"; };
31F3271E1C055A3E0027DE25 /* Colors.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Colors.app; sourceTree = BUILT_PRODUCTS_DIR; };
31F327211C055A3E0027DE25 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
31F327231C055A3F0027DE25 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
31F327281C055A3F0027DE25 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
31F3271B1C055A3E0027DE25 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
31F327151C055A3E0027DE25 = {
isa = PBXGroup;
children = (
31F327201C055A3E0027DE25 /* Colors */,
31F3271F1C055A3E0027DE25 /* Products */,
);
sourceTree = "<group>";
};
31F3271F1C055A3E0027DE25 /* Products */ = {
isa = PBXGroup;
children = (
31F3271E1C055A3E0027DE25 /* Colors.app */,
);
name = Products;
sourceTree = "<group>";
};
31F327201C055A3E0027DE25 /* Colors */ = {
isa = PBXGroup;
children = (
31F327211C055A3E0027DE25 /* AppDelegate.swift */,
31F327231C055A3F0027DE25 /* Assets.xcassets */,
3178899E1C0B58EA00345AB8 /* MainMenu.xib */,
31F327281C055A3F0027DE25 /* Info.plist */,
);
path = Colors;
sourceTree = SOURCE_ROOT;
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
31F3271D1C055A3E0027DE25 /* Colors */ = {
isa = PBXNativeTarget;
buildConfigurationList = 31F3272B1C055A3F0027DE25 /* Build configuration list for PBXNativeTarget "Colors" */;
buildPhases = (
31F3271A1C055A3E0027DE25 /* Sources */,
31F3271B1C055A3E0027DE25 /* Frameworks */,
31F3271C1C055A3E0027DE25 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = Colors;
productName = Color;
productReference = 31F3271E1C055A3E0027DE25 /* Colors.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
31F327161C055A3E0027DE25 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Joey Hoer";
TargetAttributes = {
31F3271D1C055A3E0027DE25 = {
CreatedOnToolsVersion = 7.0.1;
};
};
};
buildConfigurationList = 31F327191C055A3E0027DE25 /* Build configuration list for PBXProject "Colors" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 31F327151C055A3E0027DE25;
productRefGroup = 31F3271F1C055A3E0027DE25 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
31F3271D1C055A3E0027DE25 /* Colors */,
);
};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
31F3271C1C055A3E0027DE25 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
31F327241C055A3F0027DE25 /* Assets.xcassets in Resources */,
3178899F1C0B58EA00345AB8 /* MainMenu.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
31F3271A1C055A3E0027DE25 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
31F327221C055A3E0027DE25 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin XCBuildConfiguration section */
31F327291C055A3F0027DE25 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
31F3272A1C055A3F0027DE25 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
};
name = Release;
};
31F3272C1C055A3F0027DE25 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = Colors;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Colors/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.joeyhoer.Colors;
PRODUCT_NAME = Colors;
};
name = Debug;
};
31F3272D1C055A3F0027DE25 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = Colors;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = Colors/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.joeyhoer.Colors;
PRODUCT_NAME = Colors;
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
31F327191C055A3E0027DE25 /* Build configuration list for PBXProject "Colors" */ = {
isa = XCConfigurationList;
buildConfigurations = (
31F327291C055A3F0027DE25 /* Debug */,
31F3272A1C055A3F0027DE25 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
31F3272B1C055A3F0027DE25 /* Build configuration list for PBXNativeTarget "Colors" */ = {
isa = XCConfigurationList;
buildConfigurations = (
31F3272C1C055A3F0027DE25 /* Debug */,
31F3272D1C055A3F0027DE25 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 31F327161C055A3E0027DE25 /* Project object */;
}
84 changes: 84 additions & 0 deletions Colors/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
// AppDelegate.swift
// Colors
//
// Created by Joey Hoer on 11/24/15.
// Copyright © 2015 Joey Hoer. All rights reserved.
//

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var window: NSWindow!

let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(NSSquareStatusItemLength)
let colorPanel = NSColorPanel.sharedColorPanel()
let menu = NSMenu()

func applicationDidFinishLaunching(aNotification: NSNotification) {
if let button = statusItem.button {
button.image = NSImage(named: "Colors")
button.action = Selector("pickColor:")


// (Re)Declare Objective-C defined constants
let NSLeftMouseDownMask = 1 << 1
let NSRightMouseDownMask = 1 << 3

// Attach action to both left and right clicks
button.sendActionOn(NSLeftMouseDownMask | NSRightMouseDownMask)

// Display button as disabled
//button.appearsDisabled = true

// Do not hide color panel when application is switched
colorPanel.hidesOnDeactivate = false

// Do not highlight statu item when clicked
statusItem.highlightMode = false

// Set window level
//colorPanel.level = Int(CGWindowLevelForKey(.NormalWindowLevelKey))

// Setup menu items
// Store application name
let appName = NSBundle.mainBundle().infoDictionary?[kCFBundleNameKey as String] as? String
// Setup "Quit" menu item
menu.addItem(NSMenuItem(title: "Quit " + appName!, action: Selector("terminate:"), keyEquivalent: ""))

// Set menu; will be shown when action is executed
//statusItem.menu = menu

}
}

func applicationWillTerminate(aNotification: NSNotification) {
// Nothing to do here
}

func pickColor(sender: NSMenuItem) {
let flags = NSEvent.modifierFlags()

if (flags == NSEventModifierFlags.AlternateKeyMask) {
statusItem.highlightMode = true
statusItem.popUpStatusItemMenu(menu)
statusItem.highlightMode = false
} else {
// if (!colorPanel.visible) {

// Focus application
NSApplication.sharedApplication().activateIgnoringOtherApps(true)

// Bring window to front
colorPanel.makeKeyAndOrderFront(sender)

// } else {
// // Close color panel
// colorPanel.close()
// }
}
}

}
Loading

0 comments on commit d87478f

Please sign in to comment.