Skip to content
Snippets Groups Projects
Commit 7bca0424 authored by Claudio Cambra's avatar Claudio Cambra Committed by Jean-Baptiste Kempf
Browse files

macosx: Auto-hide main library window toolbar during video playback


Signed-off-by: default avatarClaudio Cambra <developer@claudiocambra.com>
parent 3bb353e3
No related branches found
No related tags found
No related merge requests found
......@@ -82,6 +82,8 @@ static NSArray<NSLayoutConstraint *> *audioPlaceholderImageViewSizeConstraints;
NSInteger _currentSelectedSegment;
NSInteger _currentSelectedViewModeSegment;
NSTimer *_hideToolbarTimer;
}
- (IBAction)goToBrowseSection:(id)sender;
......@@ -199,6 +201,10 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
selector:@selector(playerStateChanged:)
name:VLCPlayerStateChanged
object:nil];
[notificationCenter addObserver:self
selector:@selector(videoDisplayToolbar:)
name:VLCVideoWindowShouldShowFullscreenController
object:nil];
if (@available(macOS 10.14, *)) {
[[NSApplication sharedApplication] addObserver:self
......@@ -759,6 +765,47 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
_windowFrameBeforePlayback = [self frame];
}
- (void)startAutohideTimer
{
/* Do nothing if timer is already in place */
if (_hideToolbarTimer.valid) {
return;
}
/* Get timeout and make sure it is not lower than 1 second */
long long timeToKeepVisibleInSec = MAX(var_CreateGetInteger(getIntf(), "mouse-hide-timeout") / 1000, 1);
_hideToolbarTimer = [NSTimer scheduledTimerWithTimeInterval:timeToKeepVisibleInSec
target:self
selector:@selector(videoHideToolbar:)
userInfo:nil
repeats:NO];
}
- (void)stopAutohideTimer
{
[_hideToolbarTimer invalidate];
}
- (void)videoHideToolbar:(id)sender
{
if (self.hasActiveVideo && !self.videoView.hidden) {
[self stopAutohideTimer];
self.toolbar.visible = NO;
}
}
- (void)videoDisplayToolbar:(id)sender
{
[self stopAutohideTimer];
if (self.hasActiveVideo && !self.videoView.hidden) {
[self startAutohideTimer];
}
self.toolbar.visible = YES;
}
- (void)setHasActiveVideo:(BOOL)hasActiveVideo
{
[super setHasActiveVideo:hasActiveVideo];
......@@ -833,6 +880,8 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
[self hideControlsBar];
[_fspanel shouldBecomeActive:nil];
}
[self videoHideToolbar:self];
}
- (void)disableVideoPlaybackAppearance
......@@ -861,6 +910,7 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
// restore alpha value to 1 for the case that macosx-opaqueness is set to < 1
[self setAlphaValue:1.0];
self.videoView.hidden = YES;
[self.segmentedTitleControl setHidden:NO];
[self.forwardsNavigationButton setHidden:NO];
......@@ -877,6 +927,8 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
[self showControlsBar];
[_fspanel shouldBecomeInactive:nil];
}
[self videoDisplayToolbar:self];
}
#pragma mark -
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment