Changeset 7753


Ignore:
Timestamp:
Jan 19, 2009, 10:08:21 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
  • trunk/macosx/Controller.m

    r7675 r7753  
    39373937   
    39383938    //replace all buttons
     3939    [fNoFilterButton sizeToFit];
    39393940    [fActiveFilterButton sizeToFit];
    39403941    [fDownloadFilterButton sizeToFit];
     
    39423943    [fPauseFilterButton sizeToFit];
    39433944   
     3945    NSRect allRect = [fNoFilterButton frame];
     3946   
    39443947    NSRect activeRect = [fActiveFilterButton frame];
     3948    activeRect.origin.x = NSMaxX(allRect) + 1.0;
    39453949   
    39463950    NSRect downloadRect = [fDownloadFilterButton frame];
     
    39693973        searchFrame.size.width = SEARCH_FILTER_MIN_WIDTH;
    39703974       
    3971         //resize the buttons so they don't overlay
    3972         NSInteger difference = (NSMaxX(pauseRect) + 5.0) - searchFrame.origin.x - 1; //subtract 1, since 0 will be counted
    3973        
    3974         //decrease downloading by 8, seeding by 1, paused by 1, active by 1, repeat
    3975         NSInteger download = (difference / 11 * 8) + MIN(difference % 11 + 1, 8); //8 for every 11
    3976         NSInteger seed = (difference / 11) + (difference % 11 >= 8 ? 1 : 0);
    3977         NSInteger paused = (difference / 11) + (difference % 11 >= 9 ? 1 : 0);
    3978         NSInteger active = (difference / 11) + (difference % 11 >= 10 ? 1 : 0);
    3979        
    3980         activeRect.size.width -= active;
    3981        
    3982         downloadRect.origin.x -= active;
    3983         downloadRect.size.width -= download;
    3984        
    3985         seedRect.origin.x -= active + download;
    3986         seedRect.size.width -= seed;
    3987        
    3988         pauseRect.origin.x -= active + download + seed;
    3989         pauseRect.size.width -= paused;
     3975        //calculate width the buttons can take up
     3976        const CGFloat allowedWidth = (searchFrame.origin.x - 5.0) - allRect.origin.x;
     3977       
     3978        const CGFloat currentTotal = NSWidth(allRect) + NSWidth(activeRect) + NSWidth(downloadRect) + NSWidth(seedRect)
     3979                                        + NSWidth(pauseRect);
     3980       
     3981        //decrease button widths proportionally
     3982        const NSInteger all = NSWidth(allRect) * (allowedWidth / currentTotal);
     3983        const NSInteger active = NSWidth(activeRect) * (allowedWidth / currentTotal);
     3984        const NSInteger download = NSWidth(downloadRect) * (allowedWidth / currentTotal);
     3985        const NSInteger seed = NSWidth(seedRect) * (allowedWidth / currentTotal);
     3986        const NSInteger paused = NSWidth(pauseRect) * (allowedWidth / currentTotal);
     3987       
     3988        allRect.size.width = all;
     3989       
     3990        activeRect.size.width = active;
     3991        activeRect.origin.x = NSMaxX(allRect) + 1.0;
     3992       
     3993        downloadRect.size.width = download;
     3994        downloadRect.origin.x = NSMaxX(activeRect) + 1.0;
     3995       
     3996        seedRect.size.width = seed;
     3997        seedRect.origin.x = NSMaxX(downloadRect) + 1.0;
     3998       
     3999        pauseRect.size.width = paused;
     4000        pauseRect.origin.x = NSMaxX(seedRect) + 1.0;
    39904001    }
    39914002    else;
    39924003   
     4004    [fNoFilterButton setFrame: allRect];
    39934005    [fActiveFilterButton setFrame: activeRect];
    39944006    [fDownloadFilterButton setFrame: downloadRect];
Note: See TracChangeset for help on using the changeset viewer.