vlc | branch: master | David Fuhrmann <[email protected]> | Sat Jul 1 11:37:14 2017 +0200| [9615d4c428fe569bb58bc3f449769d5ad8493a9d] | committer: David Fuhrmann
macosx: Fix animations for playmode buttons in controls bar > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9615d4c428fe569bb58bc3f449769d5ad8493a9d --- modules/gui/macosx/UI/MainWindow.xib | 6 ++- modules/gui/macosx/UI/Open.xib | 17 +++--- modules/gui/macosx/VLCMainWindowControlsBar.h | 3 ++ modules/gui/macosx/VLCMainWindowControlsBar.m | 78 ++++++++++++++------------- 4 files changed, 58 insertions(+), 46 deletions(-) diff --git a/modules/gui/macosx/UI/MainWindow.xib b/modules/gui/macosx/UI/MainWindow.xib index f4b2a655b1..6b401e5ebf 100644 --- a/modules/gui/macosx/UI/MainWindow.xib +++ b/modules/gui/macosx/UI/MainWindow.xib @@ -14,7 +14,7 @@ </customObject> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> <customObject id="-3" userLabel="Application" customClass="NSObject"/> - <window title="VLC media player" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" tabbingMode="disallowed" id="21" userLabel="Main Window" customClass="VLCMainWindow"> + <window title="VLC media player" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="" animationBehavior="default" id="21" userLabel="Main Window" customClass="VLCMainWindow"> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" topStrut="YES"/> <rect key="contentRect" x="53" y="419" width="716" height="333"/> @@ -560,6 +560,7 @@ <button translatesAutoresizingMaskIntoConstraints="NO" id="2789"> <rect key="frame" x="28" y="0.0" width="28" height="23"/> <constraints> + <constraint firstAttribute="width" constant="28" id="3Ww-8A-Fh7"/> <constraint firstAttribute="height" constant="23" id="JJL-a1-CWG"/> </constraints> <buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="repeat" imagePosition="only" alignment="center" alternateImage="repeat-pressed" inset="2" id="4316"> @@ -573,6 +574,7 @@ <button translatesAutoresizingMaskIntoConstraints="NO" id="2208"> <rect key="frame" x="56" y="0.0" width="29" height="23"/> <constraints> + <constraint firstAttribute="width" constant="29" id="6Z4-L0-Wzo"/> <constraint firstAttribute="height" constant="23" id="7YJ-zp-9if"/> </constraints> <buttonCell key="cell" type="bevel" bezelStyle="regularSquare" image="shuffle" imagePosition="only" alignment="center" alternateImage="shuffle-pressed" inset="2" id="4313"> @@ -850,7 +852,9 @@ <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"/> + <outlet property="repeatButtonWidthConstraint" destination="3Ww-8A-Fh7" id="i89-fY-S9w"/> <outlet property="shuffleButton" destination="2208" id="kf1-mU-75T"/> + <outlet property="shuffleButtonWidthConstraint" destination="6Z4-L0-Wzo" id="xFz-7x-Vlz"/> <outlet property="stopButton" destination="3647" id="ddx-Gq-iPV"/> <outlet property="timeField" destination="4423" id="Wvo-az-Lou"/> <outlet property="timeSlider" destination="4422" id="I3H-rQ-4GH"/> diff --git a/modules/gui/macosx/UI/Open.xib b/modules/gui/macosx/UI/Open.xib index a1a908d430..4db0d252a4 100644 --- a/modules/gui/macosx/UI/Open.xib +++ b/modules/gui/macosx/UI/Open.xib @@ -1,9 +1,8 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11542" systemVersion="15G1217" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> +<?xml version="1.0" encoding="UTF-8"?> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="16F73" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <dependencies> - <deployment identifier="macosx"/> <development version="7000" identifier="xcode"/> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11542"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/> <capability name="box content view" minToolsVersion="7.0"/> </dependencies> <objects> @@ -148,7 +147,7 @@ <windowStyleMask key="styleMask" titled="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="162" y="354" width="574" height="380"/> - <rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/> + <rect key="screenRect" x="0.0" y="0.0" width="1280" height="778"/> <value key="minSize" type="size" width="213" height="107"/> <view key="contentView" id="637"> <rect key="frame" x="0.0" y="0.0" width="574" height="380"/> @@ -199,7 +198,7 @@ Gw <rect key="frame" x="10" y="33" width="528" height="232"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> - <box autoresizesSubviews="NO" borderType="line" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="3487"> + <box autoresizesSubviews="NO" title="Box" borderType="line" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="3487"> <rect key="frame" x="1" y="-1" width="526" height="47"/> <view key="contentView" id="7Lj-Zt-bjd"> <rect key="frame" x="1" y="1" width="524" height="45"/> @@ -607,7 +606,7 @@ Gw <windowStyleMask key="styleMask" titled="YES" closable="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="37" y="107" width="531" height="324"/> - <rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/> + <rect key="screenRect" x="0.0" y="0.0" width="1280" height="778"/> <value key="minSize" type="size" width="213" height="107"/> <view key="contentView" id="1264"> <rect key="frame" x="0.0" y="0.0" width="531" height="324"/> @@ -1247,7 +1246,7 @@ DQ <windowStyleMask key="styleMask" titled="YES" closable="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> <rect key="contentRect" x="246" y="437" width="656" height="249"/> - <rect key="screenRect" x="0.0" y="0.0" width="1280" height="777"/> + <rect key="screenRect" x="0.0" y="0.0" width="1280" height="778"/> <value key="minSize" type="size" width="213" height="107"/> <view key="contentView" id="2793"> <rect key="frame" x="0.0" y="0.0" width="656" height="249"/> @@ -1381,7 +1380,7 @@ Gw <action selector="openNetUDPButtonAction:" target="-2" id="jxT-wR-kT9"/> </connections> </button> - <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="2811"> + <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2811"> <rect key="frame" x="17" y="60" width="622" height="70"/> <textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" id="2986"> <font key="font" metaFont="smallSystem"/> diff --git a/modules/gui/macosx/VLCMainWindowControlsBar.h b/modules/gui/macosx/VLCMainWindowControlsBar.h index a9e66acc51..e3134d49c1 100644 --- a/modules/gui/macosx/VLCMainWindowControlsBar.h +++ b/modules/gui/macosx/VLCMainWindowControlsBar.h @@ -41,7 +41,10 @@ @property (readwrite, strong) IBOutlet NSButton *playlistButton; @property (readwrite, strong) IBOutlet NSButton *repeatButton; +@property (readwrite, strong) IBOutlet NSLayoutConstraint *repeatButtonWidthConstraint; + @property (readwrite, strong) IBOutlet NSButton *shuffleButton; +@property (readwrite, strong) IBOutlet NSLayoutConstraint *shuffleButtonWidthConstraint; @property (readwrite, strong) IBOutlet VLCVolumeSliderCommon * volumeSlider; @property (readwrite, strong) IBOutlet NSImageView *volumeTrackImageView; diff --git a/modules/gui/macosx/VLCMainWindowControlsBar.m b/modules/gui/macosx/VLCMainWindowControlsBar.m index d6ac135361..08c41e43f4 100644 --- a/modules/gui/macosx/VLCMainWindowControlsBar.m +++ b/modules/gui/macosx/VLCMainWindowControlsBar.m @@ -56,15 +56,12 @@ NSLayoutConstraint *_hideNextButtonConstraint; NSLayoutConstraint *_hideEffectsButtonConstraint; - - NSLayoutConstraint *_hideRepeatButtonConstraint; - NSLayoutConstraint *_hideShuffleButtonConstraint; } - (void)addJumpButtons:(BOOL)b_fast; - (void)removeJumpButtons:(BOOL)b_fast; -- (void)addPlaymodeButtons:(BOOL)b_fast; -- (void)removePlaymodeButtons:(BOOL)b_fast; +- (void)addPlaymodeButtons:(BOOL)withAnimation; +- (void)removePlaymodeButtons:(BOOL)withAnimation; @end @@ -208,23 +205,9 @@ if (!var_InheritBool(getIntf(), "macosx-show-effects-button")) [self removeEffectsButton:YES]; - _hideRepeatButtonConstraint = [NSLayoutConstraint constraintWithItem:self.repeatButton - attribute:NSLayoutAttributeWidth - relatedBy:NSLayoutRelationEqual - toItem:nil - attribute:NSLayoutAttributeNotAnAttribute - multiplier:1 - constant:0]; - _hideShuffleButtonConstraint = [NSLayoutConstraint constraintWithItem:self.shuffleButton - attribute:NSLayoutAttributeWidth - relatedBy:NSLayoutRelationEqual - toItem:nil - attribute:NSLayoutAttributeNotAnAttribute - multiplier:1 - constant:0]; b_show_playmode_buttons = var_InheritBool(getIntf(), "macosx-show-playmode-buttons"); if (!b_show_playmode_buttons) - [self removePlaymodeButtons:YES]; + [self removePlaymodeButtons:NO]; _hidePrevButtonConstraint = [NSLayoutConstraint constraintWithItem:self.prevButton attribute:NSLayoutAttributeWidth @@ -252,6 +235,22 @@ #pragma mark interface customization +- (void)hideButtonWithConstraint:(NSLayoutConstraint *)constraint animation:(BOOL)animation +{ + NSAssert([constraint.firstItem isKindOfClass:[NSButton class]], @"Constraint must be for NSButton object"); + + NSLayoutConstraint *animatedConstraint = animation ? constraint.animator : constraint; + animatedConstraint.constant = 0; +} + +- (void)showButtonWithConstraint:(NSLayoutConstraint *)constraint animation:(BOOL)animation +{ + NSAssert([constraint.firstItem isKindOfClass:[NSButton class]], @"Constraint must be for NSButton object"); + + NSLayoutConstraint *animatedConstraint = animation ? constraint.animator : constraint; + animatedConstraint.constant = ((NSButton *)constraint.firstItem).image.size.width; +} + - (void)toggleEffectsButton { if (config_GetInt(getIntf(), "macosx-show-effects-button")) @@ -356,37 +355,44 @@ b_show_playmode_buttons = config_GetInt(getIntf(), "macosx-show-playmode-buttons"); if (b_show_playmode_buttons) - [self addPlaymodeButtons:NO]; + [self addPlaymodeButtons:YES]; else - [self removePlaymodeButtons:NO]; + [self removePlaymodeButtons:YES]; } -- (void)addPlaymodeButtons:(BOOL)b_fast +- (void)addPlaymodeButtons:(BOOL)withAnimation { - [self.repeatButton removeConstraint:_hideRepeatButtonConstraint]; - [self.shuffleButton removeConstraint:_hideShuffleButtonConstraint]; + [NSAnimationContext beginGrouping]; + [self showButtonWithConstraint:self.repeatButtonWidthConstraint animation:withAnimation]; + [self showButtonWithConstraint:self.shuffleButtonWidthConstraint animation:withAnimation]; + id button = withAnimation ? self.playlistButton.animator : self.playlistButton; if (self.darkInterface) { - [[self.playlistButton animator] setImage:imageFromRes(@"playlist_dark")]; - [[self.playlistButton animator] setAlternateImage:imageFromRes(@"playlist-pressed_dark")]; + [button setImage:imageFromRes(@"playlist_dark")]; + [button setAlternateImage:imageFromRes(@"playlist-pressed_dark")]; } else { - [[self.playlistButton animator] setImage:imageFromRes(@"playlist-btn")]; - [[self.playlistButton animator] setAlternateImage:imageFromRes(@"playlist-btn-pressed")]; + [button setImage:imageFromRes(@"playlist-btn")]; + [button setAlternateImage:imageFromRes(@"playlist-btn-pressed")]; } + [NSAnimationContext endGrouping]; } -- (void)removePlaymodeButtons:(BOOL)b_fast +- (void)removePlaymodeButtons:(BOOL)withAnimation { - [self.repeatButton addConstraint:_hideRepeatButtonConstraint]; - [self.shuffleButton addConstraint:_hideShuffleButtonConstraint]; + [NSAnimationContext beginGrouping]; + + [self hideButtonWithConstraint:self.repeatButtonWidthConstraint animation:withAnimation]; + [self hideButtonWithConstraint:self.shuffleButtonWidthConstraint animation:withAnimation]; + id button = withAnimation ? self.playlistButton.animator : self.playlistButton; if (self.darkInterface) { - [[self.playlistButton animator] setImage:imageFromRes(@"playlist-1btn-dark")]; - [[self.playlistButton animator] setAlternateImage:imageFromRes(@"playlist-1btn-dark-pressed")]; + [button setImage:imageFromRes(@"playlist-1btn-dark")]; + [button setAlternateImage:imageFromRes(@"playlist-1btn-dark-pressed")]; } else { - [[self.playlistButton animator] setImage:imageFromRes(@"playlist-1btn")]; - [[self.playlistButton animator] setAlternateImage:imageFromRes(@"playlist-1btn-pressed")]; + [button setImage:imageFromRes(@"playlist-1btn")]; + [button setAlternateImage:imageFromRes(@"playlist-1btn-pressed")]; } + [NSAnimationContext endGrouping]; } #pragma mark - _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
