fix: layout issues in macOS client torrent inspector window (#4366)

This commit is contained in:
SweetPPro 2022-12-17 05:27:37 +11:00 committed by GitHub
parent 0824c2da6d
commit 5d5893036d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 117 additions and 283 deletions

View File

@ -10,38 +10,21 @@
<connections>
<outlet property="fActivityStackView" destination="2aX-cc-oXC" id="fln-Xs-VS8"/>
<outlet property="fDateActivityField" destination="9" id="71"/>
<outlet property="fDateActivityLabel" destination="10" id="110"/>
<outlet property="fDateAddedField" destination="15" id="69"/>
<outlet property="fDateAddedLabel" destination="16" id="108"/>
<outlet property="fDateCompletedField" destination="13" id="70"/>
<outlet property="fDateCompletedLabel" destination="14" id="109"/>
<outlet property="fDatesSectionLabel" destination="17" id="114"/>
<outlet property="fDatesView" destination="WMr-Dh-mdg" id="v6r-qK-AG5"/>
<outlet property="fDownloadTimeField" destination="82" id="99"/>
<outlet property="fDownloadTimeLabel" destination="83" id="112"/>
<outlet property="fDownloadedLabel" destination="29" id="103"/>
<outlet property="fDownloadedTotalField" destination="28" id="65"/>
<outlet property="fErrorLabel" destination="18" id="107"/>
<outlet property="fErrorMessageView" destination="61" id="72"/>
<outlet property="fErrorScrollView" destination="3" id="118"/>
<outlet property="fFailedDLLabel" destination="5" id="105"/>
<outlet property="fFailedHashField" destination="4" id="67"/>
<outlet property="fHaveField" destination="22" id="64"/>
<outlet property="fHaveLabel" destination="23" id="102"/>
<outlet property="fPiecesControl" destination="8" id="73"/>
<outlet property="fPiecesView" destination="19" id="74"/>
<outlet property="fProgressField" destination="6" id="63"/>
<outlet property="fProgressLabel" destination="7" id="101"/>
<outlet property="fRatioField" destination="24" id="68"/>
<outlet property="fRatioLabel" destination="25" id="106"/>
<outlet property="fSeedTimeField" destination="80" id="98"/>
<outlet property="fSeedTimeLabel" destination="81" id="111"/>
<outlet property="fStateField" destination="20" id="62"/>
<outlet property="fStateLabel" destination="21" id="100"/>
<outlet property="fTimeSectionLabel" destination="84" id="116"/>
<outlet property="fTransferSectionLabel" destination="11" id="113"/>
<outlet property="fTransferView" destination="Vhd-qH-kFK" id="6Rm-4u-qEm"/>
<outlet property="fUploadedLabel" destination="27" id="104"/>
<outlet property="fUploadedTotalField" destination="26" id="66"/>
<outlet property="view" destination="2" id="75"/>
</connections>
@ -227,7 +210,7 @@
</subviews>
</clipView>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="280" id="Rsh-Sr-mv6"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="247" id="Rsh-Sr-mv6"/>
<constraint firstAttribute="height" constant="58" id="WCB-XG-J3d"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" controlSize="small" horizontal="YES" id="59">
@ -447,7 +430,7 @@
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="WMr-Dh-mdg" secondAttribute="trailing" priority="250" constant="218" id="BL5-hI-Rcy"/>
<constraint firstAttribute="width" priority="250" constant="360" id="zSb-K0-Tyg"/>
<constraint firstAttribute="width" priority="250" constant="330" id="zSb-K0-Tyg"/>
</constraints>
<visibilityPriorities>
<integer value="1000"/>

View File

@ -8,24 +8,14 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="InfoGeneralViewController">
<connections>
<outlet property="fCommentLabel" destination="7" id="59"/>
<outlet property="fCommentScrollView" destination="4" id="61"/>
<outlet property="fCommentView" destination="38" id="51"/>
<outlet property="fCreatorField" destination="10" id="46"/>
<outlet property="fCreatorLabel" destination="11" id="57"/>
<outlet property="fDataLocationField" destination="14" id="48"/>
<outlet property="fDataLocationLabel" destination="15" id="60"/>
<outlet property="fDateCreatedField" destination="8" id="47"/>
<outlet property="fDateCreatedLabel" destination="9" id="58"/>
<outlet property="fHashField" destination="5" id="43"/>
<outlet property="fHashLabel" destination="6" id="55"/>
<outlet property="fInfoSectionLabel" destination="3" id="52"/>
<outlet property="fPiecesField" destination="19" id="42"/>
<outlet property="fPiecesLabel" destination="20" id="54"/>
<outlet property="fRevealDataButton" destination="12" id="49"/>
<outlet property="fSecureField" destination="16" id="44"/>
<outlet property="fSecureLabel" destination="17" id="56"/>
<outlet property="fWhereSectionLabel" destination="13" id="53"/>
<outlet property="view" destination="2" id="45"/>
</connections>
</customObject>

View File

@ -8,7 +8,6 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="InfoOptionsViewController">
<connections>
<outlet property="fAdvancedSectionLabel" destination="14" id="126"/>
<outlet property="fDownloadLimitCheck" destination="7" id="66"/>
<outlet property="fDownloadLimitField" destination="17" id="69"/>
<outlet property="fDownloadLimitLabel" destination="16" id="70"/>
@ -17,23 +16,16 @@
<outlet property="fIdleLimitGlobalLabel" destination="107" id="111"/>
<outlet property="fIdleLimitLabel" destination="97" id="103"/>
<outlet property="fIdlePopUp" destination="80" id="104"/>
<outlet property="fInactivityLabel" destination="79" id="124"/>
<outlet property="fMaxConnectionsLabel" destination="13" id="127"/>
<outlet property="fOptionsStackView" destination="KYq-Jm-g2s" id="VcL-x0-Jdk"/>
<outlet property="fPeersConnectField" destination="12" id="78"/>
<outlet property="fPeersConnectLabel" destination="11" id="77"/>
<outlet property="fPriorityLabel" destination="4" id="121"/>
<outlet property="fPriorityPopUp" destination="3" id="76"/>
<outlet property="fPrioritySectionLabel" destination="5" id="120"/>
<outlet property="fPriorityView" destination="2Ow-Hq-XLB" id="mIQ-bG-tAo"/>
<outlet property="fRatioLabel" destination="15" id="123"/>
<outlet property="fRatioLimitField" destination="10" id="75"/>
<outlet property="fRatioLimitGlobalLabel" destination="109" id="112"/>
<outlet property="fRatioPopUp" destination="9" id="74"/>
<outlet property="fRemoveSeedingCompleteCheck" destination="113" id="118"/>
<outlet property="fSeedingLimitsSectionLabel" destination="21" id="122"/>
<outlet property="fSeedingView" destination="wfz-WZ-zVG" id="zLN-y6-kI2"/>
<outlet property="fTransferBandwidthSectionLabel" destination="20" id="125"/>
<outlet property="fUploadLimitCheck" destination="8" id="67"/>
<outlet property="fUploadLimitField" destination="19" id="71"/>
<outlet property="fUploadLimitLabel" destination="18" id="72"/>
@ -111,7 +103,7 @@
</connections>
</button>
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="3">
<rect key="frame" x="96" y="99" width="74" height="17"/>
<rect key="frame" x="96" y="100" width="74" height="17"/>
<popUpButtonCell key="cell" type="roundRect" title="Normal" bezelStyle="roundedRect" alignment="left" controlSize="small" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="1" imageScaling="proportionallyDown" inset="2" selectedItem="51" id="48">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
@ -230,7 +222,7 @@
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="80">
<rect key="frame" x="60" y="79" width="122" height="20"/>
<rect key="frame" x="60" y="80" width="122" height="20"/>
<popUpButtonCell key="cell" type="roundRect" title="Global Setting" bezelStyle="roundedRect" alignment="left" controlSize="small" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" preferredEdge="maxY" selectedItem="87" id="84">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
@ -273,7 +265,7 @@
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="9">
<rect key="frame" x="60" y="101" width="122" height="20"/>
<rect key="frame" x="60" y="102" width="122" height="20"/>
<popUpButtonCell key="cell" type="roundRect" title="Global Setting" bezelStyle="roundedRect" alignment="left" controlSize="small" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" inset="2" preferredEdge="maxY" selectedItem="41" id="38">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>

View File

@ -9,6 +9,8 @@
@interface InfoActivityViewController : NSViewController<InfoViewController>
- (NSRect)viewRect;
- (void)checkLayout;
- (void)checkWindowSize;
- (void)updateWindowLayout;
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents;
@ -19,5 +21,6 @@
- (void)clearView;
@property(nonatomic) IBOutlet NSView* fTransferView;
@property(nonatomic) CGFloat oldHeight;
@end

View File

@ -42,31 +42,13 @@ static CGFloat const kStackViewVerticalSpacing = 8.0;
@property(nonatomic) IBOutlet PiecesView* fPiecesView;
@property(nonatomic) IBOutlet NSSegmentedControl* fPiecesControl;
//remove when we switch to auto layout
@property(nonatomic) IBOutlet NSTextField* fTransferSectionLabel;
@property(nonatomic) IBOutlet NSTextField* fDatesSectionLabel;
@property(nonatomic) IBOutlet NSTextField* fTimeSectionLabel;
@property(nonatomic) IBOutlet NSTextField* fStateLabel;
@property(nonatomic) IBOutlet NSTextField* fProgressLabel;
@property(nonatomic) IBOutlet NSTextField* fHaveLabel;
@property(nonatomic) IBOutlet NSTextField* fDownloadedLabel;
@property(nonatomic) IBOutlet NSTextField* fUploadedLabel;
@property(nonatomic) IBOutlet NSTextField* fFailedDLLabel;
@property(nonatomic) IBOutlet NSTextField* fRatioLabel;
@property(nonatomic) IBOutlet NSTextField* fErrorLabel;
@property(nonatomic) IBOutlet NSTextField* fDateAddedLabel;
@property(nonatomic) IBOutlet NSTextField* fDateCompletedLabel;
@property(nonatomic) IBOutlet NSTextField* fDateActivityLabel;
@property(nonatomic) IBOutlet NSTextField* fDownloadTimeLabel;
@property(nonatomic) IBOutlet NSTextField* fSeedTimeLabel;
@property(nonatomic) IBOutlet NSScrollView* fErrorScrollView;
@property(nonatomic) IBOutlet NSStackView* fActivityStackView;
@property(nonatomic) IBOutlet NSView* fDatesView;
@property(nonatomic, readonly) CGFloat currentHeight;
@property(nonatomic, readonly) CGFloat horizLayoutHeight;
@property(nonatomic, readonly) CGFloat horizLayoutWidth;
@property(nonatomic, readonly) CGFloat vertLayoutHeight;
@property(nonatomic, readwrite) CGFloat fHeightChange;
@property(nonatomic, readwrite) CGFloat fCurrentHeight;
@property(nonatomic, readonly) CGFloat fHorizLayoutHeight;
@property(nonatomic, readonly) CGFloat fHorizLayoutWidth;
@property(nonatomic, readonly) CGFloat fVertLayoutHeight;
@end
@ -84,75 +66,7 @@ static CGFloat const kStackViewVerticalSpacing = 8.0;
- (void)awakeFromNib
{
[self.fTransferSectionLabel sizeToFit];
[self.fDatesSectionLabel sizeToFit];
[self.fTimeSectionLabel sizeToFit];
NSArray* labels = @[
self.fStateLabel,
self.fProgressLabel,
self.fHaveLabel,
self.fDownloadedLabel,
self.fUploadedLabel,
self.fFailedDLLabel,
self.fRatioLabel,
self.fErrorLabel,
self.fDateAddedLabel,
self.fDateCompletedLabel,
self.fDateActivityLabel,
self.fDownloadTimeLabel,
self.fSeedTimeLabel
];
CGFloat oldMaxWidth = 0.0, originX = 0.0, newMaxWidth = 0.0;
for (NSTextField* label in labels)
{
NSRect const oldFrame = label.frame;
if (oldFrame.size.width > oldMaxWidth)
{
oldMaxWidth = oldFrame.size.width;
originX = oldFrame.origin.x;
}
[label sizeToFit];
CGFloat const newWidth = label.bounds.size.width;
if (newWidth > newMaxWidth)
{
newMaxWidth = newWidth;
}
}
for (NSTextField* label in labels)
{
NSRect frame = label.frame;
frame.origin.x = originX + (newMaxWidth - frame.size.width);
label.frame = frame;
}
NSArray* fields = @[
self.fDateAddedField,
self.fDateCompletedField,
self.fDateActivityField,
self.fStateField,
self.fProgressField,
self.fHaveField,
self.fDownloadedTotalField,
self.fUploadedTotalField,
self.fFailedHashField,
self.fRatioField,
self.fDownloadTimeField,
self.fSeedTimeField,
self.fErrorScrollView
];
CGFloat const widthIncrease = newMaxWidth - oldMaxWidth;
for (NSView* field in fields)
{
NSRect frame = field.frame;
frame.origin.x += widthIncrease;
frame.size.width -= widthIncrease;
field.frame = frame;
}
[self checkWindowSize];
}
- (void)dealloc
@ -160,55 +74,32 @@ static CGFloat const kStackViewVerticalSpacing = 8.0;
[NSNotificationCenter.defaultCenter removeObserver:self];
}
- (CGFloat)currentHeight
{
return NSHeight(self.view.frame);
}
- (CGFloat)horizLayoutHeight
- (CGFloat)fHorizLayoutHeight
{
return NSHeight(self.fTransferView.frame) + 2 * kStackViewInset;
}
- (CGFloat)horizLayoutWidth
- (CGFloat)fHorizLayoutWidth
{
return NSWidth(self.fTransferView.frame) + NSWidth(self.fDatesView.frame) + (2 * kStackViewInset) + kStackViewHorizontalSpacing;
}
- (CGFloat)vertLayoutHeight
- (CGFloat)fVertLayoutHeight
{
return NSHeight(self.fTransferView.frame) + NSHeight(self.fDatesView.frame) + (2 * kStackViewInset) + kStackViewVerticalSpacing;
}
- (CGFloat)changeInWindowHeight
- (CGFloat)fHeightChange
{
CGFloat difference = 0;
if (NSWidth(self.view.window.frame) >= self.horizLayoutWidth + 1)
{
self.fActivityStackView.orientation = NSUserInterfaceLayoutOrientationHorizontal;
//add some padding between views in horizontal layout
self.fActivityStackView.spacing = kStackViewHorizontalSpacing;
difference = NSHeight(self.view.frame) - self.horizLayoutHeight;
}
else
{
self.fActivityStackView.orientation = NSUserInterfaceLayoutOrientationVertical;
self.fActivityStackView.spacing = kStackViewVerticalSpacing;
difference = NSHeight(self.view.frame) - self.vertLayoutHeight;
}
return difference;
return self.oldHeight - self.fCurrentHeight;
}
- (NSRect)viewRect
{
CGFloat difference = self.changeInWindowHeight;
CGFloat difference = self.fHeightChange;
NSRect windowRect = self.view.window.frame, viewRect = self.view.frame;
NSRect windowRect = self.view.window.frame;
NSRect viewRect = self.view.frame;
if (difference != 0)
{
viewRect.size.height -= difference;
@ -218,12 +109,44 @@ static CGFloat const kStackViewVerticalSpacing = 8.0;
return viewRect;
}
- (void)checkLayout
{
if (NSWidth(self.view.window.frame) >= self.fHorizLayoutWidth + 1)
{
self.fActivityStackView.orientation = NSUserInterfaceLayoutOrientationHorizontal;
//add some padding between views in horizontal layout
self.fActivityStackView.spacing = kStackViewHorizontalSpacing;
self.fCurrentHeight = self.fHorizLayoutHeight;
}
else
{
self.fActivityStackView.orientation = NSUserInterfaceLayoutOrientationVertical;
self.fActivityStackView.spacing = kStackViewVerticalSpacing;
self.fCurrentHeight = self.fVertLayoutHeight;
}
}
- (void)checkWindowSize
{
self.oldHeight = self.fCurrentHeight;
[self checkLayout];
if (self.oldHeight != self.fCurrentHeight)
{
[self updateWindowLayout];
}
}
- (void)updateWindowLayout
{
CGFloat difference = self.changeInWindowHeight;
if (difference != 0)
if (self.fCurrentHeight != 0)
{
[self checkLayout];
CGFloat difference = self.fHeightChange;
NSRect windowRect = self.view.window.frame;
windowRect.origin.y += difference;
windowRect.size.height -= difference;
@ -257,7 +180,11 @@ static CGFloat const kStackViewVerticalSpacing = 8.0;
return;
}
uint64_t have = 0, haveVerified = 0, downloadedTotal = 0, uploadedTotal = 0, failedHash = 0;
uint64_t have = 0;
uint64_t haveVerified = 0;
uint64_t downloadedTotal = 0;
uint64_t uploadedTotal = 0;
uint64_t failedHash = 0;
NSDate* lastActivity = nil;
for (Torrent* torrent in self.fTorrents)
{

View File

@ -23,18 +23,6 @@
@property(nonatomic) IBOutlet NSButton* fRevealDataButton;
//remove when we switch to auto layout
@property(nonatomic) IBOutlet NSTextField* fPiecesLabel;
@property(nonatomic) IBOutlet NSTextField* fHashLabel;
@property(nonatomic) IBOutlet NSTextField* fSecureLabel;
@property(nonatomic) IBOutlet NSTextField* fCreatorLabel;
@property(nonatomic) IBOutlet NSTextField* fDateCreatedLabel;
@property(nonatomic) IBOutlet NSTextField* fCommentLabel;
@property(nonatomic) IBOutlet NSTextField* fDataLocationLabel;
@property(nonatomic) IBOutlet NSTextField* fInfoSectionLabel;
@property(nonatomic) IBOutlet NSTextField* fWhereSectionLabel;
@property(nonatomic) IBOutlet NSScrollView* fCommentScrollView;
@end
@implementation InfoGeneralViewController
@ -49,67 +37,6 @@
return self;
}
- (void)awakeFromNib
{
#warning remove when switching to auto layout
[self.fInfoSectionLabel sizeToFit];
[self.fWhereSectionLabel sizeToFit];
NSArray* labels = @[
self.fPiecesLabel,
self.fHashLabel,
self.fSecureLabel,
self.fCreatorLabel,
self.fDateCreatedLabel,
self.fCommentLabel,
self.fDataLocationLabel,
];
CGFloat oldMaxWidth = 0.0, originX = 0.0, newMaxWidth = 0.0;
for (NSTextField* label in labels)
{
NSRect const oldFrame = label.frame;
if (oldFrame.size.width > oldMaxWidth)
{
oldMaxWidth = oldFrame.size.width;
originX = oldFrame.origin.x;
}
[label sizeToFit];
CGFloat const newWidth = label.bounds.size.width;
if (newWidth > newMaxWidth)
{
newMaxWidth = newWidth;
}
}
for (NSTextField* label in labels)
{
NSRect frame = label.frame;
frame.origin.x = originX + (newMaxWidth - frame.size.width);
label.frame = frame;
}
NSArray* fields = @[
self.fPiecesField,
self.fHashField,
self.fSecureField,
self.fCreatorField,
self.fDateCreatedField,
self.fCommentScrollView,
self.fDataLocationField,
];
CGFloat const widthIncrease = newMaxWidth - oldMaxWidth;
for (NSView* field in fields)
{
NSRect frame = field.frame;
frame.origin.x += widthIncrease;
frame.size.width -= widthIncrease;
field.frame = frame;
}
}
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents
{
//don't check if it's the same in case the metadata changed

View File

@ -9,6 +9,8 @@
@interface InfoOptionsViewController : NSViewController<InfoViewController>
- (NSRect)viewRect;
- (void)checkLayout;
- (void)checkWindowSize;
- (void)updateWindowLayout;
- (void)setInfoForTorrents:(NSArray<Torrent*>*)torrents;
@ -32,5 +34,6 @@
- (IBAction)setPeersConnectLimit:(id)sender;
@property(nonatomic) IBOutlet NSView* fPriorityView;
@property(nonatomic) CGFloat oldHeight;
@end

View File

@ -48,24 +48,15 @@ static CGFloat const kStackViewSpacing = 8.0;
@property(nonatomic) IBOutlet NSTextField* fPeersConnectLabel;
@property(nonatomic) IBOutlet NSTextField* fPeersConnectField;
//remove when we switch to auto layout
@property(nonatomic) IBOutlet NSTextField* fTransferBandwidthSectionLabel;
@property(nonatomic) IBOutlet NSTextField* fPrioritySectionLabel;
@property(nonatomic) IBOutlet NSTextField* fPriorityLabel;
@property(nonatomic) IBOutlet NSTextField* fSeedingLimitsSectionLabel;
@property(nonatomic) IBOutlet NSTextField* fRatioLabel;
@property(nonatomic) IBOutlet NSTextField* fInactivityLabel;
@property(nonatomic) IBOutlet NSTextField* fAdvancedSectionLabel;
@property(nonatomic) IBOutlet NSTextField* fMaxConnectionsLabel;
@property(nonatomic, copy) NSString* fInitialString;
@property(nonatomic) IBOutlet NSStackView* fOptionsStackView;
@property(nonatomic) IBOutlet NSView* fSeedingView;
@property(nonatomic, readonly) CGFloat currentHeight;
@property(nonatomic, readonly) CGFloat horizLayoutHeight;
@property(nonatomic, readonly) CGFloat horizLayoutWidth;
@property(nonatomic, readonly) CGFloat vertLayoutHeight;
@property(nonatomic, readwrite) CGFloat fHeightChange;
@property(nonatomic, readwrite) CGFloat fCurrentHeight;
@property(nonatomic, readonly) CGFloat fHorizLayoutHeight;
@property(nonatomic, readonly) CGFloat fHorizLayoutWidth;
@property(nonatomic, readonly) CGFloat fVertLayoutHeight;
@end
@ -83,6 +74,8 @@ static CGFloat const kStackViewSpacing = 8.0;
- (void)awakeFromNib
{
[self checkWindowSize];
[self setGlobalLabels];
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(setGlobalLabels) name:@"UpdateGlobalOptions" object:nil];
@ -96,47 +89,29 @@ static CGFloat const kStackViewSpacing = 8.0;
[NSNotificationCenter.defaultCenter removeObserver:self];
}
- (CGFloat)currentHeight
{
return NSHeight(self.view.frame);
}
- (CGFloat)horizLayoutHeight
- (CGFloat)fHorizLayoutHeight
{
return NSHeight(self.fPriorityView.frame) + 2 * kStackViewInset;
}
- (CGFloat)horizLayoutWidth
- (CGFloat)fHorizLayoutWidth
{
return NSWidth(self.fPriorityView.frame) + NSWidth(self.fSeedingView.frame) + (2 * kStackViewInset) + kStackViewSpacing;
}
- (CGFloat)vertLayoutHeight
- (CGFloat)fVertLayoutHeight
{
return NSHeight(self.fPriorityView.frame) + NSHeight(self.fSeedingView.frame) + (2 * kStackViewInset) + kStackViewSpacing;
}
- (CGFloat)changeInWindowHeight
- (CGFloat)fHeightChange
{
CGFloat difference = 0;
if (NSWidth(self.view.window.frame) >= self.horizLayoutWidth + 1)
{
self.fOptionsStackView.orientation = NSUserInterfaceLayoutOrientationHorizontal;
difference = NSHeight(self.view.frame) - self.horizLayoutHeight;
}
else
{
self.fOptionsStackView.orientation = NSUserInterfaceLayoutOrientationVertical;
difference = NSHeight(self.view.frame) - self.vertLayoutHeight;
}
return difference;
return self.oldHeight - self.fCurrentHeight;
}
- (NSRect)viewRect
{
CGFloat difference = self.changeInWindowHeight;
CGFloat difference = self.fHeightChange;
NSRect windowRect = self.view.window.frame, viewRect = self.view.frame;
if (difference != 0)
@ -148,12 +123,40 @@ static CGFloat const kStackViewSpacing = 8.0;
return viewRect;
}
- (void)checkLayout
{
if (NSWidth(self.view.window.frame) >= self.fHorizLayoutWidth + 1)
{
self.fOptionsStackView.orientation = NSUserInterfaceLayoutOrientationHorizontal;
self.fCurrentHeight = self.fHorizLayoutHeight;
}
else
{
self.fOptionsStackView.orientation = NSUserInterfaceLayoutOrientationVertical;
self.fCurrentHeight = self.fVertLayoutHeight;
}
}
- (void)checkWindowSize
{
self.oldHeight = self.fCurrentHeight;
[self checkLayout];
if (self.oldHeight != self.fCurrentHeight)
{
[self updateWindowLayout];
}
}
- (void)updateWindowLayout
{
CGFloat difference = self.changeInWindowHeight;
if (difference != 0)
if (self.fCurrentHeight != 0)
{
[self checkLayout];
CGFloat difference = self.fHeightChange;
NSRect windowRect = self.view.window.frame;
windowRect.origin.y += difference;
windowRect.size.height -= difference;

View File

@ -183,11 +183,11 @@ typedef NS_ENUM(unsigned int, tabTag) {
{
if (self.fViewController == self.fOptionsViewController)
{
[self.fOptionsViewController updateWindowLayout];
[self.fOptionsViewController checkWindowSize];
}
else if (self.fViewController == self.fActivityViewController)
{
[self.fActivityViewController updateWindowLayout];
[self.fActivityViewController checkWindowSize];
}
}
@ -337,11 +337,17 @@ typedef NS_ENUM(unsigned int, tabTag) {
//special case for Activity and Options views
if (self.fViewController == self.fActivityViewController)
{
[self.fActivityViewController setOldHeight:oldHeight];
[self.fActivityViewController checkLayout];
minWindowWidth = MAX(self.fMinWindowWidth, self.fActivityViewController.fTransferView.frame.size.width);
viewRect = [self.fActivityViewController viewRect];
}
else if (self.fViewController == self.fOptionsViewController)
{
[self.fOptionsViewController setOldHeight:oldHeight];
[self.fOptionsViewController checkLayout];
minWindowWidth = MAX(self.fMinWindowWidth, self.fOptionsViewController.fPriorityView.frame.size.width);
viewRect = [self.fOptionsViewController viewRect];
}