diff --git a/macosx/Base.lproj/InfoActivityView.xib b/macosx/Base.lproj/InfoActivityView.xib
index 5eb31e56b..b99d3da3a 100644
--- a/macosx/Base.lproj/InfoActivityView.xib
+++ b/macosx/Base.lproj/InfoActivityView.xib
@@ -10,38 +10,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -227,7 +210,7 @@
-
+
@@ -447,7 +430,7 @@
-
+
diff --git a/macosx/Base.lproj/InfoGeneralView.xib b/macosx/Base.lproj/InfoGeneralView.xib
index 29f7bce25..cb44d3038 100644
--- a/macosx/Base.lproj/InfoGeneralView.xib
+++ b/macosx/Base.lproj/InfoGeneralView.xib
@@ -8,24 +8,14 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/macosx/Base.lproj/InfoOptionsView.xib b/macosx/Base.lproj/InfoOptionsView.xib
index 01743f9e7..f678b0073 100644
--- a/macosx/Base.lproj/InfoOptionsView.xib
+++ b/macosx/Base.lproj/InfoOptionsView.xib
@@ -8,7 +8,6 @@
-
@@ -17,23 +16,16 @@
-
-
-
-
-
-
-
@@ -111,7 +103,7 @@
-
+
@@ -230,7 +222,7 @@
-
+
@@ -273,7 +265,7 @@
-
+
diff --git a/macosx/InfoActivityViewController.h b/macosx/InfoActivityViewController.h
index c85026ba5..804cc760c 100644
--- a/macosx/InfoActivityViewController.h
+++ b/macosx/InfoActivityViewController.h
@@ -9,6 +9,8 @@
@interface InfoActivityViewController : NSViewController
- (NSRect)viewRect;
+- (void)checkLayout;
+- (void)checkWindowSize;
- (void)updateWindowLayout;
- (void)setInfoForTorrents:(NSArray*)torrents;
@@ -19,5 +21,6 @@
- (void)clearView;
@property(nonatomic) IBOutlet NSView* fTransferView;
+@property(nonatomic) CGFloat oldHeight;
@end
diff --git a/macosx/InfoActivityViewController.mm b/macosx/InfoActivityViewController.mm
index 49b8567f6..c3d2b9ff2 100644
--- a/macosx/InfoActivityViewController.mm
+++ b/macosx/InfoActivityViewController.mm
@@ -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)
{
diff --git a/macosx/InfoGeneralViewController.mm b/macosx/InfoGeneralViewController.mm
index d1385255e..4e729929d 100644
--- a/macosx/InfoGeneralViewController.mm
+++ b/macosx/InfoGeneralViewController.mm
@@ -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*)torrents
{
//don't check if it's the same in case the metadata changed
diff --git a/macosx/InfoOptionsViewController.h b/macosx/InfoOptionsViewController.h
index 4dea408e3..c679f4eff 100644
--- a/macosx/InfoOptionsViewController.h
+++ b/macosx/InfoOptionsViewController.h
@@ -9,6 +9,8 @@
@interface InfoOptionsViewController : NSViewController
- (NSRect)viewRect;
+- (void)checkLayout;
+- (void)checkWindowSize;
- (void)updateWindowLayout;
- (void)setInfoForTorrents:(NSArray*)torrents;
@@ -32,5 +34,6 @@
- (IBAction)setPeersConnectLimit:(id)sender;
@property(nonatomic) IBOutlet NSView* fPriorityView;
+@property(nonatomic) CGFloat oldHeight;
@end
diff --git a/macosx/InfoOptionsViewController.mm b/macosx/InfoOptionsViewController.mm
index 6f940c2b2..47ecea1b9 100644
--- a/macosx/InfoOptionsViewController.mm
+++ b/macosx/InfoOptionsViewController.mm
@@ -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;
diff --git a/macosx/InfoWindowController.mm b/macosx/InfoWindowController.mm
index f0884594d..688a0dcb4 100644
--- a/macosx/InfoWindowController.mm
+++ b/macosx/InfoWindowController.mm
@@ -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];
}