Changeset 11788


Ignore:
Timestamp:
Jan 30, 2011, 2:36:08 AM (11 years ago)
Author:
livings124
Message:

use the control color for the selected inspector button; small tweaks to the updated button bar's drawing code

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoTabButtonBack.h

    r11787 r11788  
    2727@interface InfoTabButtonBack : NSView
    2828{
     29    NSGradient * fGradient;
    2930}
    3031
  • trunk/macosx/InfoTabButtonBack.m

    r11787 r11788  
    2727@implementation InfoTabButtonBack
    2828
     29- (id) initWithFrame: (NSRect) rect
     30{
     31    if ((self = [super initWithFrame: rect]))
     32    {
     33        NSColor * lightColor = [NSColor colorWithCalibratedRed: 255.0/255.0 green: 255.0/255.0 blue: 255.0/255.0 alpha: 1.0];
     34        NSColor * darkColor = [NSColor colorWithCalibratedRed: 225.0/255.0 green: 225.0/255.0 blue: 225.0/255.0 alpha: 1.0];
     35        fGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
     36    }
     37    return self;
     38}
     39
     40- (void) dealloc
     41{
     42    [fGradient release];
     43    [super dealloc];
     44}
     45
    2946- (void) drawRect: (NSRect) rect
    3047{
    31     NSColor * lightColor = [NSColor colorWithCalibratedRed: 255.0/255.0 green: 255.0/255.0 blue: 255.0/255.0 alpha: 1.0];
    32     NSColor * darkColor = [NSColor colorWithCalibratedRed: 225.0/255.0 green: 225.0/255.0 blue: 225.0/255.0 alpha: 1.0];
    33     NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: darkColor endingColor: lightColor];
    34     [gradient drawInRect: rect angle: 90.0];
    35     [gradient release];
     48    NSInteger count = 0;
     49    NSRect gridRects[2];
     50    NSColor * colorRects[2];
    3651   
    37     [[NSColor grayColor] set];
    38     NSRectFill(NSMakeRect(0.0, 0.0, NSWidth(rect), 1.0));
    39     NSRectFill(NSMakeRect(0.0, NSHeight(rect) - 1.0, NSWidth(rect), 1.0));
     52    NSRect lineBorderRect = NSMakeRect(NSMinX(rect), NSHeight([self bounds]) - 1.0, NSWidth(rect), 1.0);
     53    if (NSIntersectsRect(lineBorderRect, rect))
     54    {
     55        gridRects[count] = lineBorderRect;
     56        colorRects[count] = [NSColor grayColor];
     57        ++count;
     58       
     59        rect.size.height -= 1.0;
     60    }
     61   
     62    lineBorderRect.origin.y = 0.0;
     63    if (NSIntersectsRect(lineBorderRect, rect))
     64    {
     65        gridRects[count] = lineBorderRect;
     66        colorRects[count] = [NSColor grayColor];
     67        ++count;
     68       
     69        rect.origin.y += 1.0;
     70        rect.size.height -= 1.0;
     71    }
     72   
     73    NSRectFillListWithColors(gridRects, colorRects, count);
     74   
     75    [fGradient drawInRect: rect angle: 270.0];
    4076}
    4177
  • trunk/macosx/InfoTabButtonCell.m

    r11787 r11788  
    3030{
    3131    [(NSMatrix *)[self controlView] setToolTip: [self title] forCell: self];
     32   
     33    NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
     34    [nc addObserver: self selector: @selector(updateControlTint:)
     35        name: NSControlTintDidChangeNotification object: NSApp];
    3236       
    3337    fSelected = NO;
     
    4044- (void) dealloc
    4145{
     46    [[NSNotificationCenter defaultCenter] removeObserver: self];
     47   
    4248    [fIcon release];
    4349    [super dealloc];
     
    5056    NSInteger row, col;
    5157    [(NSMatrix *)[self controlView] getRow: &row column: &col ofCell: self];
    52     const NSSize tabSize = [(NSMatrix *)[self controlView] cellFrameAtRow: row column: col].size;
    53     const NSRect tabRect = NSMakeRect(0.0, 0.0, tabSize.width, tabSize.height);
     58    NSRect tabRect = [(NSMatrix *)[self controlView] cellFrameAtRow: row column: col];
     59    tabRect.origin.x = 0.0;
     60    tabRect.origin.y = 0.0;
    5461   
    55     NSImage * tabImage = [[NSImage alloc] initWithSize: tabSize];
     62    NSImage * tabImage = [[NSImage alloc] initWithSize: tabRect.size];
    5663       
    5764    [tabImage lockFocus];
    5865   
    59     if (!fSelected)
     66    if (fSelected)
    6067    {
    61         NSColor * lightColor = [NSColor colorWithCalibratedRed: 255.0/255.0 green: 255.0/255.0 blue: 255.0/255.0 alpha: 1.0];
    62         NSColor * darkColor = [NSColor colorWithCalibratedRed: 225.0/255.0 green: 225.0/255.0 blue: 225.0/255.0 alpha: 1.0];
    63         NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: darkColor endingColor: lightColor];
    64         [gradient drawInRect: tabRect angle: 90.0];
     68        NSColor * lightColor = [NSColor colorForControlTint: [NSColor currentControlTint]];
     69        NSColor * darkColor = [lightColor blendedColorWithFraction: 0.2 ofColor: [NSColor blackColor]];
     70        NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
     71        [gradient drawInRect: tabRect angle: 270.0];
    6572        [gradient release];
    6673    }
    6774    else
    6875    {
    69         NSColor * lightColor = [NSColor colorWithCalibratedRed: 160.0/255.0 green: 160.0/255.0 blue: 160.0/255.0 alpha: 1.0];
    70         NSColor * darkColor = [NSColor colorWithCalibratedRed: 150.0/255.0 green: 150.0/255.0 blue: 150.0/255.0 alpha: 1.0];
    71         NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: darkColor endingColor: lightColor];
    72         [gradient drawInRect: tabRect angle: 90.0];
     76        NSColor * lightColor = [NSColor colorWithCalibratedRed: 255.0/255.0 green: 255.0/255.0 blue: 255.0/255.0 alpha: 1.0];
     77        NSColor * darkColor = [NSColor colorWithCalibratedRed: 225.0/255.0 green: 225.0/255.0 blue: 225.0/255.0 alpha: 1.0];
     78        NSGradient * gradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
     79        [gradient drawInRect: tabRect angle: 270.0];
    7380        [gradient release];
    7481    }
     
    8390        const NSSize iconSize = [fIcon size];
    8491       
    85         const NSRect iconRect = NSMakeRect(floor((tabSize.width - iconSize.width) * 0.5),
    86                                             floor((tabSize.height - iconSize.height) * 0.5),
     92        const NSRect iconRect = NSMakeRect(floor((NSWidth(tabRect) - iconSize.width) * 0.5),
     93                                            floor((NSHeight(tabRect) - iconSize.height) * 0.5),
    8794                                            iconSize.width, iconSize.height);
    8895       
     
    95102}
    96103
     104- (void) updateControlTint: (NSNotification *) notification
     105{
     106    if (fSelected)
     107        [self setSelectedTab: YES];
     108}
     109
    97110@end
Note: See TracChangeset for help on using the changeset viewer.