aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AppKit/GTMTheme.h18
-rw-r--r--AppKit/GTMTheme.m22
-rw-r--r--AppKit/GTMThemeTest.m6
3 files changed, 37 insertions, 9 deletions
diff --git a/AppKit/GTMTheme.h b/AppKit/GTMTheme.h
index 52d5d13..8eb8713 100644
--- a/AppKit/GTMTheme.h
+++ b/AppKit/GTMTheme.h
@@ -77,11 +77,21 @@ typedef NSUInteger GTMThemeState;
- (NSColor *)backgroundPatternColorForStyle:(GTMThemeStyle)style
state:(GTMThemeState)state;
-// NSGradient for specific usage, active indicates whether the window is key
-- (NSGradient *)gradientForStyle:(GTMThemeStyle)style state:(GTMThemeState)state;
+// NSGradient for specific usage
+- (NSGradient *)gradientForStyle:(GTMThemeStyle)style
+ state:(GTMThemeState)state;
-// Outline color for stroke, active indicates whether the window is key
-- (NSColor *)strokeColorForStyle:(GTMThemeStyle)style state:(GTMThemeState)state;
+// Outline color for stroke
+- (NSColor *)strokeColorForStyle:(GTMThemeStyle)style
+ state:(GTMThemeState)state;
+
+// Text color
+- (NSColor *)textColorForStyle:(GTMThemeStyle)style
+ state:(GTMThemeState)state;
+
+// Base background color (a plain (non pattern/gradient) NSColor)
+- (NSColor *)backgroundColorForStyle:(GTMThemeStyle)style
+ state:(GTMThemeState)state;
// Indicates whether luminance is dark or light
- (BOOL)styleIsDark:(GTMThemeStyle)style state:(GTMThemeState)state;
diff --git a/AppKit/GTMTheme.m b/AppKit/GTMTheme.m
index 45d92ff..5940b1c 100644
--- a/AppKit/GTMTheme.m
+++ b/AppKit/GTMTheme.m
@@ -31,7 +31,7 @@ NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor";
GTMTheme *theme = nil;
if ([[self delegate] conformsToProtocol:
@protocol(GTMThemeDelegate)]) {
- theme = [[self delegate] gtm_themeForWindow:self];
+ theme = [(id <GTMThemeDelegate>)[self delegate] gtm_themeForWindow:self];
} else if ([[self windowController] conformsToProtocol:
@protocol(GTMThemeDelegate)]) {
theme = [[self windowController] gtm_themeForWindow:self];
@@ -162,7 +162,7 @@ NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor";
- (NSColor *)backgroundColor {
// For nil, we return a color that works with a normal textured window
if (!backgroundColor_)
- return [NSColor colorWithCalibratedWhite:0.667 alpha:1.0];
+ return [NSColor colorWithCalibratedWhite:0.5 alpha:1.0];
return backgroundColor_;
}
@@ -258,7 +258,7 @@ NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor";
if (color) return color;
NSImage *image = [self backgroundImageForStyle:style state:state];
- if (!image) {
+ if (!image && backgroundColor_) {
NSGradient *gradient = [self gradientForStyle:style state:state];
if (gradient) {
// create a gradient image for the background
@@ -301,7 +301,8 @@ NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor";
[image addRepresentation:rep];
}
}
- color = [NSColor colorWithPatternImage:image];
+ if (image)
+ color = [NSColor colorWithPatternImage:image];
[self cacheValue:color forSelector:_cmd style:style state:state];
return color;
}
@@ -466,6 +467,19 @@ NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor";
[self cacheValue:color forSelector:_cmd style:style state:state];
return color;
}
+
+- (NSColor *)backgroundColorForStyle:(GTMThemeStyle)style
+ state:(GTMThemeState)state {
+ NSColor *color = [self valueForSelector:_cmd style:style state:state];
+ if (color) return color;
+
+ // TODO(alcor): calculate this based off base background color
+ // Generally this will be set by a theme provider
+ color = [self backgroundColor];
+
+ [self cacheValue:color forSelector:_cmd style:style state:state];
+ return color;
+}
@end
#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
diff --git a/AppKit/GTMThemeTest.m b/AppKit/GTMThemeTest.m
index e58e95f..0f5c996 100644
--- a/AppKit/GTMThemeTest.m
+++ b/AppKit/GTMThemeTest.m
@@ -33,7 +33,7 @@
// When there are no values, use window default colors
STAssertEqualObjects([theme backgroundColor],
- [NSColor colorWithCalibratedWhite:0.667 alpha:1.0], nil);
+ [NSColor colorWithCalibratedWhite:0.5 alpha:1.0], nil);
STAssertNil([theme backgroundImageForStyle:GTMThemeStyleWindow
state:GTMThemeStateActiveWindow],
nil);
@@ -44,6 +44,10 @@
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:colorData forKey:kGTMThemeBackgroundColorKey];
+ STAssertNotNil([theme textColorForStyle:GTMThemeStyleToolBar
+ state:GTMThemeStateActiveWindow], nil);
+ STAssertNotNil([theme backgroundColorForStyle:GTMThemeStyleToolBar
+ state:GTMThemeStateActiveWindow], nil);
STAssertNotNil([theme backgroundPatternColorForStyle:GTMThemeStyleToolBar
state:GTMThemeStateActiveWindow], nil);
STAssertNotNil([theme strokeColorForStyle:GTMThemeStyleToolBar