Skip to content

Commit

Permalink
Fixed issue with defaults, tweaked font sizing, set version to 0.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
pjbeardsley committed Jul 23, 2012
1 parent 7dace2b commit bf29988
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
7 changes: 4 additions & 3 deletions Helveticolor/ConfigSheet.xib
Expand Up @@ -62,6 +62,7 @@
<string key="NSFrame">{{217, 12}, {81, 32}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:9</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="100062243">
Expand Down Expand Up @@ -334,7 +335,7 @@
<object class="NSTextFieldCell" key="NSCell" id="498166074">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents">10 min</string>
<string key="NSContents">7 min</string>
<reference key="NSSupport" ref="26"/>
<string key="NSCellIdentifier">_NS:1505</string>
<reference key="NSControlView" ref="1029377599"/>
Expand All @@ -354,7 +355,7 @@
<object class="NSTextFieldCell" key="NSCell" id="154740310">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents">20 min</string>
<string key="NSContents">9 min</string>
<reference key="NSSupport" ref="26"/>
<string key="NSCellIdentifier">_NS:1505</string>
<reference key="NSControlView" ref="720202110"/>
Expand All @@ -377,7 +378,7 @@
<string key="NSContents"/>
<string key="NSCellIdentifier">_NS:9</string>
<reference key="NSControlView" ref="286039368"/>
<double key="NSMaxValue">10</double>
<double key="NSMaxValue">9</double>
<double key="NSMinValue">3</double>
<double key="NSValue">3</double>
<double key="NSAltIncValue">0.0</double>
Expand Down
4 changes: 2 additions & 2 deletions Helveticolor/Helveticolor-Info.plist
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>0.1.0 (1)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<string>0.1.0</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012 __MyCompanyName__. All rights reserved.</string>
<key>NSPrincipalClass</key>
Expand Down
36 changes: 28 additions & 8 deletions Helveticolor/HelveticolorView.m
Expand Up @@ -77,8 +77,8 @@ - (void)refreshPaletteListForType:(int) showPalettesType
NSError *error = nil;

NSData* data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
returningResponse:&response
error:&error];

NSXMLDocument *xmlDoc = [[[NSXMLDocument alloc] initWithData:data options:0 error:&error] autorelease];

Expand Down Expand Up @@ -122,6 +122,7 @@ - (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
// Register our default values
[defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kShowPalettesTop], SHOW_PALETTES_TYPE_DEFAULTS_KEY,
[NSNumber numberWithInt:3], PALETTE_CHANGE_INTERVAL_DEFAULTS_KEY,
nil]];

self.colors = [NSMutableArray array];
Expand Down Expand Up @@ -169,7 +170,17 @@ - (void)animateOneFrame
return;
}

if ((self.paletteLastChanged != nil) && ([self.paletteLastChanged timeIntervalSinceNow] <= ([[defaults objectForKey: PALETTE_CHANGE_INTERVAL_DEFAULTS_KEY] intValue] * -60))) {
int palleteChangeInterval = [[defaults objectForKey: PALETTE_CHANGE_INTERVAL_DEFAULTS_KEY] intValue];

if (paletteChangeInterval < 3) {
paletteChangeInterval = 3;
}

if (paletteChangeInterval > 9) {
paletteChangeInterval = 9;
}

if ((self.paletteLastChanged != nil) && ([self.paletteLastChanged timeIntervalSinceNow] <= (palleteChangeInterval * -60))) {

if ([[defaults objectForKey: SHOW_PALETTES_TYPE_DEFAULTS_KEY] intValue] == kShowPalettesRandom) {
[self refreshPaletteListForType:kShowPalettesRandom];
Expand Down Expand Up @@ -396,15 +407,24 @@ - (void) drawFrameForColor: (Color *)color withPaletteTitle: (NSString *)title
}

// draw primary text
int fontSize = (int)(rect.size.height * 0.25);
NSString *hexColorString = [[NSString stringWithString: @"#"] stringByAppendingString: color.hexValue];

int alphaFontSize = (int)(rect.size.height * 0.25);
int numericFontSize = (int)(rect.size.height * 0.255);

NSDictionary *mainTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSFont fontWithName:@"Helvetica Neue" size:fontSize], NSFontAttributeName,
[NSFont fontWithName:@"Helvetica Neue" size:numericFontSize], NSFontAttributeName,
textColor, NSForegroundColorAttributeName,
nil];

NSString *hexColorString = [[NSString stringWithString: @"#"] stringByAppendingString: color.hexValue];
NSAttributedString *mainAttributedText = [[[NSAttributedString alloc] initWithString: hexColorString attributes: mainTextAttributes] autorelease];
NSMutableAttributedString *mainAttributedText = [[[NSMutableAttributedString alloc] initWithString: hexColorString attributes: mainTextAttributes] autorelease];

for (int i = 0; i < [hexColorString length]; i++) {
if (([hexColorString characterAtIndex:i] >= 'A') || ([hexColorString characterAtIndex:i] >= 'F')) {
[mainAttributedText addAttribute:NSFontAttributeName value:[NSFont fontWithName:@"Helvetica Neue" size:alphaFontSize] range:NSMakeRange(i, 1)];
}
}


NSSize attrSize = [mainAttributedText size];
int xOffset = (rect.size.width / 2) - (attrSize.width / 2);
Expand All @@ -413,7 +433,7 @@ - (void) drawFrameForColor: (Color *)color withPaletteTitle: (NSString *)title
[mainAttributedText drawAtPoint:NSMakePoint(xOffset, yOffset)];

// draw secondary text
fontSize = (int)(rect.size.height * 0.04);
int fontSize = (int)(rect.size.height * 0.04);
NSDictionary *secondaryTextAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSFont fontWithName:@"Helvetica Neue" size:fontSize], NSFontAttributeName,
textColor, NSForegroundColorAttributeName,
Expand Down

0 comments on commit bf29988

Please sign in to comment.