Changeset 7754


Ignore:
Timestamp:
Jan 19, 2009, 10:08:31 PM (12 years ago)
Author:
livings124
Message:

(trunk) filter button shrinking will now scale proportionally based on button size - a big improvement for localizations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.5x/macosx/Controller.m

    r7666 r7754  
    40514051   
    40524052    //replace all buttons
     4053    [fNoFilterButton sizeToFit];
    40534054    [fActiveFilterButton sizeToFit];
    40544055    [fDownloadFilterButton sizeToFit];
     
    40564057    [fPauseFilterButton sizeToFit];
    40574058   
     4059    NSRect allRect = [fNoFilterButton frame];
     4060   
    40584061    NSRect activeRect = [fActiveFilterButton frame];
     4062    activeRect.origin.x = NSMaxX(allRect) + 1.0;
    40594063   
    40604064    NSRect downloadRect = [fDownloadFilterButton frame];
     
    40834087        searchFrame.size.width = SEARCH_FILTER_MIN_WIDTH;
    40844088       
    4085         //resize the buttons so they don't overlay
    4086         NSInteger difference = (NSMaxX(pauseRect) + 5.0) - searchFrame.origin.x - 1; //subtract 1, since 0 will be counted
    4087        
    4088         //decrease downloading by 8, seeding by 1, paused by 1, active by 1, repeat
    4089         NSInteger download = (difference / 11 * 8) + MIN(difference % 11 + 1, 8); //8 for every 11
    4090         NSInteger seed = (difference / 11) + (difference % 11 >= 8 ? 1 : 0);
    4091         NSInteger paused = (difference / 11) + (difference % 11 >= 9 ? 1 : 0);
    4092         NSInteger active = (difference / 11) + (difference % 11 >= 10 ? 1 : 0);
    4093        
    4094         activeRect.size.width -= active;
    4095        
    4096         downloadRect.origin.x -= active;
    4097         downloadRect.size.width -= download;
    4098        
    4099         seedRect.origin.x -= active + download;
    4100         seedRect.size.width -= seed;
    4101        
    4102         pauseRect.origin.x -= active + download + seed;
    4103         pauseRect.size.width -= paused;
     4089        //calculate width the buttons can take up
     4090        const CGFloat allowedWidth = (searchFrame.origin.x - 5.0) - allRect.origin.x;
     4091       
     4092        const CGFloat currentTotal = NSWidth(allRect) + NSWidth(activeRect) + NSWidth(downloadRect) + NSWidth(seedRect)
     4093                                        + NSWidth(pauseRect);
     4094       
     4095        //decrease button widths proportionally
     4096        const NSInteger all = NSWidth(allRect) * (allowedWidth / currentTotal);
     4097        const NSInteger active = NSWidth(activeRect) * (allowedWidth / currentTotal);
     4098        const NSInteger download = NSWidth(downloadRect) * (allowedWidth / currentTotal);
     4099        const NSInteger seed = NSWidth(seedRect) * (allowedWidth / currentTotal);
     4100        const NSInteger paused = NSWidth(pauseRect) * (allowedWidth / currentTotal);
     4101       
     4102        allRect.size.width = all;
     4103       
     4104        activeRect.size.width = active;
     4105        activeRect.origin.x = NSMaxX(allRect) + 1.0;
     4106       
     4107        downloadRect.size.width = download;
     4108        downloadRect.origin.x = NSMaxX(activeRect) + 1.0;
     4109       
     4110        seedRect.size.width = seed;
     4111        seedRect.origin.x = NSMaxX(downloadRect) + 1.0;
     4112       
     4113        pauseRect.size.width = paused;
     4114        pauseRect.origin.x = NSMaxX(seedRect) + 1.0;
    41044115    }
    41054116    else;
    41064117   
     4118    [fNoFilterButton setFrame: allRect];
    41074119    [fActiveFilterButton setFrame: activeRect];
    41084120    [fDownloadFilterButton setFrame: downloadRect];
Note: See TracChangeset for help on using the changeset viewer.