Permalink
Browse files

Add a preference panel for the colors used in the counter.

  • Loading branch information...
1 parent 19d4c0e commit 64fbbf544efee4a7fb188acf50214601c916576d @kamitchell kamitchell committed Oct 17, 2010
Showing with 1,231 additions and 33 deletions.
  1. +10 −0 Blitz.xcodeproj/project.pbxproj
  2. +4 −0 CounterView.h
  3. +6 −27 CounterView.m
  4. +58 −6 English.lproj/MainMenu.xib
  5. +3 −0 MyAppDelegate.h
  6. +43 −0 MyAppDelegate.m
  7. +15 −0 NSUserDefaults+ColorSupport.h
  8. +28 −0 NSUserDefaults+ColorSupport.m
  9. +1,064 −0 Preferences.xib
@@ -13,6 +13,8 @@
0A99C7A9126965BC00B0EAA5 /* MyAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A99C7A8126965BC00B0EAA5 /* MyAppDelegate.m */; };
0A99C7AE126965D000B0EAA5 /* CounterWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0A99C7AD126965D000B0EAA5 /* CounterWindow.xib */; };
0A9E2D30106DB7D5004CA409 /* CounterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A9E2D2F106DB7D5004CA409 /* CounterView.m */; };
+ 0AA66867126A96FA0009BD60 /* NSUserDefaults+ColorSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AA66866126A96FA0009BD60 /* NSUserDefaults+ColorSupport.m */; };
+ 0AB99A6E126A9C99000A4BF6 /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0AB99A6D126A9C99000A4BF6 /* Preferences.xib */; };
1DDD582C0DA1D0D100B32029 /* Slides.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58280DA1D0D100B32029 /* Slides.xib */; };
1DDD582D0DA1D0D100B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD582A0DA1D0D100B32029 /* MainMenu.xib */; };
345BF6AC10668503004BCEE3 /* SpeakerSlidesView.m in Sources */ = {isa = PBXBuildFile; fileRef = 345BF6AB10668503004BCEE3 /* SpeakerSlidesView.m */; };
@@ -73,6 +75,9 @@
0A99C7AD126965D000B0EAA5 /* CounterWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = CounterWindow.xib; sourceTree = "<group>"; };
0A9E2D2E106DB7D5004CA409 /* CounterView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CounterView.h; sourceTree = "<group>"; };
0A9E2D2F106DB7D5004CA409 /* CounterView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CounterView.m; sourceTree = "<group>"; };
+ 0AA66865126A96FA0009BD60 /* NSUserDefaults+ColorSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSUserDefaults+ColorSupport.h"; sourceTree = "<group>"; };
+ 0AA66866126A96FA0009BD60 /* NSUserDefaults+ColorSupport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSUserDefaults+ColorSupport.m"; sourceTree = "<group>"; };
+ 0AB99A6D126A9C99000A4BF6 /* Preferences.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Preferences.xib; sourceTree = "<group>"; };
1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = "<absolute>"; };
13E42FBA07B3F13500E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
1DDD58290DA1D0D100B32029 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/Slides.xib; sourceTree = "<group>"; };
@@ -165,6 +170,8 @@
2A37F4ABFDCFA73011CA2CEA /* Classes */ = {
isa = PBXGroup;
children = (
+ 0AA66865126A96FA0009BD60 /* NSUserDefaults+ColorSupport.h */,
+ 0AA66866126A96FA0009BD60 /* NSUserDefaults+ColorSupport.m */,
0A99C7A4126965B300B0EAA5 /* CustomWindow.h */,
0A99C7A5126965B300B0EAA5 /* CustomWindow.m */,
0A99C7A7126965BC00B0EAA5 /* MyAppDelegate.h */,
@@ -211,6 +218,7 @@
1DDD582A0DA1D0D100B32029 /* MainMenu.xib */,
34E6612D1065EB97001B6FE9 /* SpeakerNotes.xib */,
0A99C7AD126965D000B0EAA5 /* CounterWindow.xib */,
+ 0AB99A6D126A9C99000A4BF6 /* Preferences.xib */,
);
name = Resources;
sourceTree = "<group>";
@@ -286,6 +294,7 @@
34E6611E1065E938001B6FE9 /* presenter-notes.xsl in Resources */,
34E6612E1065EB97001B6FE9 /* SpeakerNotes.xib in Resources */,
0A99C7AE126965D000B0EAA5 /* CounterWindow.xib in Resources */,
+ 0AB99A6E126A9C99000A4BF6 /* Preferences.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -324,6 +333,7 @@
0A9E2D30106DB7D5004CA409 /* CounterView.m in Sources */,
0A99C7A6126965B300B0EAA5 /* CustomWindow.m in Sources */,
0A99C7A9126965BC00B0EAA5 /* MyAppDelegate.m in Sources */,
+ 0AA66867126A96FA0009BD60 /* NSUserDefaults+ColorSupport.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
@@ -1,6 +1,10 @@
#import <Cocoa/Cocoa.h>
#define UpdateSecondsElapsed @"UpdateSecondsElapsed"
+#define kCounterViewRingForeground @"CounterViewRingForeground"
+#define kCounterViewRingBackground @"CounterViewRingBackground"
+#define kCounterViewWedgeForeground @"CounterViewWedgeForeground"
+#define kCounterViewWedgeBackground @"CounterViewWedgeBackground"
@interface CounterView : NSView {
uint16_t secondsElapsed;
View
@@ -1,5 +1,5 @@
#import "CounterView.h"
-
+#import "NSUserDefaults+ColorSupport.h"
@implementation CounterView
@synthesize secondsElapsed;
@@ -22,27 +22,6 @@ - (void) dealloc {
[super dealloc];
}
-// Following function stolen from http://cocoa.karelia.com/Foundation_Categories/NSColor__Instantiat.m
-static NSColor* colorFromHexRGB( NSString *inColorString ) {
- NSColor *result = nil;
- unsigned int colorCode = 0;
- unsigned char redByte, greenByte, blueByte;
-
- if (nil != inColorString) {
- NSScanner *scanner = [NSScanner scannerWithString:inColorString];
- (void) [scanner scanHexInt:&colorCode]; // ignore error
- }
- redByte = (unsigned char) (colorCode >> 16);
- greenByte = (unsigned char) (colorCode >> 8);
- blueByte = (unsigned char) (colorCode); // masks off high bits
- result = [NSColor
- colorWithCalibratedRed: (float)redByte / 0xff
- green: (float)greenByte/ 0xff
- blue: (float)blueByte / 0xff
- alpha: 1.0];
- return result;
-}
-
#define threeOclock 0.0f
#define twelveOclock 90.0f
#define nineOclock 180.0f
@@ -54,7 +33,7 @@ - (void)drawRect:(NSRect)rect {
const CGFloat kOuterRingWidth = 8.0f;
- NSColor *outerSlideElapsedWedgeColor = colorFromHexRGB(@"2c8fff");
+ NSColor *outerSlideElapsedWedgeColor = [[NSUserDefaults standardUserDefaults] colorForKey:kCounterViewRingForeground];
NSRect bounds = [self bounds];
NSPoint center = NSMakePoint(NSMidX(bounds), NSMidY(bounds));
@@ -70,7 +49,7 @@ - (void)drawRect:(NSRect)rect {
[shadow setShadowOffset:NSMakeSize(2.0, -2.0)];
[shadow set];
- [colorFromHexRGB(@"32303d") set];
+ [[[NSUserDefaults standardUserDefaults] colorForKey:kCounterViewRingBackground] set];
[outerSlideRingBackground fill];
[[[[NSShadow alloc] init] autorelease] set];
@@ -107,7 +86,7 @@ - (void)drawRect:(NSRect)rect {
{
NSBezierPath *innerTalkCircleBackground = [NSBezierPath bezierPathWithOvalInRect:innerCircleBounds];
- [[NSColor blackColor] set];
+ [[[NSUserDefaults standardUserDefaults] colorForKey:kCounterViewWedgeBackground] set];
[innerTalkCircleBackground fill];
}
@@ -123,7 +102,7 @@ - (void)drawRect:(NSRect)rect {
[innerTalkElapsedWedge lineToPoint:center];
[innerTalkElapsedWedge closePath];
- [colorFromHexRGB(@"0046a8") set];
+ [[[NSUserDefaults standardUserDefaults] colorForKey:kCounterViewWedgeForeground] set];
[innerTalkElapsedWedge fill];
}
@@ -140,7 +119,7 @@ - (void)drawRect:(NSRect)rect {
[outerSlideElapsedWedgeColor colorWithAlphaComponent:0.02f], 0.80,
[outerSlideElapsedWedgeColor colorWithAlphaComponent:0.01f], 1.00,
nil] autorelease];
- NSGradient *dotGradient = [[[NSGradient alloc] initWithStartingColor:colorFromHexRGB(@"ffffff")
+ NSGradient *dotGradient = [[[NSGradient alloc] initWithStartingColor:[NSColor whiteColor]
endingColor:outerSlideElapsedWedgeColor] autorelease];
[[NSGraphicsContext currentContext] saveGraphicsState]; {
View
@@ -12,7 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="24"/>
+ <integer value="57"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -77,6 +77,25 @@
<reference key="NSOnImage" ref="1033313550"/>
<reference key="NSMixedImage" ref="310636482"/>
</object>
+ <object class="NSMenuItem" id="906902602">
+ <reference key="NSMenu" ref="110575045"/>
+ <bool key="NSIsDisabled">YES</bool>
+ <bool key="NSIsSeparator">YES</bool>
+ <string key="NSTitle"/>
+ <string key="NSKeyEquiv"/>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="1033313550"/>
+ <reference key="NSMixedImage" ref="310636482"/>
+ </object>
+ <object class="NSMenuItem" id="614493186">
+ <reference key="NSMenu" ref="110575045"/>
+ <string key="NSTitle">Preferences…</string>
+ <string key="NSKeyEquiv">,</string>
+ <int key="NSKeyEquivModMask">1048576</int>
+ <int key="NSMnemonicLoc">2147483647</int>
+ <reference key="NSOnImage" ref="1033313550"/>
+ <reference key="NSMixedImage" ref="310636482"/>
+ </object>
<object class="NSMenuItem" id="481834944">
<reference key="NSMenu" ref="110575045"/>
<bool key="NSIsDisabled">YES</bool>
@@ -965,6 +984,14 @@
</object>
<int key="connectionID">456</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">showPreferences:</string>
+ <reference key="source" ref="70522014"/>
+ <reference key="destination" ref="614493186"/>
+ </object>
+ <int key="connectionID">460</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1285,6 +1312,8 @@
<reference ref="1056857174"/>
<reference ref="342932134"/>
<reference ref="76175306"/>
+ <reference ref="614493186"/>
+ <reference ref="906902602"/>
</object>
<reference key="parent" ref="694149608"/>
</object>
@@ -1505,6 +1534,16 @@
<reference key="object" ref="953915714"/>
<reference key="parent" ref="835318025"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">457</int>
+ <reference key="object" ref="614493186"/>
+ <reference key="parent" ref="110575045"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">458</int>
+ <reference key="object" ref="906902602"/>
+ <reference key="parent" ref="110575045"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1641,9 +1680,10 @@
<string>354.IBPluginDependency</string>
<string>354.ImportedFromIB2</string>
<string>450.IBPluginDependency</string>
- <string>452.IBPluginDependency</string>
<string>454.IBPluginDependency</string>
<string>455.IBPluginDependency</string>
+ <string>457.IBPluginDependency</string>
+ <string>458.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>5.ImportedFromIB2</string>
<string>56.IBPluginDependency</string>
@@ -1805,10 +1845,11 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
- <string>{{328, 618}, {229, 173}}</string>
+ <string>{{328, 588}, {229, 203}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>{{23, 794}, {245, 183}}</string>
@@ -1846,7 +1887,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">456</int>
+ <int key="maxID">460</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1855,8 +1896,19 @@
<string key="className">MyAppDelegate</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="actions">
- <string key="NS.key.0">showFloatingCounters:</string>
- <string key="NS.object.0">id</string>
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>showFloatingCounters:</string>
+ <string>showPreferences:</string>
+ <string>startStopReset:</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
View
@@ -11,13 +11,15 @@
@interface MyAppDelegate : NSObject {
NSMutableArray *windowControllers;
+ NSWindowController *preferencesWindowController;
NSUInteger secondsElapsed;
KeynoteApplication *keynote;
bool running;
NSTimer *timer;
}
@property (retain) NSMutableArray *windowControllers;
+@property (retain) NSWindowController *preferencesWindowController;
@property (retain) KeynoteApplication *keynote;
@property (assign, setter=setSecondsElapsed:) NSUInteger secondsElapsed;
@property (assign) bool running;
@@ -27,5 +29,6 @@
- (void) setSecondsElapsed:(NSUInteger)elapsed;
- (IBAction)showFloatingCounters:(id)sender;
+- (IBAction)showPreferences:(id)sender;
@end
View
@@ -12,11 +12,46 @@
@implementation MyAppDelegate
@synthesize windowControllers;
+@synthesize preferencesWindowController;
@synthesize secondsElapsed;
@synthesize keynote;
@synthesize running;
@synthesize timer;
+// Following function stolen from http://cocoa.karelia.com/Foundation_Categories/NSColor__Instantiat.m
+static NSData* colorDataFromHexRGB( NSString *inColorString ) {
+ NSColor *result = nil;
+ unsigned int colorCode = 0;
+ unsigned char redByte, greenByte, blueByte;
+
+ if (nil != inColorString) {
+ NSScanner *scanner = [NSScanner scannerWithString:inColorString];
+ (void) [scanner scanHexInt:&colorCode]; // ignore error
+ }
+ redByte = (unsigned char) (colorCode >> 16);
+ greenByte = (unsigned char) (colorCode >> 8);
+ blueByte = (unsigned char) (colorCode); // masks off high bits
+ result = [NSColor
+ colorWithCalibratedRed: (float)redByte / 0xff
+ green: (float)greenByte/ 0xff
+ blue: (float)blueByte / 0xff
+ alpha: 1.0];
+ return [NSArchiver archivedDataWithRootObject:result];
+}
+
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
+{
+ NSUserDefaults *preferences = [NSUserDefaults standardUserDefaults];
+ NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
+ colorDataFromHexRGB(@"2c8fff"), kCounterViewRingForeground,
+ colorDataFromHexRGB(@"32303d"), kCounterViewRingBackground,
+ colorDataFromHexRGB(@"0046ff"), kCounterViewWedgeForeground,
+ colorDataFromHexRGB(@"000000"), kCounterViewWedgeBackground,
+ nil];
+
+ [preferences registerDefaults:dict];
+}
+
- (IBAction)startStopReset:(id)sender
{
if (self.running)
@@ -104,4 +139,12 @@ - (IBAction)showFloatingCounters:(id)sender
[controller showWindow:self];
}
}
+
+- (IBAction)showPreferences:(id)sender
+{
+ if (self.preferencesWindowController == nil)
+ self.preferencesWindowController = [[NSWindowController alloc] initWithWindowNibName:@"Preferences"];
+
+ [self.preferencesWindowController showWindow:self];
+}
@end
@@ -0,0 +1,15 @@
+//
+// NSUserDefaults+ColorSupport.h
+// Blitz
+//
+// Created by Kevin Mitchell on 10/16/10.
+// Copyright 2010 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface NSUserDefaults(ColorSupport)
+ - (void)setColor:(NSColor *)aColor forKey:(NSString *)aKey;
+ - (NSColor *)colorForKey:(NSString *)aKey;
+@end
Oops, something went wrong.

0 comments on commit 64fbbf5

Please sign in to comment.