mirror of
https://github.com/transmission/transmission
synced 2025-01-03 05:25:52 +00:00
mac os autosize dock fix (#7188)
* macOS autosize dock fix * Fix: Move variable declaration inside block to minimize scope length * Fix: Move comment to its own line for better readability * Fix: Use dot syntax for accessing scrollViewHeight property in calculateScrollViewHeightWithDockAdjustment method * Fix: Add CGFloat type declaration for height variable * rollback alignment change for clang-format --------- Co-authored-by: emeritaacuity0u <emerita.acuity_0u@icloud.com>
This commit is contained in:
parent
19543ba65f
commit
4e25c038a6
1 changed files with 21 additions and 5 deletions
|
@ -5179,7 +5179,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
|
||||||
|
|
||||||
if (![self.fDefaults boolForKey:@"AutoSize"])
|
if (![self.fDefaults boolForKey:@"AutoSize"])
|
||||||
{
|
{
|
||||||
//only set a minimum height constraint
|
// Only set a minimum height constraint
|
||||||
CGFloat height = self.minScrollViewHeightAllowed;
|
CGFloat height = self.minScrollViewHeightAllowed;
|
||||||
NSString* constraintsString = [NSString stringWithFormat:@"V:[scrollView(>=%f)]", height];
|
NSString* constraintsString = [NSString stringWithFormat:@"V:[scrollView(>=%f)]", height];
|
||||||
self.fStackViewHeightConstraints = [NSLayoutConstraint constraintsWithVisualFormat:constraintsString options:0
|
self.fStackViewHeightConstraints = [NSLayoutConstraint constraintsWithVisualFormat:constraintsString options:0
|
||||||
|
@ -5188,18 +5188,18 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//set a fixed height constraint
|
// Set a fixed height constraint
|
||||||
CGFloat height = self.scrollViewHeight;
|
CGFloat height = [self calculateScrollViewHeightWithDockAdjustment];
|
||||||
NSString* constraintsString = [NSString stringWithFormat:@"V:[scrollView(==%f)]", height];
|
NSString* constraintsString = [NSString stringWithFormat:@"V:[scrollView(==%f)]", height];
|
||||||
self.fStackViewHeightConstraints = [NSLayoutConstraint constraintsWithVisualFormat:constraintsString options:0
|
self.fStackViewHeightConstraints = [NSLayoutConstraint constraintsWithVisualFormat:constraintsString options:0
|
||||||
metrics:nil
|
metrics:nil
|
||||||
views:views];
|
views:views];
|
||||||
|
|
||||||
//redraw table to avoid empty cells
|
// Redraw table to avoid empty cells
|
||||||
[self.fTableView reloadData];
|
[self.fTableView reloadData];
|
||||||
}
|
}
|
||||||
|
|
||||||
//add height constraint to fStackView
|
// Add height constraint to fStackView
|
||||||
[self.fStackView addConstraints:self.fStackViewHeightConstraints];
|
[self.fStackView addConstraints:self.fStackViewHeightConstraints];
|
||||||
|
|
||||||
scrollView.hasVerticalScroller = YES;
|
scrollView.hasVerticalScroller = YES;
|
||||||
|
@ -5210,6 +5210,22 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (CGFloat)calculateScrollViewHeightWithDockAdjustment
|
||||||
|
{
|
||||||
|
CGFloat height = self.scrollViewHeight;
|
||||||
|
|
||||||
|
// Get the main screen's visible frame
|
||||||
|
NSScreen* screen = self.fWindow.screen;
|
||||||
|
if (screen)
|
||||||
|
{
|
||||||
|
// This frame respects the Dock and menu bar
|
||||||
|
NSRect visibleFrame = screen.visibleFrame;
|
||||||
|
height = MIN(height, visibleFrame.size.height - [self toolbarHeight] - [self mainWindowComponentHeight]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)updateForAutoSize
|
- (void)updateForAutoSize
|
||||||
{
|
{
|
||||||
if (!self.isFullScreen)
|
if (!self.isFullScreen)
|
||||||
|
|
Loading…
Reference in a new issue