]> granicus.if.org Git - transmission/commitdiff
Fix constraints issues on Yosemite when hiding web seed view (OS X)
authorMike Gelfand <mikedld@mikedld.com>
Thu, 3 Mar 2016 22:27:45 +0000 (22:27 +0000)
committerMike Gelfand <mikedld@mikedld.com>
Thu, 3 Mar 2016 22:27:45 +0000 (22:27 +0000)
macosx/InfoPeersView.xib
macosx/InfoPeersViewController.h
macosx/InfoPeersViewController.m

index c2bbd79913fb19c11cca1cddb78731c349e85a19..bcb323ae4d1ccde910291ec2686673186522edd1 100644 (file)
@@ -9,9 +9,8 @@
             <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>
@@ -212,14 +211,16 @@ Multiline Label</string>
                 </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>
index a66fdd61d238e155a201f12084e8c4a3360c11b0..3b74a5a05b5f9cc3b1be0fc486023518b7ca60c6 100644 (file)
     
     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;
index 861423affb961a41617eb93022b9442c41c11bf4..3580910a6565f4c6826d8d76d4a8744eb9c0a32f 100644 (file)
@@ -32,6 +32,9 @@
 #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