diff options
author | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-10-07 18:15:23 +0000 |
---|---|---|
committer | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-10-07 18:15:23 +0000 |
commit | 5943e22b5e6a9ffca98f11a1a85ca7e2bbe7f592 (patch) | |
tree | 464cfcad3fcc635eb307faa1f5407a519711f0eb /AppKit | |
parent | c5d1cb4c430f0ed96355c5edf1265c57e7d5e562 (diff) |
[Author: dmaclach]
Add background phase to GTMTheme.
R=thomasvl
DELTA=49 (47 added, 0 deleted, 2 changed)
Diffstat (limited to 'AppKit')
-rw-r--r-- | AppKit/GTMTheme.h | 15 | ||||
-rw-r--r-- | AppKit/GTMTheme.m | 16 | ||||
-rw-r--r-- | AppKit/GTMThemeTest.m | 22 |
3 files changed, 50 insertions, 3 deletions
diff --git a/AppKit/GTMTheme.h b/AppKit/GTMTheme.h index 8eb8713..787d1f1 100644 --- a/AppKit/GTMTheme.h +++ b/AppKit/GTMTheme.h @@ -39,6 +39,7 @@ enum { typedef NSUInteger GTMThemeStyle; enum { + GTMThemeStateInactiveWindow = 0, GTMThemeStateActiveWindow = 1 << 0 }; typedef NSUInteger GTMThemeState; @@ -49,7 +50,8 @@ typedef NSUInteger GTMThemeState; @interface GTMTheme : NSObject { @private NSColor *backgroundColor_; // bound to user defaults - NSImage *backgroundImage_; // bound to user defaults + NSImage *backgroundImage_; // bound to user defaults + NSPoint backgroundImagePhase_; // bound to user defaults NSMutableDictionary *values_; // cached values } @@ -66,9 +68,18 @@ typedef NSUInteger GTMThemeState; // sets the base theme color - (void)setBackgroundColor:(NSColor *)value; -// base background color +// base background image - (NSImage *)backgroundImage; +// set base background image +- (void)setBackgroundImage:(NSImage *)value; + +// the phase of the background image +- (NSPoint)backgroundImagePhase; + +// set the phase of the background image +- (void)setBackgroundImagePhase:(NSPoint)phase; + // NSImage pattern background - (NSImage *)backgroundImageForStyle:(GTMThemeStyle)style state:(GTMThemeState)state; diff --git a/AppKit/GTMTheme.m b/AppKit/GTMTheme.m index 5940b1c..7162916 100644 --- a/AppKit/GTMTheme.m +++ b/AppKit/GTMTheme.m @@ -88,6 +88,11 @@ NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor"; NSUnarchiveFromDataTransformerName, NSValueTransformerNameBindingOption, nil]]; + + [self bind:@"backgroundImagePhase" + toObject:controller + withKeyPath:@"values.GTMThemeBackgroundImagePhase" + options:nil]; } - (id)init { @@ -101,12 +106,14 @@ NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor"; - (void)finalize { [self unbind:@"backgroundColor"]; [self unbind:@"backgroundImage"]; + [self unbind:@"backgroundImagePhase"]; [super finalize]; } - (void)dealloc { [self unbind:@"backgroundColor"]; [self unbind:@"backgroundImage"]; + [self unbind:@"backgroundImagePhase"]; [values_ release]; [super dealloc]; } @@ -178,6 +185,15 @@ NSString *const kGTMThemeBackgroundColorKey = @"GTMThemeBackgroundColor"; return backgroundImage_; } +- (NSPoint)backgroundImagePhase { + return backgroundImagePhase_; +} + +- (void)setBackgroundImagePhase:(NSPoint)phase { + backgroundImagePhase_ = phase; + [self sendChangeNotification]; +} + - (NSImage *)backgroundImageForStyle:(GTMThemeStyle)style state:(GTMThemeState)state { id value = [self valueForSelector:_cmd style:style state:state]; diff --git a/AppKit/GTMThemeTest.m b/AppKit/GTMThemeTest.m index 0f5c996..ce1b6ad 100644 --- a/AppKit/GTMThemeTest.m +++ b/AppKit/GTMThemeTest.m @@ -23,7 +23,9 @@ #import "GTMSenTestCase.h" #import "GTMTheme.h" -@interface GTMThemeTest : GTMTestCase +@interface GTMThemeTest : GTMTestCase { + @private + BOOL themeNotificationCalled_; @end @implementation GTMThemeTest @@ -67,6 +69,24 @@ @"GTMThemeBackgroundColor"]; } +- (void)testPhase { + GTMTheme *theme = [GTMTheme defaultTheme]; + STAssertEquals([theme backgroundImagePhase], NSZeroPoint, nil); + + NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + [nc addObserver:self + selector:@selector(themeDidChangeNotification:) + name:kGTMThemeDidChangeNotification + object:theme]; + themeNotificationCalled_ = NO; + NSPoint newPhase = NSMakePoint(20, 30); + [theme setBackgroundImagePhase:newPhase]; + STAssertTrue(themeNotificationCalled_, nil); + themeNotificationCalled_ = NO; + STAssertEquals([theme backgroundImagePhase], newPhase, nil); + [nc removeObserver:self name:kGTMThemeDidChangeNotification object:theme]; +} + @end #endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 |