Changeset 7753
- Timestamp:
- Jan 19, 2009, 10:08:21 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/Controller.m
r7675 r7753 3937 3937 3938 3938 //replace all buttons 3939 [fNoFilterButton sizeToFit]; 3939 3940 [fActiveFilterButton sizeToFit]; 3940 3941 [fDownloadFilterButton sizeToFit]; … … 3942 3943 [fPauseFilterButton sizeToFit]; 3943 3944 3945 NSRect allRect = [fNoFilterButton frame]; 3946 3944 3947 NSRect activeRect = [fActiveFilterButton frame]; 3948 activeRect.origin.x = NSMaxX(allRect) + 1.0; 3945 3949 3946 3950 NSRect downloadRect = [fDownloadFilterButton frame]; … … 3969 3973 searchFrame.size.width = SEARCH_FILTER_MIN_WIDTH; 3970 3974 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; 3990 4001 } 3991 4002 else; 3992 4003 4004 [fNoFilterButton setFrame: allRect]; 3993 4005 [fActiveFilterButton setFrame: activeRect]; 3994 4006 [fDownloadFilterButton setFrame: downloadRect];
Note: See TracChangeset
for help on using the changeset viewer.