[vlc-commits] macosx: Refine animations to show and hide the fullscreen controller

David Fuhrmann git at videolan.org
Wed Jan 15 21:55:10 CET 2020


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Wed Jan 15 21:50:00 2020 +0100| [6dcf70b7c3ae71fc88dc83fd4faa0e3122701af3] | committer: David Fuhrmann

macosx: Refine animations to show and hide the fullscreen controller

Previously, the fs panel was fading in with a 400ms animation, and
at the same time the 1s timer to hide the panel has started.
This led to a percieved visibility of the panel for only 600 ms approx,
which felt a bit too short as a default value.

Now only start the timer once the animation is fully complete, and
avoid repeated abortions of this animation.

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

 .../macosx/windows/video/VLCFSPanelController.m    | 25 ++++++++++++++--------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/modules/gui/macosx/windows/video/VLCFSPanelController.m b/modules/gui/macosx/windows/video/VLCFSPanelController.m
index 4a433ef6df..090adc757e 100644
--- a/modules/gui/macosx/windows/video/VLCFSPanelController.m
+++ b/modules/gui/macosx/windows/video/VLCFSPanelController.m
@@ -42,6 +42,7 @@ NSString *VLCFSPanelShouldBecomeInactive = @"VLCFSPanelShouldBecomeInactive";
 @interface VLCFSPanelController ()
 {
     BOOL _isCounting;
+    BOOL _isFadingIn;
 
     // Only used to track changes and trigger centering of FS panel
     NSRect _associatedVoutFrame;
@@ -383,20 +384,26 @@ static NSString *kAssociatedFullscreenRect = @"VLCFullscreenAssociatedWindowRect
     if (!var_InheritBool(getIntf(), "macosx-fspanel"))
         return;
 
-    [NSAnimationContext beginGrouping];
-    [[NSAnimationContext currentContext] setDuration:0.4f];
-    [[self.window animator] setAlphaValue:1.0f];
-    [NSAnimationContext endGrouping];
+    if (_isFadingIn)
+        return;
 
-    [self startAutohideTimer];
+    [self stopAutohideTimer];
+    [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
+        _isFadingIn = YES;
+        [context setDuration:0.4f];
+        [[self.window animator] setAlphaValue:1.0f];
+    } completionHandler:^{
+        _isFadingIn = NO;
+        [self startAutohideTimer];
+    }];
 }
 
 - (void)fadeOut
 {
-    [NSAnimationContext beginGrouping];
-    [[NSAnimationContext currentContext] setDuration:0.4f];
-    [[self.window animator] setAlphaValue:0.0f];
-    [NSAnimationContext endGrouping];
+    [NSAnimationContext runAnimationGroup:^(NSAnimationContext * _Nonnull context) {
+        [context setDuration:0.4f];
+        [[self.window animator] setAlphaValue:0.0f];
+    } completionHandler:nil];
 }
 
 - (void)centerPanel



More information about the vlc-commits mailing list