diff --git a/macosx/Controller.mm b/macosx/Controller.mm index b3c7182a8..0ffcb8073 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -767,9 +767,6 @@ static void removeKeRangerRansomware() { [self showInfo:nil]; } - - //redraw filterbar to avoid clipping - [NSNotificationCenter.defaultCenter postNotificationName:@"ResizeBar" object:nil]; } - (void)applicationDidFinishLaunching:(NSNotification*)notification @@ -4948,7 +4945,7 @@ static void removeKeRangerRansomware() [self.fStackView insertArrangedSubview:self.fFilterBar.view atIndex:idx]; NSDictionary* views = @{ @"fFilterBar" : self.fFilterBar.view }; - [self.fStackView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[fFilterBar(==21)]" options:0 + [self.fStackView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[fFilterBar(==23)]" options:0 metrics:nil views:views]]; diff --git a/macosx/FilterBar.xib b/macosx/FilterBar.xib index 94e51095d..790edb20e 100644 --- a/macosx/FilterBar.xib +++ b/macosx/FilterBar.xib @@ -25,20 +25,11 @@ - - + - + + + @@ -60,57 +51,100 @@ - + - + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + @@ -121,18 +155,20 @@ - + + + + + + + + + + + + + diff --git a/macosx/FilterBarController.mm b/macosx/FilterBarController.mm index 7ea8cf7ea..fe387ea70 100644 --- a/macosx/FilterBarController.mm +++ b/macosx/FilterBarController.mm @@ -10,9 +10,6 @@ #define FILTER_TYPE_TAG_NAME 401 #define FILTER_TYPE_TAG_TRACKER 402 -#define SEARCH_MIN_WIDTH 48.0 -#define SEARCH_MAX_WIDTH 95.0 - @interface FilterBarController () @property(nonatomic) IBOutlet FilterButton* fNoFilterButton; @@ -26,7 +23,6 @@ @property(nonatomic) IBOutlet NSPopUpButton* fGroupsButton; -- (void)resizeBar; - (void)updateGroupsButton; - (void)updateGroups:(NSNotification*)notification; @@ -62,8 +58,6 @@ [self.fGroupsButton.menu itemWithTag:GROUP_FILTER_ALL_TAG].title = NSLocalizedString(@"All Groups", "Filter Bar -> group filter menu"); - [self resizeBar]; - //set current filter NSString* filterType = [NSUserDefaults.standardUserDefaults stringForKey:@"Filter"]; @@ -127,11 +121,6 @@ [self updateGroupsButton]; - [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(resizeBar) name:NSWindowDidResizeNotification - object:self.view.window]; - - [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(resizeBar) name:@"ResizeBar" object:nil]; - //update when groups change [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(updateGroups:) name:@"UpdateGroups" object:nil]; } @@ -398,70 +387,6 @@ #pragma mark - Private -- (void)resizeBar -{ - //replace all buttons - [self.fNoFilterButton sizeToFit]; - [self.fActiveFilterButton sizeToFit]; - [self.fDownloadFilterButton sizeToFit]; - [self.fSeedFilterButton sizeToFit]; - [self.fPauseFilterButton sizeToFit]; - [self.fErrorFilterButton sizeToFit]; - - NSRect allRect = self.fNoFilterButton.frame; - NSRect activeRect = self.fActiveFilterButton.frame; - NSRect downloadRect = self.fDownloadFilterButton.frame; - NSRect seedRect = self.fSeedFilterButton.frame; - NSRect pauseRect = self.fPauseFilterButton.frame; - NSRect errorRect = self.fErrorFilterButton.frame; - - //size search filter to not overlap buttons - NSRect searchFrame = self.fSearchField.frame; - searchFrame.origin.x = NSMaxX(errorRect) + 5.0; - searchFrame.size.width = NSWidth(self.view.frame) - searchFrame.origin.x - 5.0; - - //make sure it is not too long - if (NSWidth(searchFrame) > SEARCH_MAX_WIDTH) - { - searchFrame.origin.x += NSWidth(searchFrame) - SEARCH_MAX_WIDTH; - searchFrame.size.width = SEARCH_MAX_WIDTH; - } - else if (NSWidth(searchFrame) < SEARCH_MIN_WIDTH) - { - searchFrame.origin.x += NSWidth(searchFrame) - SEARCH_MIN_WIDTH; - searchFrame.size.width = SEARCH_MIN_WIDTH; - - //calculate width the buttons can take up - CGFloat const allowedWidth = (searchFrame.origin.x - 5.0) - allRect.origin.x; - CGFloat const currentWidth = NSWidth(allRect) + NSWidth(activeRect) + NSWidth(downloadRect) + NSWidth(seedRect) + - NSWidth(pauseRect) + NSWidth(errorRect) + 4.0; //add 4 for space between buttons - CGFloat const ratio = allowedWidth / currentWidth; - - //decrease button widths proportionally - allRect.size.width = NSWidth(allRect) * ratio; - activeRect.size.width = NSWidth(activeRect) * ratio; - downloadRect.size.width = NSWidth(downloadRect) * ratio; - seedRect.size.width = NSWidth(seedRect) * ratio; - pauseRect.size.width = NSWidth(pauseRect) * ratio; - errorRect.size.width = NSWidth(errorRect) * ratio; - } - - activeRect.origin.x = NSMaxX(allRect) + 1.0; - downloadRect.origin.x = NSMaxX(activeRect) + 1.0; - seedRect.origin.x = NSMaxX(downloadRect) + 1.0; - pauseRect.origin.x = NSMaxX(seedRect) + 1.0; - errorRect.origin.x = NSMaxX(pauseRect) + 1.0; - - self.fNoFilterButton.frame = allRect; - self.fActiveFilterButton.frame = activeRect; - self.fDownloadFilterButton.frame = downloadRect; - self.fSeedFilterButton.frame = seedRect; - self.fPauseFilterButton.frame = pauseRect; - self.fErrorFilterButton.frame = errorRect; - - self.fSearchField.frame = searchFrame; -} - - (void)updateGroupsButton { NSInteger const groupIndex = [NSUserDefaults.standardUserDefaults integerForKey:@"FilterGroup"]; diff --git a/macosx/StatusBar.xib b/macosx/StatusBar.xib index a1a8efd50..788e9cfe0 100644 --- a/macosx/StatusBar.xib +++ b/macosx/StatusBar.xib @@ -22,9 +22,8 @@ - - - + + @@ -55,28 +54,24 @@ - - - + + - - - + + - - - + + - - - + + @@ -84,6 +79,19 @@ + + + + + + + + + + + + + diff --git a/macosx/StatusBarController.mm b/macosx/StatusBarController.mm index 0b04226c3..90b695607 100644 --- a/macosx/StatusBarController.mm +++ b/macosx/StatusBarController.mm @@ -32,8 +32,6 @@ typedef NS_ENUM(unsigned int, statusTag) { @property(nonatomic) CGFloat fPreviousDownloadRate; @property(nonatomic) CGFloat fPreviousUploadRate; -- (void)resizeStatusButton; - @end @implementation StatusBarController @@ -70,9 +68,6 @@ typedef NS_ENUM(unsigned int, statusTag) { //update when speed limits are changed [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(updateSpeedFieldsToolTips) name:@"SpeedLimitUpdate" object:nil]; - [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(resizeStatusButton) - name:NSWindowDidResizeNotification - object:self.view.window]; } - (void)dealloc @@ -137,7 +132,6 @@ typedef NS_ENUM(unsigned int, statusTag) { if (![self.fStatusButton.title isEqualToString:statusString]) { self.fStatusButton.title = statusString; - [self resizeStatusButton]; } } @@ -247,23 +241,4 @@ typedef NS_ENUM(unsigned int, statusTag) { return YES; } -#pragma mark - Private - -- (void)resizeStatusButton -{ - [self.fStatusButton sizeToFit]; - - //width ends up being too long - NSRect statusFrame = self.fStatusButton.frame; - statusFrame.size.width -= 25.0; - - CGFloat const difference = NSMaxX(statusFrame) + 5.0 - NSMinX(self.fTotalDLImageView.frame); - if (difference > 0.0) - { - statusFrame.size.width -= difference; - } - - self.fStatusButton.frame = statusFrame; -} - @end