mirror of
https://github.com/transmission/transmission
synced 2025-01-31 03:12:44 +00:00
refactor ActivityView (#4448)
Refactor based on suggestions from #4400. Provides a fix which supercedes #4427.
This commit is contained in:
parent
3d04dd6828
commit
342ea650df
2 changed files with 26 additions and 32 deletions
|
@ -99,11 +99,7 @@ static CGFloat const kStackViewVerticalSpacing = 8.0;
|
|||
NSRect viewRect = self.view.frame;
|
||||
|
||||
CGFloat difference = self.fHeightChange;
|
||||
if (difference != 0)
|
||||
{
|
||||
viewRect.size.height -= difference;
|
||||
viewRect.size.width = NSWidth(self.view.window.frame);
|
||||
}
|
||||
viewRect.size.height -= difference;
|
||||
|
||||
return viewRect;
|
||||
}
|
||||
|
@ -130,32 +126,24 @@ static CGFloat const kStackViewVerticalSpacing = 8.0;
|
|||
{
|
||||
self.oldHeight = self.fCurrentHeight;
|
||||
|
||||
[self checkLayout];
|
||||
|
||||
if (self.fHeightChange != 0)
|
||||
{
|
||||
[self updateWindowLayout];
|
||||
}
|
||||
[self updateWindowLayout];
|
||||
}
|
||||
|
||||
- (void)updateWindowLayout
|
||||
{
|
||||
if (self.fCurrentHeight != 0)
|
||||
{
|
||||
[self checkLayout];
|
||||
[self checkLayout];
|
||||
|
||||
CGFloat difference = self.fHeightChange;
|
||||
CGFloat difference = self.fHeightChange;
|
||||
|
||||
NSRect windowRect = self.view.window.frame;
|
||||
windowRect.origin.y += difference;
|
||||
windowRect.size.height -= difference;
|
||||
NSRect windowRect = self.view.window.frame;
|
||||
windowRect.origin.y += difference;
|
||||
windowRect.size.height -= difference;
|
||||
|
||||
self.view.window.minSize = NSMakeSize(self.view.window.minSize.width, NSHeight(windowRect));
|
||||
self.view.window.maxSize = NSMakeSize(FLT_MAX, NSHeight(windowRect));
|
||||
self.view.window.minSize = NSMakeSize(self.view.window.minSize.width, NSHeight(windowRect));
|
||||
self.view.window.maxSize = NSMakeSize(FLT_MAX, NSHeight(windowRect));
|
||||
|
||||
self.view.frame = [self viewRect];
|
||||
[self.view.window setFrame:windowRect display:YES animate:YES];
|
||||
}
|
||||
self.view.frame = [self viewRect];
|
||||
[self.view.window setFrame:windowRect display:YES animate:YES];
|
||||
}
|
||||
|
||||
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents
|
||||
|
|
|
@ -114,10 +114,12 @@ static CGFloat const kStackViewSpacing = 8.0;
|
|||
NSRect viewRect = self.view.frame;
|
||||
|
||||
CGFloat difference = self.fHeightChange;
|
||||
if (difference != 0)
|
||||
|
||||
// we check for existence of self.view.window
|
||||
// as when view is shown from TorrentTableView.mm popover we don't want to customize the view height
|
||||
if (self.view.window)
|
||||
{
|
||||
viewRect.size.height -= difference;
|
||||
viewRect.size.width = NSWidth(self.view.window.frame);
|
||||
}
|
||||
|
||||
return viewRect;
|
||||
|
@ -141,17 +143,14 @@ static CGFloat const kStackViewSpacing = 8.0;
|
|||
{
|
||||
self.oldHeight = self.fCurrentHeight;
|
||||
|
||||
[self checkLayout];
|
||||
|
||||
if (self.fHeightChange != 0)
|
||||
{
|
||||
[self updateWindowLayout];
|
||||
}
|
||||
[self updateWindowLayout];
|
||||
}
|
||||
|
||||
- (void)updateWindowLayout
|
||||
{
|
||||
if (self.fCurrentHeight != 0)
|
||||
// we check for existence of self.view.window
|
||||
// as when view is shown from TorrentTableView.mm popover we don't want to customize the view height
|
||||
if (self.view.window)
|
||||
{
|
||||
[self checkLayout];
|
||||
|
||||
|
@ -167,6 +166,13 @@ static CGFloat const kStackViewSpacing = 8.0;
|
|||
self.view.frame = [self viewRect];
|
||||
[self.view.window setFrame:windowRect display:YES animate:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
// set popover width
|
||||
NSRect rect = self.view.frame;
|
||||
rect.size.width = NSWidth(self.fOptionsStackView.frame) + (2 * kStackViewInset);
|
||||
self.view.frame = rect;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents
|
||||
|
|
Loading…
Reference in a new issue