Changeset 5740


Ignore:
Timestamp:
May 2, 2008, 1:08:23 PM (14 years ago)
Author:
livings124
Message:

generate the inspector tab button images dynamically when selected/deselected instead of storing them

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/BadgeView.m

    r5687 r5740  
    7171{
    7272    fQuitting = YES;
    73     [self display];
    7473}
    7574
  • trunk/macosx/InfoTabButtonCell.h

    r4423 r5740  
    2727@interface InfoTabButtonCell : NSButtonCell
    2828{
    29     NSImage * fIcon, * fRegularImage, * fSelectedImage;
     29    NSImage * fIcon;
    3030   
    3131    BOOL fSelected;
  • trunk/macosx/InfoTabButtonCell.m

    r4779 r5740  
    4444    [fIcon release];
    4545   
    46     [fRegularImage release];
    47     [fSelectedImage release];
    4846    [super dealloc];
    4947}
     
    5351    [fIcon release];
    5452    fIcon = [image retain];
    55    
    56     if (fRegularImage)
    57     {
    58         [fRegularImage release];
    59         fRegularImage = nil;
    60     }
    61     if (fSelectedImage)
    62     {
    63         [fSelectedImage release];
    64         fSelectedImage = nil;
    65     }
    6653   
    6754    [self setSelectedTab: fSelected];
     
    7360   
    7461    NSImage * tabImage;
    75     BOOL createImage = NO;
    7662    if (fSelected)
     63        tabImage = [NSColor currentControlTint] == NSGraphiteControlTint
     64                    ? [[NSImage imageNamed: @"InfoTabBackGraphite.png"] copy] : [[NSImage imageNamed: @"InfoTabBackBlue.png"] copy];
     65    else
     66        tabImage = [[NSImage imageNamed: @"InfoTabBack.png"] copy];
     67   
     68    if (fIcon)
    7769    {
    78         if (!fSelectedImage)
    79         {
    80             fSelectedImage = [NSColor currentControlTint] == NSGraphiteControlTint
    81                 ? [[NSImage imageNamed: @"InfoTabBackGraphite.png"] copy] : [[NSImage imageNamed: @"InfoTabBackBlue.png"] copy];
    82             createImage = YES;
    83         }
    84         tabImage = fSelectedImage;
    85     }
    86     else
    87     {
    88         if (!fRegularImage)
    89         {
    90             fRegularImage = [[NSImage imageNamed: @"InfoTabBack.png"] copy];
    91             createImage = YES;
    92         }
    93         tabImage = fRegularImage;
    94     }
    95    
    96     if (createImage)
    97     {
    98         if (fIcon)
    99         {
    100             NSSize iconSize = [fIcon size], tabSize = [tabImage size];
    101             NSPoint point = NSMakePoint(floorf((tabSize.width - iconSize.width) * 0.5),
    102                                         floorf((tabSize.height - iconSize.height) * 0.5));
    103            
    104             [tabImage lockFocus];
    105             [fIcon compositeToPoint: point operation: NSCompositeSourceOver];
    106             [tabImage unlockFocus];
    107         }
     70        NSSize iconSize = [fIcon size], tabSize = [tabImage size];
     71        NSPoint point = NSMakePoint(floorf((tabSize.width - iconSize.width) * 0.5),
     72                                    floorf((tabSize.height - iconSize.height) * 0.5));
     73       
     74        [tabImage lockFocus];
     75        [fIcon compositeToPoint: point operation: NSCompositeSourceOver];
     76        [tabImage unlockFocus];
    10877    }
    10978   
    11079    [self setImage: tabImage];
     80    [tabImage release];
    11181}
    11282
    11383- (void) updateControlTint: (NSNotification *) notification
    11484{
    115     [fSelectedImage release];
    116     fSelectedImage = nil;
    117    
    11885    if (fSelected)
    11986        [self setSelectedTab: YES];
Note: See TracChangeset for help on using the changeset viewer.