[vlc-commits] macosx: Fix animation for effects button

David Fuhrmann git at videolan.org
Sat Jul 1 12:58:31 CEST 2017


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat Jul  1 11:52:49 2017 +0200| [c8860f05458bea967badc00ebd55b74c7f6f81b2] | committer: David Fuhrmann

macosx: Fix animation for effects button

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c8860f05458bea967badc00ebd55b74c7f6f81b2
---

 modules/gui/macosx/UI/MainWindow.xib          |  2 +
 modules/gui/macosx/VLCMainWindowControlsBar.h |  1 +
 modules/gui/macosx/VLCMainWindowControlsBar.m | 53 +++++++++++----------------
 3 files changed, 24 insertions(+), 32 deletions(-)

diff --git a/modules/gui/macosx/UI/MainWindow.xib b/modules/gui/macosx/UI/MainWindow.xib
index 6b401e5ebf..a022c51372 100644
--- a/modules/gui/macosx/UI/MainWindow.xib
+++ b/modules/gui/macosx/UI/MainWindow.xib
@@ -704,6 +704,7 @@
                                             <button translatesAutoresizingMaskIntoConstraints="NO" id="3654">
                                                 <rect key="frame" x="0.0" y="0.0" width="29" height="23"/>
                                                 <constraints>
+                                                    <constraint firstAttribute="width" constant="29" id="cE9-ym-9VP"/>
                                                     <constraint firstAttribute="height" constant="23" id="eNr-1j-DKO"/>
                                                 </constraints>
                                                 <buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="effects-double-buttons" imagePosition="only" alignment="center" alternateImage="effects-double-buttons-pressed" id="4281">
@@ -843,6 +844,7 @@
                 <outlet property="bottomBarView" destination="4756" id="5621"/>
                 <outlet property="dropView" destination="5608" id="zUe-aW-9EY"/>
                 <outlet property="effectsButton" destination="3654" id="VfE-Hs-5Ni"/>
+                <outlet property="effectsButtonWidthConstraint" destination="cE9-ym-9VP" id="ZQQ-m6-t7W"/>
                 <outlet property="forwardButton" destination="3648" id="0bA-YS-tkr"/>
                 <outlet property="fullscreenButton" destination="4419" id="hgS-Tk-jle"/>
                 <outlet property="nextButton" destination="HBS-xq-EkN" id="MIO-Ba-jDH"/>
diff --git a/modules/gui/macosx/VLCMainWindowControlsBar.h b/modules/gui/macosx/VLCMainWindowControlsBar.h
index e3134d49c1..cdd3327837 100644
--- a/modules/gui/macosx/VLCMainWindowControlsBar.h
+++ b/modules/gui/macosx/VLCMainWindowControlsBar.h
@@ -52,6 +52,7 @@
 @property (readwrite, strong) IBOutlet NSButton *volumeUpButton;
 
 @property (readwrite, strong) IBOutlet NSButton *effectsButton;
+ at property (readwrite, strong) IBOutlet NSLayoutConstraint *effectsButtonWidthConstraint;
 
 - (IBAction)stop:(id)sender;
 
diff --git a/modules/gui/macosx/VLCMainWindowControlsBar.m b/modules/gui/macosx/VLCMainWindowControlsBar.m
index 08c41e43f4..b0818eb13f 100644
--- a/modules/gui/macosx/VLCMainWindowControlsBar.m
+++ b/modules/gui/macosx/VLCMainWindowControlsBar.m
@@ -54,8 +54,6 @@
 
     NSLayoutConstraint *_hidePrevButtonConstraint;
     NSLayoutConstraint *_hideNextButtonConstraint;
-
-    NSLayoutConstraint *_hideEffectsButtonConstraint;
 }
 
 - (void)addJumpButtons:(BOOL)b_fast;
@@ -195,15 +193,8 @@
     [self.volumeUpButton setEnabled: b_mute];
 
     // configure optional buttons
-    _hideEffectsButtonConstraint = [NSLayoutConstraint constraintWithItem:self.effectsButton
-                                                      attribute:NSLayoutAttributeWidth
-                                                      relatedBy:NSLayoutRelationEqual
-                                                         toItem:nil
-                                                      attribute:NSLayoutAttributeNotAnAttribute
-                                                     multiplier:1
-                                                       constant:0];
     if (!var_InheritBool(getIntf(), "macosx-show-effects-button"))
-        [self removeEffectsButton:YES];
+        [self removeEffectsButton:NO];
 
     b_show_playmode_buttons = var_InheritBool(getIntf(), "macosx-show-playmode-buttons");
     if (!b_show_playmode_buttons)
@@ -254,47 +245,45 @@
 - (void)toggleEffectsButton
 {
     if (config_GetInt(getIntf(), "macosx-show-effects-button"))
-        [self addEffectsButton:NO];
+        [self addEffectsButton:YES];
     else
-        [self removeEffectsButton:NO];
+        [self removeEffectsButton:YES];
 }
 
-- (void)addEffectsButton:(BOOL)b_fast
+- (void)addEffectsButton:(BOOL)withAnimation
 {
-    if (!self.effectsButton)
-        return;
-
-    [self.effectsButton removeConstraint:_hideEffectsButtonConstraint];
+    [NSAnimationContext beginGrouping];
+    [self showButtonWithConstraint:self.effectsButtonWidthConstraint animation:withAnimation];
 
+    id button = withAnimation ? self.fullscreenButton.animator : self.fullscreenButton;
     if (!self.nativeFullscreenMode) {
         if (self.darkInterface) {
-            [[self.fullscreenButton animator] setImage: imageFromRes(@"fullscreen-double-buttons_dark")];
-            [[self.fullscreenButton animator] setAlternateImage: imageFromRes(@"fullscreen-double-buttons-pressed_dark")];
+            [button setImage: imageFromRes(@"fullscreen-double-buttons_dark")];
+            [button setAlternateImage: imageFromRes(@"fullscreen-double-buttons-pressed_dark")];
         } else {
-            [[self.fullscreenButton animator] setImage: imageFromRes(@"fullscreen-double-buttons")];
-            [[self.fullscreenButton animator] setAlternateImage: imageFromRes(@"fullscreen-double-buttons-pressed")];
+            [button setImage: imageFromRes(@"fullscreen-double-buttons")];
+            [button setAlternateImage: imageFromRes(@"fullscreen-double-buttons-pressed")];
         }
     }
-
-    [self.bottomBarView setNeedsDisplay:YES];
+    [NSAnimationContext endGrouping];
 }
 
-- (void)removeEffectsButton:(BOOL)b_fast
+- (void)removeEffectsButton:(BOOL)withAnimation
 {
-    if (!self.effectsButton)
-        return;
-
-    [self.effectsButton addConstraint:_hideEffectsButtonConstraint];
+    [NSAnimationContext beginGrouping];
+    [self hideButtonWithConstraint:self.effectsButtonWidthConstraint animation:withAnimation];
 
+    id button = withAnimation ? self.fullscreenButton.animator : self.fullscreenButton;
     if (!self.nativeFullscreenMode) {
         if (self.darkInterface) {
-            [[self.fullscreenButton animator] setImage: imageFromRes(@"fullscreen-one-button_dark")];
-            [[self.fullscreenButton animator] setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed_dark")];
+            [button setImage: imageFromRes(@"fullscreen-one-button_dark")];
+            [button setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed_dark")];
         } else {
-            [[self.fullscreenButton animator] setImage: imageFromRes(@"fullscreen-one-button")];
-            [[self.fullscreenButton animator] setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed")];
+            [button setImage: imageFromRes(@"fullscreen-one-button")];
+            [button setAlternateImage: imageFromRes(@"fullscreen-one-button-pressed")];
         }
     }
+    [NSAnimationContext endGrouping];
 }
 
 - (void)toggleJumpButtons



More information about the vlc-commits mailing list