X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/6e879de483fcc0349bb3720d1eb8ae74dc6d3803..c25ae738dc14fa146f7cf5a3762abb90fb73faaf:/MenuTunesView.m diff --git a/MenuTunesView.m b/MenuTunesView.m index 05af9af..08e7ceb 100755 --- a/MenuTunesView.m +++ b/MenuTunesView.m @@ -1,5 +1,6 @@ #import "MenuTunesView.h" +extern NSColor* _NSGetThemePartColorPattern(int, int, int); @implementation MenuTunesView @@ -7,30 +8,41 @@ { if ( (self = [super initWithFrame:frame]) ) { - images = [[NSDictionary alloc] initWithObjectsAndKeys: - [NSImage imageNamed:@"menu"], @"normal", - [NSImage imageNamed:@"selected_image"], @"selected", - nil]; + image = [NSImage imageNamed:@"menu"]; + altImage = [NSImage imageNamed:@"selected_image"]; + mouseIsPressed = NO; } return self; } - (void)drawRect:(NSRect)rect { - NSImage *image - [curImage compositeToPoint:NSMakePoint(0, 0) operation:NSCompositeSourceOver]; + NSImage *icon; + NSColor *background; + + if ( mouseIsPressed ) { + icon = altImage; + background = _NSGetThemePartColorPattern(44, 2, 0); + } else { + icon = image; + background = [NSColor clearColor]; + } + [background set]; + NSRectFill(rect); + [icon compositeToPoint:NSMakePoint(((rect.size.width - [icon size].width) / 2), 0) + operation:NSCompositeSourceOver]; } - (void)mouseDown:(NSEvent *)event { - curImage = altImage; + mouseIsPressed = YES; [self setNeedsDisplay:YES]; [super mouseDown:event]; } - (void)mouseUp:(NSEvent *)event { - curImage = image; + mouseIsPressed = NO; [self setNeedsDisplay:YES]; [super mouseUp:event]; }