Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
4b1d22f3 by Claudio Cambra at 2023-02-03T04:30:12+00:00
macosx: Add VLCLibraryWindowAutohideToolbar class

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
821e9602 by Claudio Cambra at 2023-02-03T04:30:12+00:00
macosx: Implement internal autohide behaviour in VLCLibraryWindowAutohideToolbar

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
4bdb1e28 by Claudio Cambra at 2023-02-03T04:30:12+00:00
macosx: Add autohide property to VLCLibraryWindowAutohideToolbar

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
ee56cd3f by Claudio Cambra at 2023-02-03T04:30:12+00:00
macosx: Add displayToolbar method to VLCLibraryWindowAutohideToolbar

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
6d564d6b by Claudio Cambra at 2023-02-03T04:30:12+00:00
macosx: Observe VLCVideoWindowShouldShowFullscreenController notification in 
VLCLibraryWindowAutohideToolbar

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
f7aba26f by Claudio Cambra at 2023-02-03T04:30:12+00:00
macosx: Default VLCLibraryWindowAutohideToolbar property to NO

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
47e99e7e by Claudio Cambra at 2023-02-03T04:30:12+00:00
macosx: Use VLCLibraryWindowAutohideToolbar in VLCLibraryWindow

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
0382486a by Claudio Cambra at 2023-02-03T04:30:12+00:00
macosx: Deduplicate setup code in VLCLibraryWindowAutohideToolbar

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -
2ae5c194 by Claudio Cambra at 2023-02-03T04:30:12+00:00
macosx: Notify to display fullscreen controller whenever mouse is moved 
anywhere in VLCLibraryWindow (including playlist sidebar and toolbar), not just 
VLCVoutView

Signed-off-by: Claudio Cambra <[email protected]>

- - - - -


6 changed files:

- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- modules/gui/macosx/UI/VLCLibraryWindow.xib
- modules/gui/macosx/library/VLCLibraryWindow.m
- + modules/gui/macosx/library/VLCLibraryWindowAutohideToolbar.h
- + modules/gui/macosx/library/VLCLibraryWindowAutohideToolbar.m


Changes:

=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -79,6 +79,7 @@
                1CFE8D591EA0D42A00E94451 /* VLCErrorWindowController.m in 
Sources */ = {isa = PBXBuildFile; fileRef = 1CFE8D581EA0D42A00E94451 /* 
VLCErrorWindowController.m */; };
                5307A6F52967859F001E0C6A /* NSImage+VLCAdditions.m in Sources 
*/ = {isa = PBXBuildFile; fileRef = 5307A6F42967859F001E0C6A /* 
NSImage+VLCAdditions.m */; };
                5307A6F82969904D001E0C6A /* 
VLCLibraryMediaSourceViewController.m in Sources */ = {isa = PBXBuildFile; 
fileRef = 5307A6F72969904D001E0C6A /* VLCLibraryMediaSourceViewController.m */; 
};
+               5307E5C3298745AB005F42C1 /* VLCLibraryWindowAutohideToolbar.m 
in Sources */ = {isa = PBXBuildFile; fileRef = 5307E5C2298745AB005F42C1 /* 
VLCLibraryWindowAutohideToolbar.m */; };
                5317FE04294E3DD3001702F0 /* VLCLibraryCollectionViewDelegate.m 
in Sources */ = {isa = PBXBuildFile; fileRef = 5317FE03294E3DD3001702F0 /* 
VLCLibraryCollectionViewDelegate.m */; };
                5325C57D29302E6800B2B63A /* VLCLibraryAudioViewController.m in 
Sources */ = {isa = PBXBuildFile; fileRef = 5325C57B29302E6800B2B63A /* 
VLCLibraryAudioViewController.m */; };
                5362550D293FD639005D64FA /* VLCLibraryWindowController.m in 
Sources */ = {isa = PBXBuildFile; fileRef = 5362550C293FD639005D64FA /* 
VLCLibraryWindowController.m */; };
@@ -245,6 +246,8 @@
                5307A6F42967859F001E0C6A /* NSImage+VLCAdditions.m */ = {isa = 
PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = 
"NSImage+VLCAdditions.m"; sourceTree = "<group>"; };
                5307A6F62969904D001E0C6A /* 
VLCLibraryMediaSourceViewController.h */ = {isa = PBXFileReference; 
lastKnownFileType = sourcecode.c.h; path = 
VLCLibraryMediaSourceViewController.h; sourceTree = "<group>"; };
                5307A6F72969904D001E0C6A /* 
VLCLibraryMediaSourceViewController.m */ = {isa = PBXFileReference; 
lastKnownFileType = sourcecode.c.objc; path = 
VLCLibraryMediaSourceViewController.m; sourceTree = "<group>"; };
+               5307E5C1298745AB005F42C1 /* VLCLibraryWindowAutohideToolbar.h 
*/ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = 
VLCLibraryWindowAutohideToolbar.h; sourceTree = "<group>"; };
+               5307E5C2298745AB005F42C1 /* VLCLibraryWindowAutohideToolbar.m 
*/ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = 
VLCLibraryWindowAutohideToolbar.m; sourceTree = "<group>"; };
                5317FE02294E3DD3001702F0 /* VLCLibraryCollectionViewDelegate.h 
*/ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = 
VLCLibraryCollectionViewDelegate.h; sourceTree = "<group>"; };
                5317FE03294E3DD3001702F0 /* VLCLibraryCollectionViewDelegate.m 
*/ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = 
VLCLibraryCollectionViewDelegate.m; sourceTree = "<group>"; };
                5317FE05294E8D1A001702F0 /* 
VLCLibraryCollectionViewDataSource.h */ = {isa = PBXFileReference; 
lastKnownFileType = sourcecode.c.h; path = 
VLCLibraryCollectionViewDataSource.h; sourceTree = "<group>"; };
@@ -1165,6 +1168,8 @@
                                536283DE291146BC00640C15 /* 
VLCLibraryTableView.m */,
                                7D713D302201AE350042BEB7 /* VLCLibraryWindow.h 
*/,
                                7D713D312201AE350042BEB7 /* VLCLibraryWindow.m 
*/,
+                               5307E5C1298745AB005F42C1 /* 
VLCLibraryWindowAutohideToolbar.h */,
+                               5307E5C2298745AB005F42C1 /* 
VLCLibraryWindowAutohideToolbar.m */,
                                5362550B293FD639005D64FA /* 
VLCLibraryWindowController.h */,
                                5362550C293FD639005D64FA /* 
VLCLibraryWindowController.m */,
                                5317FE02294E3DD3001702F0 /* 
VLCLibraryCollectionViewDelegate.h */,
@@ -1882,6 +1887,7 @@
                                536283F1291146BC00640C15 /* 
VLCLibraryAlbumTracksDataSource.m in Sources */,
                                5307A6F52967859F001E0C6A /* 
NSImage+VLCAdditions.m in Sources */,
                                1CCC89042078A3D500E5626F /* StreamOutput.xib in 
Sources */,
+                               5307E5C3298745AB005F42C1 /* 
VLCLibraryWindowAutohideToolbar.m in Sources */,
                                536283F7291146BC00640C15 /* 
VLCLibraryNavigationState.m in Sources */,
                                1CCC89052078A3D500E5626F /* TextfieldPanel.xib 
in Sources */,
                                1CCC89062078A3D500E5626F /* 
TimeSelectionPanel.xib in Sources */,


=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -100,6 +100,8 @@ libmacosx_plugin_la_SOURCES = \
        gui/macosx/library/VLCLibraryUIUnits.m \
        gui/macosx/library/VLCLibraryWindow.h \
        gui/macosx/library/VLCLibraryWindow.m \
+       gui/macosx/library/VLCLibraryWindowAutohideToolbar.h \
+       gui/macosx/library/VLCLibraryWindowAutohideToolbar.m \
        gui/macosx/library/VLCLibraryWindowController.h \
        gui/macosx/library/VLCLibraryWindowController.m \
        gui/macosx/library/video-library/VLCLibraryVideoViewController.h \


=====================================
modules/gui/macosx/UI/VLCLibraryWindow.xib
=====================================
@@ -588,7 +588,7 @@
                     <constraint firstAttribute="bottom" 
secondItem="vUy-jt-gjY" secondAttribute="bottom" id="vMr-VQ-r4P"/>
                 </constraints>
             </visualEffectView>
-            <toolbar key="toolbar" 
implicitIdentifier="CAE4F278-DC20-4A58-B07E-1580E7B14C87" 
centeredItem="KnW-Lr-R1d" autosavesConfiguration="NO" displayMode="iconOnly" 
sizeMode="regular" id="pr3-TD-J2z">
+            <toolbar key="toolbar" 
implicitIdentifier="CAE4F278-DC20-4A58-B07E-1580E7B14C87" 
centeredItem="KnW-Lr-R1d" autosavesConfiguration="NO" displayMode="iconOnly" 
sizeMode="regular" id="pr3-TD-J2z" 
customClass="VLCLibraryWindowAutohideToolbar">
                 <allowedToolbarItems>
                     <toolbarItem 
implicitItemIdentifier="71EED6C9-B0A2-4964-8846-16159F10619E" label="Sort 
Order" paletteLabel="Sort Order" image="arrow.up.arrow.down" catalog="system" 
sizingBehavior="auto" id="Tbc-Ik-FaO">
                         <nil key="toolTip"/>


=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -40,6 +40,7 @@
 #import "library/VLCLibrarySortingMenuController.h"
 #import "library/VLCLibraryNavigationStack.h"
 #import "library/VLCLibraryUIUnits.h"
+#import "library/VLCLibraryWindowAutohideToolbar.h"
 
 #import 
"library/video-library/VLCLibraryVideoCollectionViewsStackViewController.h"
 #import "library/video-library/VLCLibraryVideoTableViewDataSource.h"
@@ -184,10 +185,6 @@ 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
@@ -695,47 +692,6 @@ static void addShadow(NSImageView *__unsafe_unretained 
imageView)
         _windowFrameBeforePlayback = [self frame];
 }
 
-- (void)startToolbarAutohideTimer
-{
-    /* 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 startToolbarAutohideTimer];
-    }
-
-    self.toolbar.visible = YES;
-}
-
 - (void)setHasActiveVideo:(BOOL)hasActiveVideo
 {
     [super setHasActiveVideo:hasActiveVideo];
@@ -811,7 +767,7 @@ static void addShadow(NSImageView *__unsafe_unretained 
imageView)
         [_fspanel shouldBecomeActive:nil];
     }
 
-    [self startToolbarAutohideTimer];
+    [(VLCLibraryWindowAutohideToolbar *)self.toolbar setAutohide:YES];
 }
 
 - (void)disableVideoPlaybackAppearance
@@ -858,7 +814,22 @@ static void addShadow(NSImageView *__unsafe_unretained 
imageView)
         [_fspanel shouldBecomeInactive:nil];
     }
 
-    [self videoDisplayToolbar:self];
+    [(VLCLibraryWindowAutohideToolbar *)self.toolbar setAutohide:NO];
+}
+
+- (void)mouseMoved:(NSEvent *)o_event
+{
+    if (!self.videoView.hidden) {
+        NSPoint mouseLocation = [o_event locationInWindow];
+        NSRect windowRectWithFrame = [self 
frameRectForContentRect:self.contentView.frame];
+
+        if ([self.contentView mouse:mouseLocation inRect:windowRectWithFrame]) 
{
+            [[NSNotificationCenter defaultCenter] 
postNotificationName:VLCVideoWindowShouldShowFullscreenController
+                                                                object:self];
+        }
+    }
+
+    [super mouseMoved:o_event];
 }
 
 #pragma mark -


=====================================
modules/gui/macosx/library/VLCLibraryWindowAutohideToolbar.h
=====================================
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * VLCLibraryWindowAutohideToolbar.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2023 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 
USA.
+ *****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface VLCLibraryWindowAutohideToolbar : NSToolbar
+
+@property (readwrite, nonatomic) BOOL autohide;
+
+- (void)displayToolbar;
+
+@end
+
+NS_ASSUME_NONNULL_END


=====================================
modules/gui/macosx/library/VLCLibraryWindowAutohideToolbar.m
=====================================
@@ -0,0 +1,126 @@
+/*****************************************************************************
+ * VLCLibraryWindowAutohideToolbar.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2023 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, 
USA.
+ *****************************************************************************/
+
+#import "VLCLibraryWindowAutohideToolbar.h"
+
+#import "main/VLCMain.h"
+
+#import "windows/video/VLCVideoWindowCommon.h"
+
+#import <vlc_common.h>
+
+@interface VLCLibraryWindowAutohideToolbar()
+{
+    NSTimer *_hideToolbarTimer;
+}
+@end
+
+@implementation VLCLibraryWindowAutohideToolbar
+
+- (instancetype)init
+{
+    self = [super init];
+    if (self) {
+        [self setup];
+    }
+    return self;
+}
+
+- (void)awakeFromNib
+{
+    [self setup];
+}
+
+- (void)setup
+{
+    NSNotificationCenter *notificationCenter = [NSNotificationCenter 
defaultCenter];
+    [notificationCenter addObserver:self
+                           selector:@selector(shouldShowToolbar:)
+                               
name:VLCVideoWindowShouldShowFullscreenController
+                             object:nil];
+    _autohide = NO;
+}
+
+- (void)stopAutohideTimer
+{
+    [_hideToolbarTimer invalidate];
+}
+
+- (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(hideToolbar:)
+                                                       userInfo:nil
+                                                        repeats:NO];
+}
+
+- (void)hideToolbar:(id)sender
+{
+    [self stopAutohideTimer];
+    self.visible = NO;
+}
+
+- (void)setAutohide:(BOOL)autohide
+{
+    if (_autohide == autohide) {
+        return;
+    }
+
+    _autohide = autohide;
+
+    if (autohide) {
+        [self startAutohideTimer];
+    } else {
+        [self displayToolbar];
+    }
+}
+
+- (void)shouldShowToolbar:(NSNotification *)aNotification
+{
+    [self displayToolbar];
+}
+
+- (void)displayToolbar
+{
+    [self stopAutohideTimer];
+
+    if (self.visible && !_autohide) {
+        return;
+    }
+
+    self.visible = YES;
+
+    if (_autohide) {
+        [self startAutohideTimer];
+    }
+}
+
+@end



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/46ca013bb6c23922609e1d936fc9f31cdcf7859f...2ae5c194b14663fe14eae12ef7941c86e7407862

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/46ca013bb6c23922609e1d936fc9f31cdcf7859f...2ae5c194b14663fe14eae12ef7941c86e7407862
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to