Changeset 686


Ignore:
Timestamp:
Jul 23, 2006, 10:23:59 PM (15 years ago)
Author:
livings124
Message:

Filter buttons now actually are buttons, meaning their behavior matches more to Mail.app's

Location:
trunk/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/BarButton.h

    r640 r686  
    2525#import <Cocoa/Cocoa.h>
    2626
    27 @interface BarButton : NSImageView
     27@interface BarButton : NSButton
    2828{
    2929    NSImage * fButtonNormal, * fButtonNormalDim, * fButtonOver,
     
    3434}
    3535
    36 - (void) setText: (NSString *) text;
    3736- (void) setEnabled: (BOOL) enable;
    3837
  • trunk/macosx/BarButton.m

    r668 r686  
    2525#import "BarButton.h"
    2626
     27@interface BarButton (Private)
     28
     29- (void) setText;
     30
     31@end
     32
    2733@implementation BarButton
    2834
     
    94100        fButtonSelectedDim = [fButtonSelected copy];
    95101       
     102        [self setText];
     103       
     104        [self setImage: fButtonNormal];
     105        [self setAlternateImage: fButtonPressed];
     106       
    96107        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(resetBounds:)
    97108                    name: NSViewBoundsDidChangeNotification object: nil];
    98109        }
    99110        return self;
     111}
     112
     113//call only once to avoid overlapping text
     114- (void) setText
     115{
     116    NSString * text = [self title];
     117
     118    NSFont * boldFont = [[NSFontManager sharedFontManager] convertFont:
     119                            [NSFont fontWithName: @"Lucida Grande" size: 12.0] toHaveTrait: NSBoldFontMask];
     120   
     121    NSSize shadowOffset = NSMakeSize(0.0, -1.0);
     122   
     123    NSShadow * shadowNormal = [NSShadow alloc];
     124    [shadowNormal setShadowOffset: shadowOffset];
     125    [shadowNormal setShadowBlurRadius: 1.0];
     126    [shadowNormal setShadowColor: [NSColor colorWithDeviceWhite: 1.0 alpha: 0.4]];
     127
     128    NSShadow * shadowNormalDim = [NSShadow alloc];
     129    [shadowNormalDim setShadowOffset: shadowOffset];
     130    [shadowNormalDim setShadowBlurRadius: 1.0];
     131    [shadowNormalDim setShadowColor: [NSColor colorWithDeviceWhite: 1.0 alpha: 0.2]];
     132
     133    NSShadow * shadowHighlighted = [NSShadow alloc];
     134    [shadowHighlighted setShadowOffset: shadowOffset];
     135    [shadowHighlighted setShadowBlurRadius: 1.0];
     136    [shadowHighlighted setShadowColor: [NSColor colorWithDeviceWhite: 0.0 alpha: 0.4]];
     137   
     138    NSDictionary * normalAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
     139                [NSColor colorWithCalibratedRed: 0.259 green: 0.259 blue: 0.259 alpha: 1.0],
     140                NSForegroundColorAttributeName,
     141                boldFont, NSFontAttributeName,
     142                shadowNormal, NSShadowAttributeName, nil],
     143        * normalDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
     144                [NSColor disabledControlTextColor], NSForegroundColorAttributeName,
     145                boldFont, NSFontAttributeName,
     146                shadowNormalDim, NSShadowAttributeName, nil],
     147        * highlightedAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
     148                [NSColor whiteColor], NSForegroundColorAttributeName,
     149                boldFont, NSFontAttributeName,
     150                shadowHighlighted, NSShadowAttributeName, nil],
     151        * highlightedDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
     152                [NSColor colorWithCalibratedRed: 0.9 green: 0.9 blue: 0.9 alpha: 1.0], NSForegroundColorAttributeName,
     153                boldFont, NSFontAttributeName,
     154                shadowHighlighted, NSShadowAttributeName, nil];
     155   
     156    NSSize textSizeNormal = [text sizeWithAttributes: normalAttributes],
     157            textSizeBold = [text sizeWithAttributes: highlightedAttributes],
     158            buttonSize = [self frame].size;
     159   
     160    NSRect textRect = NSMakeRect((buttonSize.width - textSizeNormal.width) * 0.5,
     161            (buttonSize.height - textSizeNormal.height) * 0.5 + 1.5, textSizeNormal.width, textSizeNormal.height);
     162   
     163    [shadowNormal release];
     164    [shadowNormalDim release];
     165    [shadowHighlighted release];
     166   
     167    //normal button
     168    [fButtonNormal lockFocus];
     169    [text drawInRect: textRect withAttributes: normalAttributes];
     170    [fButtonNormal unlockFocus];
     171   
     172    //normal and dim button
     173    [fButtonNormalDim lockFocus];
     174    [text drawInRect: textRect withAttributes: normalDimAttributes];
     175    [fButtonNormalDim unlockFocus];
     176   
     177    //rolled over button
     178    [fButtonOver lockFocus];
     179    [text drawInRect: textRect withAttributes: highlightedAttributes];
     180    [fButtonOver unlockFocus];
     181   
     182    //pressed button
     183    [fButtonPressed lockFocus];
     184    [text drawInRect: textRect withAttributes: highlightedAttributes];
     185    [fButtonPressed unlockFocus];
     186   
     187    //selected button
     188    [fButtonSelected lockFocus];
     189    [text drawInRect: textRect withAttributes: highlightedAttributes];
     190    [fButtonSelected unlockFocus];
     191   
     192    //selected and dim button
     193    [fButtonSelectedDim lockFocus];
     194    [text drawInRect: textRect withAttributes: highlightedDimAttributes];
     195    [fButtonSelectedDim unlockFocus];
     196   
     197    [normalAttributes release];
     198    [normalDimAttributes release];
     199    [highlightedAttributes release];
     200    [highlightedDimAttributes release];
    100201}
    101202
     
    111212}
    112213
    113 //call only once to avoid overlapping text
    114 - (void) setText: (NSString *) text
    115 {
    116     NSFont * boldFont = [[NSFontManager sharedFontManager] convertFont:
    117                             [NSFont fontWithName: @"Lucida Grande" size: 12.0] toHaveTrait: NSBoldFontMask];
    118    
    119     NSSize shadowOffset = NSMakeSize(0.0, -1.0);
    120    
    121     NSShadow * shadowNormal = [NSShadow alloc];
    122     [shadowNormal setShadowOffset: shadowOffset];
    123     [shadowNormal setShadowBlurRadius: 1.0];
    124     [shadowNormal setShadowColor: [NSColor colorWithDeviceWhite: 1.0 alpha: 0.4]];
    125 
    126     NSShadow * shadowNormalDim = [NSShadow alloc];
    127     [shadowNormalDim setShadowOffset: shadowOffset];
    128     [shadowNormalDim setShadowBlurRadius: 1.0];
    129     [shadowNormalDim setShadowColor: [NSColor colorWithDeviceWhite: 1.0 alpha: 0.2]];
    130 
    131     NSShadow * shadowHighlighted = [NSShadow alloc];
    132     [shadowHighlighted setShadowOffset: shadowOffset];
    133     [shadowHighlighted setShadowBlurRadius: 1.0];
    134     [shadowHighlighted setShadowColor: [NSColor colorWithDeviceWhite: 0.0 alpha: 0.4]];
    135    
    136     NSDictionary * normalAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
    137                 [NSColor colorWithCalibratedRed: 0.259 green: 0.259 blue: 0.259 alpha: 1.0],
    138                 NSForegroundColorAttributeName,
    139                 boldFont, NSFontAttributeName,
    140                 shadowNormal, NSShadowAttributeName, nil],
    141         * normalDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
    142                 [NSColor disabledControlTextColor], NSForegroundColorAttributeName,
    143                 boldFont, NSFontAttributeName,
    144                 shadowNormalDim, NSShadowAttributeName, nil],
    145         * highlightedAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
    146                 [NSColor whiteColor], NSForegroundColorAttributeName,
    147                 boldFont, NSFontAttributeName,
    148                 shadowHighlighted, NSShadowAttributeName, nil],
    149         * highlightedDimAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
    150                 [NSColor colorWithCalibratedRed: 0.9 green: 0.9 blue: 0.9 alpha: 1.0], NSForegroundColorAttributeName,
    151                 boldFont, NSFontAttributeName,
    152                 shadowHighlighted, NSShadowAttributeName, nil];
    153    
    154     NSSize textSizeNormal = [text sizeWithAttributes: normalAttributes],
    155             textSizeBold = [text sizeWithAttributes: highlightedAttributes],
    156             buttonSize = [self frame].size;
    157    
    158     NSRect textRect = NSMakeRect((buttonSize.width - textSizeNormal.width) * 0.5,
    159             (buttonSize.height - textSizeNormal.height) * 0.5 + 1.5, textSizeNormal.width, textSizeNormal.height);
    160    
    161     [shadowNormal release];
    162     [shadowNormalDim release];
    163     [shadowHighlighted release];
    164    
    165     //normal button
    166     [fButtonNormal lockFocus];
    167     [text drawInRect: textRect withAttributes: normalAttributes];
    168     [fButtonNormal unlockFocus];
    169    
    170     //normal and dim button
    171     [fButtonNormalDim lockFocus];
    172     [text drawInRect: textRect withAttributes: normalDimAttributes];
    173     [fButtonNormalDim unlockFocus];
    174    
    175     //rolled over button
    176     [fButtonOver lockFocus];
    177     [text drawInRect: textRect withAttributes: highlightedAttributes];
    178     [fButtonOver unlockFocus];
    179    
    180     //pressed button
    181     [fButtonPressed lockFocus];
    182     [text drawInRect: textRect withAttributes: highlightedAttributes];
    183     [fButtonPressed unlockFocus];
    184    
    185     //selected button
    186     [fButtonSelected lockFocus];
    187     [text drawInRect: textRect withAttributes: highlightedAttributes];
    188     [fButtonSelected unlockFocus];
    189    
    190     //selected and dim button
    191     [fButtonSelectedDim lockFocus];
    192     [text drawInRect: textRect withAttributes: highlightedDimAttributes];
    193     [fButtonSelectedDim unlockFocus];
    194    
    195     [self setImage: fButtonNormal];
    196    
    197     [normalAttributes release];
    198     [normalDimAttributes release];
    199     [highlightedAttributes release];
    200     [highlightedDimAttributes release];
    201 }
    202 
    203214- (void) mouseEntered: (NSEvent *) event
    204215{
     
    217228}
    218229
    219 - (void) mouseDown: (NSEvent *) event
     230/*- (void) mouseDown: (NSEvent *) event
    220231{
    221232    [self setImage: fButtonPressed];
     
    229240   
    230241    [self setImage: fEnabled ? fButtonSelected : fButtonOver];
    231 }
     242}*/
    232243
    233244- (void) setEnabled: (BOOL) enable
  • trunk/macosx/Controller.m

    r684 r686  
    249249    //set filter
    250250    fFilterType = [[fDefaults stringForKey: @"Filter"] retain];
    251 
    252     //button width should be 9 pixels surrounding text length
    253     [fNoFilterButton setText: @"All"]; //16.64
    254     [fDownloadFilterButton setText: @"Downloading"]; //81.69
    255     [fSeedFilterButton setText: @"Seeding"]; //48.57
    256     [fPauseFilterButton setText: @"Paused"]; //44.06
    257251
    258252    BarButton * currentFilterButton;
  • trunk/macosx/English.lproj/MainMenu.nib/classes.nib

    r652 r686  
    11{
    22    IBClasses = (
    3         {CLASS = BarButton; LANGUAGE = ObjC; SUPERCLASS = NSImageView; },
     3        {CLASS = BarButton; LANGUAGE = ObjC; SUPERCLASS = NSButton; },
    44        {
    55            ACTIONS = {
  • trunk/macosx/English.lproj/MainMenu.nib/info.nib

    r671 r686  
    1212                <string>366 546 420 63 0 0 1152 842 </string>
    1313                <key>1603</key>
    14                 <string>360 371 477 67 0 0 1152 842 </string>
     14                <string>337 544 477 67 0 0 1152 842 </string>
    1515                <key>29</key>
    1616                <string>9 780 451 44 0 0 1152 842 </string>
     
    3232        <key>IBOpenObjects</key>
    3333        <array>
    34                 <integer>1480</integer>
     34                <integer>1603</integer>
    3535                <integer>29</integer>
    3636                <integer>21</integer>
  • trunk/macosx/InfoWindowController.m

    r678 r686  
    423423    unsigned int i;
    424424    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    425         [[NSWorkspace sharedWorkspace] selectFile: [fFiles objectAtIndex: i]
    426             inFileViewerRootedAtPath: nil];
     425        [[NSWorkspace sharedWorkspace] selectFile: [fFiles objectAtIndex: i] inFileViewerRootedAtPath: nil];
    427426}
    428427
Note: See TracChangeset for help on using the changeset viewer.