diff --git a/macosx/Controller.h b/macosx/Controller.h index 2f1a7fe38..2ff3dafb0 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -254,6 +254,8 @@ typedef enum - (void) setWindowSizeToFit; - (NSRect) sizedWindowFrame; +- (void) resizeFilterBar; + - (void) updateForExpandCollape; - (void) showMainWindow: (id) sender; diff --git a/macosx/Controller.m b/macosx/Controller.m index fb9f2bd6c..6102e4949 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -564,7 +564,11 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy [self applyFilter: nil]; - [fWindow makeKeyAndOrderFront: nil]; + [fWindow makeKeyAndOrderFront: nil]; + + //can't be done earlier + if (![fFilterBar isHidden]) + [self resizeFilterBar]; if ([fDefaults boolForKey: @"InfoVisible"]) [self showInfo: nil]; @@ -4090,39 +4094,8 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy return [self windowFrameByAddingHeight: heightChange checkLimits: YES]; } -- (void) updateForExpandCollape +- (void) resizeFilterBar { - [self setWindowSizeToFit]; - [self setBottomCountText: YES]; -} - -- (void) showMainWindow: (id) sender -{ - [fWindow makeKeyAndOrderFront: nil]; -} - -- (void) windowDidBecomeMain: (NSNotification *) notification -{ - [fBadger clearCompleted]; - [self updateUI]; -} - -- (NSSize) windowWillResize: (NSWindow *) sender toSize: (NSSize) proposedFrameSize -{ - //only resize horizontally if autosize is enabled - if ([fDefaults boolForKey: @"AutoSize"]) - proposedFrameSize.height = [fWindow frame].size.height; - return proposedFrameSize; -} - -- (void) windowDidResize: (NSNotification *) notification -{ - if (![fStatusBar isHidden]) - [self resizeStatusButton]; - - if ([fFilterBar isHidden]) - return; - //replace all buttons [fNoFilterButton sizeToFit]; [fActiveFilterButton sizeToFit]; @@ -4181,6 +4154,42 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy [fSearchFilterField setFrame: searchFrame]; } +- (void) updateForExpandCollape +{ + [self setWindowSizeToFit]; + [self setBottomCountText: YES]; +} + +- (void) showMainWindow: (id) sender +{ + [fWindow makeKeyAndOrderFront: nil]; +} + +- (void) windowDidBecomeMain: (NSNotification *) notification +{ + [fBadger clearCompleted]; + [self updateUI]; +} + +- (NSSize) windowWillResize: (NSWindow *) sender toSize: (NSSize) proposedFrameSize +{ + //only resize horizontally if autosize is enabled + if ([fDefaults boolForKey: @"AutoSize"]) + proposedFrameSize.height = [fWindow frame].size.height; + return proposedFrameSize; +} + +- (void) windowDidResize: (NSNotification *) notification +{ + if (![fStatusBar isHidden]) + [self resizeStatusButton]; + + if ([fFilterBar isHidden]) + return; + + [self resizeFilterBar]; +} + - (void) applicationWillUnhide: (NSNotification *) notification { [self updateUI]; diff --git a/macosx/TorrentCell.m b/macosx/TorrentCell.m index 6b899fda0..015e533cc 100644 --- a/macosx/TorrentCell.m +++ b/macosx/TorrentCell.m @@ -69,8 +69,7 @@ - (void) drawPiecesBar: (NSRect) barRect; - (NSRect) rectForMinimalStatusWithString: (NSAttributedString *) string inBounds: (NSRect) bounds; -- (NSRect) rectForTitleWithStringBasedOnMinimalStatusRect: (NSRect) statusRect - inBounds: (NSRect) bounds; +- (NSRect) rectForTitleWithStringBasedOnMinimalStatusRect: (NSRect) statusRect inBounds: (NSRect) bounds; - (NSRect) rectForProgressWithStringInBounds: (NSRect) bounds; - (NSRect) rectForStatusWithStringInBounds: (NSRect) bounds; - (NSRect) barRectForBounds: (NSRect) bounds; @@ -622,8 +621,7 @@ return result; } -- (NSRect) rectForTitleWithStringBasedOnMinimalStatusRect: (NSRect) statusRect - inBounds: (NSRect) bounds +- (NSRect) rectForTitleWithStringBasedOnMinimalStatusRect: (NSRect) statusRect inBounds: (NSRect) bounds { const BOOL minimal = [fDefaults boolForKey: @"SmallView"]; @@ -633,9 +631,11 @@ + (minimal ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG) + PADDING_BETWEEN_IMAGE_AND_TITLE; result.size.height = HEIGHT_TITLE; - result.size.width = NSMaxX(bounds) - result.origin.x - PADDING_HORIZONTAL - - (minimal ? PADDING_BETWEEN_TITLE_AND_MIN_STATUS + NSWidth(statusRect) : 0.0) - - ([[self representedObject] priority] != TR_PRI_NORMAL ? PRIORITY_ICON_WIDTH + PADDING_BETWEEN_TITLE_AND_PRIORITY: 0.0); + result.size.width = NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONTAL; + if (minimal) + result.size.width -= PADDING_BETWEEN_TITLE_AND_MIN_STATUS + NSWidth(statusRect); + if ([[self representedObject] priority] != TR_PRI_NORMAL) + result.size.width -= PRIORITY_ICON_WIDTH + PADDING_BETWEEN_TITLE_AND_PRIORITY; return result; } @@ -669,11 +669,11 @@ { const BOOL minimal = [fDefaults boolForKey: @"SmallView"]; - NSRect result = bounds; + NSRect result; result.size.height = BAR_HEIGHT; - result.origin.x += (minimal ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG) + PADDING_BETWEEN_IMAGE_AND_BAR; + result.origin.x = NSMinX(bounds) + (minimal ? IMAGE_SIZE_MIN : IMAGE_SIZE_REG) + PADDING_BETWEEN_IMAGE_AND_BAR; - result.origin.y += PADDING_ABOVE_TITLE + HEIGHT_TITLE; + result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE; if (minimal) result.origin.y += PADDING_BETWEEN_TITLE_AND_BAR_MIN; else @@ -686,12 +686,12 @@ - (NSRect) controlButtonRectForBounds: (NSRect) bounds { - NSRect result = bounds; + NSRect result; result.size.height = NORMAL_BUTTON_WIDTH; result.size.width = NORMAL_BUTTON_WIDTH; result.origin.x = NSMaxX(bounds) - 2.0f * (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH); - result.origin.y += PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5f; + result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5f; if ([fDefaults boolForKey: @"SmallView"]) result.origin.y += PADDING_BETWEEN_TITLE_AND_BAR_MIN; else @@ -702,12 +702,12 @@ - (NSRect) revealButtonRectForBounds: (NSRect) bounds { - NSRect result = bounds; + NSRect result; result.size.height = NORMAL_BUTTON_WIDTH; result.size.width = NORMAL_BUTTON_WIDTH; result.origin.x = NSMaxX(bounds) - (PADDING_HORIZONTAL + NORMAL_BUTTON_WIDTH); - result.origin.y += PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5f; + result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE + HEIGHT_TITLE - (NORMAL_BUTTON_WIDTH - BAR_HEIGHT) * 0.5f; if ([fDefaults boolForKey: @"SmallView"]) result.origin.y += PADDING_BETWEEN_TITLE_AND_BAR_MIN; else