[vlc-commits] macosx: Fix animation of prev / next buttons
David Fuhrmann
git at videolan.org
Sat Jul 1 12:58:35 CEST 2017
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat Jul 1 12:01:26 2017 +0200| [fa94ead8f4f45872c6b6ad5f828adea0a28eff62] | committer: David Fuhrmann
macosx: Fix animation of prev / next buttons
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fa94ead8f4f45872c6b6ad5f828adea0a28eff62
---
modules/gui/macosx/UI/MainWindow.xib | 4 ++
modules/gui/macosx/VLCMainWindowControlsBar.h | 2 +
modules/gui/macosx/VLCMainWindowControlsBar.m | 77 ++++++++++++---------------
3 files changed, 39 insertions(+), 44 deletions(-)
diff --git a/modules/gui/macosx/UI/MainWindow.xib b/modules/gui/macosx/UI/MainWindow.xib
index a022c51372..67b8d1c5e0 100644
--- a/modules/gui/macosx/UI/MainWindow.xib
+++ b/modules/gui/macosx/UI/MainWindow.xib
@@ -450,6 +450,7 @@
<button translatesAutoresizingMaskIntoConstraints="NO" id="qfh-30-nky" userLabel="Previous Button">
<rect key="frame" x="0.0" y="0.0" width="29" height="23"/>
<constraints>
+ <constraint firstAttribute="width" constant="29" id="bP7-Ec-OLG"/>
<constraint firstAttribute="height" constant="23" id="bsS-LC-mxp"/>
</constraints>
<buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="previous-6btns" imagePosition="only" alignment="center" alternateImage="previous-6btns-pressed" continuous="YES" enabled="NO" id="KXm-ys-zEA">
@@ -503,6 +504,7 @@
<rect key="frame" x="112" y="0.0" width="29" height="23"/>
<constraints>
<constraint firstAttribute="height" constant="23" id="Icc-CC-PIU"/>
+ <constraint firstAttribute="width" constant="29" id="uPv-u5-I21"/>
</constraints>
<buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="next-6btns" imagePosition="only" alignment="center" alternateImage="next-6btns-pressed" continuous="YES" enabled="NO" id="tLR-jN-43M">
<behavior key="behavior" lightByContents="YES"/>
@@ -848,9 +850,11 @@
<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"/>
+ <outlet property="nextButtonWidthConstraint" destination="uPv-u5-I21" id="Lsk-Nu-vmn"/>
<outlet property="playButton" destination="3571" id="5Mf-48-Ga9"/>
<outlet property="playlistButton" destination="4671" id="AZd-5b-MrA"/>
<outlet property="prevButton" destination="qfh-30-nky" id="uN2-nC-7Mt"/>
+ <outlet property="prevButtonWidthConstraint" destination="bP7-Ec-OLG" id="qs4-ok-Ual"/>
<outlet property="progressBar" destination="3584" id="d57-az-Grm"/>
<outlet property="progressView" destination="5335" id="dBT-U1-rmL"/>
<outlet property="repeatButton" destination="2789" id="lRj-JN-Yry"/>
diff --git a/modules/gui/macosx/VLCMainWindowControlsBar.h b/modules/gui/macosx/VLCMainWindowControlsBar.h
index cdd3327837..f78dc26196 100644
--- a/modules/gui/macosx/VLCMainWindowControlsBar.h
+++ b/modules/gui/macosx/VLCMainWindowControlsBar.h
@@ -37,7 +37,9 @@
@property (readwrite, strong) IBOutlet NSButton *stopButton;
@property (readwrite, strong) IBOutlet NSButton *prevButton;
+ at property (readwrite, strong) IBOutlet NSLayoutConstraint *prevButtonWidthConstraint;
@property (readwrite, strong) IBOutlet NSButton *nextButton;
+ at property (readwrite, strong) IBOutlet NSLayoutConstraint *nextButtonWidthConstraint;
@property (readwrite, strong) IBOutlet NSButton *playlistButton;
@property (readwrite, strong) IBOutlet NSButton *repeatButton;
diff --git a/modules/gui/macosx/VLCMainWindowControlsBar.m b/modules/gui/macosx/VLCMainWindowControlsBar.m
index b0818eb13f..f76c567331 100644
--- a/modules/gui/macosx/VLCMainWindowControlsBar.m
+++ b/modules/gui/macosx/VLCMainWindowControlsBar.m
@@ -56,8 +56,6 @@
NSLayoutConstraint *_hideNextButtonConstraint;
}
-- (void)addJumpButtons:(BOOL)b_fast;
-- (void)removeJumpButtons:(BOOL)b_fast;
- (void)addPlaymodeButtons:(BOOL)withAnimation;
- (void)removePlaymodeButtons:(BOOL)withAnimation;
@@ -200,23 +198,9 @@
if (!b_show_playmode_buttons)
[self removePlaymodeButtons:NO];
- _hidePrevButtonConstraint = [NSLayoutConstraint constraintWithItem:self.prevButton
- attribute:NSLayoutAttributeWidth
- relatedBy:NSLayoutRelationEqual
- toItem:nil
- attribute:NSLayoutAttributeNotAnAttribute
- multiplier:1
- constant:0];
- _hideNextButtonConstraint = [NSLayoutConstraint constraintWithItem:self.nextButton
- attribute:NSLayoutAttributeWidth
- relatedBy:NSLayoutRelationEqual
- toItem:nil
- attribute:NSLayoutAttributeNotAnAttribute
- multiplier:1
- constant:0];
b_show_jump_buttons = var_InheritBool(getIntf(), "macosx-show-playback-buttons");
if (!b_show_jump_buttons)
- [self removeJumpButtons:YES];
+ [self removeJumpButtons:NO];
[[[VLCMain sharedInstance] playlist] playbackModeUpdated];
@@ -291,50 +275,55 @@
b_show_jump_buttons = config_GetInt(getIntf(), "macosx-show-playback-buttons");
if (b_show_jump_buttons)
- [self addJumpButtons:NO];
+ [self addJumpButtons:YES];
else
- [self removeJumpButtons:NO];
+ [self removeJumpButtons:YES];
}
-- (void)addJumpButtons:(BOOL)b_fast
+- (void)addJumpButtons:(BOOL)withAnimation
{
- [self.prevButton removeConstraint:_hidePrevButtonConstraint];
- [self.nextButton removeConstraint:_hideNextButtonConstraint];
+ [NSAnimationContext beginGrouping];
+ [self showButtonWithConstraint:self.prevButtonWidthConstraint animation:withAnimation];
+ [self showButtonWithConstraint:self.nextButtonWidthConstraint animation:withAnimation];
+ id backwardButton = withAnimation ? self.backwardButton.animator : self.backwardButton;
+ id forwardButton = withAnimation ? self.forwardButton.animator : self.forwardButton;
if (self.darkInterface) {
- [[self.forwardButton animator] setImage:imageFromRes(@"forward-6btns-dark")];
- [[self.forwardButton animator] setAlternateImage:imageFromRes(@"forward-6btns-dark-pressed")];
- [[self.backwardButton animator] setImage:imageFromRes(@"backward-6btns-dark")];
- [[self.backwardButton animator] setAlternateImage:imageFromRes(@"backward-6btns-dark-pressed")];
+ [forwardButton setImage:imageFromRes(@"forward-6btns-dark")];
+ [forwardButton setAlternateImage:imageFromRes(@"forward-6btns-dark-pressed")];
+ [backwardButton setImage:imageFromRes(@"backward-6btns-dark")];
+ [backwardButton setAlternateImage:imageFromRes(@"backward-6btns-dark-pressed")];
} else {
- [[self.forwardButton animator] setImage:imageFromRes(@"forward-6btns")];
- [[self.forwardButton animator] setAlternateImage:imageFromRes(@"forward-6btns-pressed")];
- [[self.backwardButton animator] setImage:imageFromRes(@"backward-6btns")];
- [[self.backwardButton animator] setAlternateImage:imageFromRes(@"backward-6btns-pressed")];
+ [forwardButton setImage:imageFromRes(@"forward-6btns")];
+ [forwardButton setAlternateImage:imageFromRes(@"forward-6btns-pressed")];
+ [backwardButton setImage:imageFromRes(@"backward-6btns")];
+ [backwardButton setAlternateImage:imageFromRes(@"backward-6btns-pressed")];
}
+ [NSAnimationContext endGrouping];
[self toggleForwardBackwardMode: YES];
}
-- (void)removeJumpButtons:(BOOL)b_fast
+- (void)removeJumpButtons:(BOOL)withAnimation
{
- if (!self.prevButton || !self.nextButton)
- return;
-
- [self.prevButton addConstraint:_hidePrevButtonConstraint];
- [self.nextButton addConstraint:_hideNextButtonConstraint];
+ [NSAnimationContext beginGrouping];
+ [self hideButtonWithConstraint:self.prevButtonWidthConstraint animation:withAnimation];
+ [self hideButtonWithConstraint:self.nextButtonWidthConstraint animation:withAnimation];
+ id backwardButton = withAnimation ? self.backwardButton.animator : self.backwardButton;
+ id forwardButton = withAnimation ? self.forwardButton.animator : self.forwardButton;
if (self.darkInterface) {
- [[self.forwardButton animator] setImage:imageFromRes(@"forward-3btns-dark")];
- [[self.forwardButton animator] setAlternateImage:imageFromRes(@"forward-3btns-dark-pressed")];
- [[self.backwardButton animator] setImage:imageFromRes(@"backward-3btns-dark")];
- [[self.backwardButton animator] setAlternateImage:imageFromRes(@"backward-3btns-dark-pressed")];
+ [forwardButton setImage:imageFromRes(@"forward-3btns-dark")];
+ [forwardButton setAlternateImage:imageFromRes(@"forward-3btns-dark-pressed")];
+ [backwardButton setImage:imageFromRes(@"backward-3btns-dark")];
+ [backwardButton setAlternateImage:imageFromRes(@"backward-3btns-dark-pressed")];
} else {
- [[self.forwardButton animator] setImage:imageFromRes(@"forward-3btns")];
- [[self.forwardButton animator] setAlternateImage:imageFromRes(@"forward-3btns-pressed")];
- [[self.backwardButton animator] setImage:imageFromRes(@"backward-3btns")];
- [[self.backwardButton animator] setAlternateImage:imageFromRes(@"backward-3btns-pressed")];
+ [forwardButton setImage:imageFromRes(@"forward-3btns")];
+ [forwardButton setAlternateImage:imageFromRes(@"forward-3btns-pressed")];
+ [backwardButton setImage:imageFromRes(@"backward-3btns")];
+ [backwardButton setAlternateImage:imageFromRes(@"backward-3btns-pressed")];
}
+ [NSAnimationContext endGrouping];
[self toggleForwardBackwardMode: NO];
}
More information about the vlc-commits
mailing list