<connections>
<outlet property="fConnectedPeersField" destination="3" id="31"/>
<outlet property="fPeerTable" destination="9" id="37"/>
- <outlet property="fPeerTableTopConstraint" destination="1HX-la-u47" id="zd4-80-4DZ"/>
<outlet property="fWebSeedTable" destination="22" id="38"/>
- <outlet property="fWebSeedTableHeightConstraint" destination="4th-jd-ByN" id="hUk-mR-d0k"/>
+ <outlet property="fWebSeedTableTopConstraint" destination="IMm-aI-A03" id="3qg-eC-YGm"/>
<outlet property="view" destination="2" id="32"/>
</connections>
</customObject>
</textField>
</subviews>
<constraints>
- <constraint firstItem="5" firstAttribute="top" secondItem="4" secondAttribute="bottom" constant="4" id="1HX-la-u47"/>
+ <constraint firstItem="5" firstAttribute="top" secondItem="4" secondAttribute="bottom" priority="998" constant="4" id="1HX-la-u47"/>
<constraint firstItem="4" firstAttribute="leading" secondItem="2" secondAttribute="leading" constant="12" id="5f9-U1-5ZR"/>
<constraint firstItem="3" firstAttribute="leading" secondItem="2" secondAttribute="leading" constant="12" id="7lL-BM-0yj"/>
<constraint firstItem="4" firstAttribute="top" secondItem="2" secondAttribute="top" constant="12" id="IMm-aI-A03"/>
<constraint firstAttribute="trailing" secondItem="3" secondAttribute="trailing" constant="12" id="PfO-Qp-6s2"/>
<constraint firstAttribute="bottom" secondItem="3" secondAttribute="bottom" constant="12" id="R8j-Z7-6VA"/>
- <constraint firstItem="3" firstAttribute="top" secondItem="5" secondAttribute="bottom" constant="4" id="ksH-yX-eMF"/>
+ <constraint firstItem="3" firstAttribute="top" secondItem="5" secondAttribute="bottom" priority="998" constant="4" id="ksH-yX-eMF"/>
<constraint firstItem="5" firstAttribute="leading" secondItem="2" secondAttribute="leading" constant="12" id="lcP-Pq-CY0"/>
+ <constraint firstItem="5" firstAttribute="top" relation="greaterThanOrEqual" secondItem="4" secondAttribute="bottom" constant="4" id="pIJ-b4-EP1"/>
+ <constraint firstItem="5" firstAttribute="top" secondItem="2" secondAttribute="top" priority="999" constant="12" id="t9u-iC-TTZ"/>
<constraint firstAttribute="trailing" secondItem="5" secondAttribute="trailing" constant="12" id="tCQ-be-4sj"/>
<constraint firstAttribute="trailing" secondItem="4" secondAttribute="trailing" constant="12" id="zRK-YF-yfr"/>
</constraints>
IBOutlet NSTableView * fPeerTable;
IBOutlet WebSeedTableView * fWebSeedTable;
- CGFloat fWebSeedTableHeight, fSpaceBetweenWebSeedAndPeer;
IBOutlet NSTextField * fConnectedPeersField;
- IBOutlet NSLayoutConstraint * fWebSeedTableHeightConstraint;
- IBOutlet NSLayoutConstraint * fPeerTableTopConstraint;
+ CGFloat fViewTopMargin;
+ IBOutlet NSLayoutConstraint * fWebSeedTableTopConstraint;
}
- (void) setInfoForTorrents: (NSArray *) torrents;
#import "transmission.h" // required by utils.h
#import "utils.h"
+#define ANIMATION_ID_KEY @"animationId"
+#define WEB_SEED_ANIMATION_ID @"webSeed"
+
@interface InfoPeersViewController (Private)
- (void) setupInfo;
"inspector -> web seed table -> header tool tip")];
//prepare for animating peer table and web seed table
- NSRect webSeedTableFrame = [[fWebSeedTable enclosingScrollView] frame];
- fWebSeedTableHeight = webSeedTableFrame.size.height;
- fSpaceBetweenWebSeedAndPeer = webSeedTableFrame.origin.y - NSMaxY([[fPeerTable enclosingScrollView] frame]);
+ fViewTopMargin = fWebSeedTableTopConstraint.constant;
CABasicAnimation * webSeedTableAnimation = [CABasicAnimation animation];
- webSeedTableAnimation.timingFunction = [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear];
- webSeedTableAnimation.duration = 0.125;
- [fWebSeedTableHeightConstraint setAnimations: [NSDictionary dictionaryWithObject: webSeedTableAnimation
- forKey: @"constant"]];
- [fPeerTableTopConstraint setAnimations: [NSDictionary dictionaryWithObject: webSeedTableAnimation
- forKey: @"constant"]];
-
+ [webSeedTableAnimation setTimingFunction: [CAMediaTimingFunction functionWithName: kCAMediaTimingFunctionLinear]];
+ [webSeedTableAnimation setDuration: 0.125];
+ [webSeedTableAnimation setDelegate: self];
+ [webSeedTableAnimation setValue: WEB_SEED_ANIMATION_ID forKey: ANIMATION_ID_KEY];
+ [fWebSeedTableTopConstraint setAnimations: @{ @"constant": webSeedTableAnimation }];
+
[self setWebSeedTableHidden: YES animate: NO];
}
return nil;
}
+- (void) animationDidStart: (CAAnimation *) animation
+{
+ if (![[animation valueForKey: ANIMATION_ID_KEY] isEqualToString: WEB_SEED_ANIMATION_ID])
+ return;
+
+ [[fWebSeedTable enclosingScrollView] setHidden: NO];
+}
+
+- (void) animationDidStop: (CAAnimation *) animation finished: (BOOL) finished
+{
+ if (![[animation valueForKey: ANIMATION_ID_KEY] isEqualToString: WEB_SEED_ANIMATION_ID])
+ return;
+
+ [[fWebSeedTable enclosingScrollView] setHidden: finished && fWebSeedTableTopConstraint.constant < 0];
+}
+
@end
@implementation InfoPeersViewController (Private)
if (animate && (![[self view] window] || ![[[self view] window] isVisible]))
animate = NO;
- const CGFloat webSeedTableHeight = hide ? 1 : fWebSeedTableHeight;
- const CGFloat spaceBetweenWebSeedAndPeer = hide ? -2 : fSpaceBetweenWebSeedAndPeer;
+ const CGFloat webSeedTableTopMargin = hide ? -NSHeight([[fWebSeedTable enclosingScrollView] frame]) : fViewTopMargin;
- [(animate ? [fWebSeedTableHeightConstraint animator] : fWebSeedTableHeightConstraint) setConstant: webSeedTableHeight];
- [(animate ? [fPeerTableTopConstraint animator] : fPeerTableTopConstraint) setConstant: spaceBetweenWebSeedAndPeer];
-
- [[fWebSeedTable enclosingScrollView] setHidden: hide];
+ [(animate ? [fWebSeedTableTopConstraint animator] : fWebSeedTableTopConstraint) setConstant: webSeedTableTopMargin];
}
- (NSArray *) peerSortDescriptors