Skip to content

Commit

Permalink
fix problem that textured buttons would still look like enabled even …
Browse files Browse the repository at this point in the history
…if disabled (black text)
  • Loading branch information
Autorelease Pool committed Oct 27, 2011
1 parent 7066fd3 commit 5ec3034
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion AppKit/NSButtonCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ -(void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)controlView {
// FIXME: use shadow in attributed string and implement shadow text drawing
const BOOL pressed=[self state] && ([self showsStateBy] & NSChangeBackgroundCellMask);
const CGFloat fgGray = (pressed) ? 0.98 : 0.0;
const CGFloat fgGrayDisabled = 0.5;
const CGFloat shadowGray = (pressed) ? 0.07 : 0.93;
const CGFloat shadowAlpha = ([self isHighlighted]) ? 0.15 : 0.25;
NSString *baseTitle = [NSString stringWithString:[title string]];
Expand All @@ -1060,7 +1061,10 @@ -(void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)controlView {
}

NSMutableDictionary *fgAttrs = [[shadowAttrs mutableCopy] autorelease];
[fgAttrs setObject:[NSColor colorWithDeviceRed:fgGray green:fgGray blue:fgGray alpha:1.0] forKey:NSForegroundColorAttributeName];
if ([self isEnabled])
[fgAttrs setObject:[NSColor colorWithDeviceRed:fgGray green:fgGray blue:fgGray alpha:1.0] forKey:NSForegroundColorAttributeName];
else
[fgAttrs setObject:[NSColor colorWithDeviceRed:fgGrayDisabled green:fgGrayDisabled blue:fgGrayDisabled alpha:1.0] forKey:NSForegroundColorAttributeName];
title = [[[NSAttributedString alloc] initWithString:baseTitle attributes:fgAttrs] autorelease];
}

Expand Down

0 comments on commit 5ec3034

Please sign in to comment.