1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-27 01:57:52 +00:00

different style for filter bar buttons

This commit is contained in:
Mitchell Livingston 2006-07-19 11:30:05 +00:00
parent 696f185ed4
commit 1da4599dfe

View file

@ -116,56 +116,80 @@
NSFont * boldFont = [[NSFontManager sharedFontManager] convertFont: NSFont * boldFont = [[NSFontManager sharedFontManager] convertFont:
[NSFont fontWithName: @"Lucida Grande" size: 12.0] toHaveTrait: NSBoldFontMask]; [NSFont fontWithName: @"Lucida Grande" size: 12.0] toHaveTrait: NSBoldFontMask];
NSSize shadowOffset = NSMakeSize(0.0, -1.0);
NSShadow * shadowNormal = [NSShadow alloc];
[shadowNormal setShadowOffset: shadowOffset];
[shadowNormal setShadowBlurRadius: 1.0];
[shadowNormal setShadowColor: [NSColor colorWithDeviceWhite: 1.0 alpha: 0.4]];
NSShadow * shadowNormalDim = [NSShadow alloc];
[shadowNormalDim setShadowOffset: shadowOffset];
[shadowNormalDim setShadowBlurRadius: 1.0];
[shadowNormalDim setShadowColor: [NSColor colorWithDeviceWhite: 1.0 alpha: 0.2]];
NSShadow * shadowHighlighted = [NSShadow alloc];
[shadowHighlighted setShadowOffset: shadowOffset];
[shadowHighlighted setShadowBlurRadius: 1.0];
[shadowHighlighted setShadowColor: [NSColor colorWithDeviceWhite: 0.0 alpha: 0.4]];
NSDictionary * normalAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: NSDictionary * normalAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSColor controlTextColor], NSForegroundColorAttributeName, [NSColor colorWithCalibratedRed: 0.259 green: 0.259 blue: 0.259 alpha: 1.0],
[NSFont fontWithName: @"Lucida Grande" size: 12.0], NSFontAttributeName, nil], NSForegroundColorAttributeName,
boldFont, NSFontAttributeName,
shadowNormal, NSShadowAttributeName, nil],
* normalDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: * normalDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSColor disabledControlTextColor], NSForegroundColorAttributeName, [NSColor disabledControlTextColor], NSForegroundColorAttributeName,
[NSFont fontWithName: @"Lucida Grande" size: 12.0], NSFontAttributeName, nil], boldFont, NSFontAttributeName,
shadowNormalDim, NSShadowAttributeName, nil],
* highlightedAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: * highlightedAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSColor whiteColor], NSForegroundColorAttributeName, [NSColor whiteColor], NSForegroundColorAttributeName,
boldFont, NSFontAttributeName, nil], boldFont, NSFontAttributeName,
shadowHighlighted, NSShadowAttributeName, nil],
* highlightedDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys: * highlightedDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSColor colorWithCalibratedRed: 0.9 green: 0.9 blue: 0.9 alpha: 1.0], NSForegroundColorAttributeName, [NSColor colorWithCalibratedRed: 0.9 green: 0.9 blue: 0.9 alpha: 1.0], NSForegroundColorAttributeName,
boldFont, NSFontAttributeName, nil]; boldFont, NSFontAttributeName,
shadowHighlighted, NSShadowAttributeName, nil];
NSSize textSizeNormal = [text sizeWithAttributes: normalAttributes], NSSize textSizeNormal = [text sizeWithAttributes: normalAttributes],
textSizeBold = [text sizeWithAttributes: highlightedAttributes], textSizeBold = [text sizeWithAttributes: highlightedAttributes],
buttonSize = [self frame].size; buttonSize = [self frame].size;
NSRect textRectNormal = NSMakeRect((buttonSize.width - textSizeNormal.width) * 0.5, NSRect textRect = NSMakeRect((buttonSize.width - textSizeNormal.width) * 0.5,
(buttonSize.height - textSizeNormal.height) * 0.5 + 1.5, textSizeNormal.width, textSizeNormal.height), (buttonSize.height - textSizeNormal.height) * 0.5 + 1.5, textSizeNormal.width, textSizeNormal.height);
textRectBold = NSMakeRect((buttonSize.width - textSizeBold.width) * 0.5,
(buttonSize.height - textSizeBold.height) * 0.5 + 1.5, textSizeBold.width, textSizeBold.height); [shadowNormal release];
[shadowNormalDim release];
[shadowHighlighted release];
//normal button //normal button
[fButtonNormal lockFocus]; [fButtonNormal lockFocus];
[text drawInRect: textRectNormal withAttributes: normalAttributes]; [text drawInRect: textRect withAttributes: normalAttributes];
[fButtonNormal unlockFocus]; [fButtonNormal unlockFocus];
//normal and dim button //normal and dim button
[fButtonNormalDim lockFocus]; [fButtonNormalDim lockFocus];
[text drawInRect: textRectNormal withAttributes: normalDimAttributes]; [text drawInRect: textRect withAttributes: normalDimAttributes];
[fButtonNormalDim unlockFocus]; [fButtonNormalDim unlockFocus];
//rolled over button //rolled over button
[fButtonOver lockFocus]; [fButtonOver lockFocus];
[text drawInRect: textRectBold withAttributes: highlightedAttributes]; [text drawInRect: textRect withAttributes: highlightedAttributes];
[fButtonOver unlockFocus]; [fButtonOver unlockFocus];
//pressed button //pressed button
[fButtonPressed lockFocus]; [fButtonPressed lockFocus];
[text drawInRect: textRectBold withAttributes: highlightedAttributes]; [text drawInRect: textRect withAttributes: highlightedAttributes];
[fButtonPressed unlockFocus]; [fButtonPressed unlockFocus];
//selected button //selected button
[fButtonSelected lockFocus]; [fButtonSelected lockFocus];
[text drawInRect: textRectBold withAttributes: highlightedAttributes]; [text drawInRect: textRect withAttributes: highlightedAttributes];
[fButtonSelected unlockFocus]; [fButtonSelected unlockFocus];
//selected and dim button //selected and dim button
[fButtonSelectedDim lockFocus]; [fButtonSelectedDim lockFocus];
[text drawInRect: textRectBold withAttributes: highlightedDimAttributes]; [text drawInRect: textRect withAttributes: highlightedDimAttributes];
[fButtonSelectedDim unlockFocus]; [fButtonSelectedDim unlockFocus];
[self setImage: fButtonNormal]; [self setImage: fButtonNormal];
@ -175,7 +199,7 @@
[highlightedAttributes release]; [highlightedAttributes release];
[highlightedDimAttributes release]; [highlightedDimAttributes release];
//NSLog(@"%@ %f", text, textSizeBold.width); //NSLog(@"%@ %f", text, textRect.width);
} }
- (void) mouseEntered: (NSEvent *) event - (void) mouseEntered: (NSEvent *) event