[vlc-commits] [Git][videolan/vlc][master] 3 commits: macosx: Add and configure loading overlay view in playlist view controller

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Mon Aug 26 18:11:14 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
c55cb751 by Claudio Cambra at 2024-08-26T17:58:53+00:00
macosx: Add and configure loading overlay view in playlist view controller

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
7497d36a by Claudio Cambra at 2024-08-26T17:58:53+00:00
macosx: Present loading overlay view when long loads related to playlists start

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
a4aea586 by Claudio Cambra at 2024-08-26T17:58:53+00:00
macosx: Hide loading overlay view when dealing with long load finish notification for playlists

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


2 changed files:

- modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistViewController.h
- modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistViewController.m


Changes:

=====================================
modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistViewController.h
=====================================
@@ -25,6 +25,7 @@
 NS_ASSUME_NONNULL_BEGIN
 
 @class VLCLibraryCollectionViewDelegate;
+ at class VLCLoadingOverlayView;
 @class VLCLibraryMasterDetailViewTableViewDelegate;
 @class VLCLibraryPlaylistDataSource;
 @class VLCLibraryTableView;
@@ -42,6 +43,8 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readonly) NSScrollView *collectionViewScrollView;
 @property (readonly) NSCollectionView *collectionView;
 @property (readonly) NSArray<NSLayoutConstraint *> *placeholderImageViewConstraints;
+ at property (readonly) VLCLoadingOverlayView *loadingOverlayView;
+ at property (readonly) NSArray<NSLayoutConstraint *> *loadingOverlayViewConstraints;
 
 @property (readonly) VLCLibraryPlaylistDataSource *dataSource;
 @property (readonly) VLCLibraryCollectionViewDelegate *collectionViewDelegate;


=====================================
modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistViewController.m
=====================================
@@ -43,6 +43,8 @@
 
 #import "main/VLCMain.h"
 
+#import "views/VLCLoadingOverlayView.h"
+
 #import "windows/video/VLCMainVideoViewController.h"
 
 @implementation VLCLibraryPlaylistViewController
@@ -69,6 +71,28 @@
                                selector:@selector(libraryModelUpdated:)
                                    name:VLCLibraryModelPlaylistDeleted
                                  object:nil];
+
+        NSString * const playlistListResetLongLoadStartNotification = [VLCLibraryModelPlaylistListReset stringByAppendingString:VLCLongNotificationNameStartSuffix];
+        NSString * const playlistListResetLongLoadFinishNotification = [VLCLibraryModelPlaylistListReset stringByAppendingString:VLCLongNotificationNameFinishSuffix];
+        NSString * const playlistDeletedLongLoadStartNotification = [VLCLibraryModelPlaylistDeleted stringByAppendingString:VLCLongNotificationNameStartSuffix];
+        NSString * const playlistDeletedLongLoadFinishNotification = [VLCLibraryModelPlaylistDeleted stringByAppendingString:VLCLongNotificationNameFinishSuffix];
+
+        [notificationCenter addObserver:self
+                               selector:@selector(libraryModelLongLoadStarted:)
+                                   name:playlistListResetLongLoadStartNotification
+                                 object:nil];
+        [notificationCenter addObserver:self
+                               selector:@selector(libraryModelLongLoadFinished:)
+                                   name:playlistListResetLongLoadFinishNotification
+                                 object:nil];
+        [notificationCenter addObserver:self
+                               selector:@selector(libraryModelLongLoadStarted:)
+                                   name:playlistDeletedLongLoadStartNotification
+                                 object:nil];
+        [notificationCenter addObserver:self
+                               selector:@selector(libraryModelLongLoadFinished:)
+                                   name:playlistDeletedLongLoadFinishNotification
+                                 object:nil];
     }
 
     return self;
@@ -192,6 +216,42 @@
     ];
 }
 
+- (void)setupLoadingOverlayView
+{
+    _loadingOverlayView = [[VLCLoadingOverlayView alloc] init];
+    self.loadingOverlayView.translatesAutoresizingMaskIntoConstraints = NO;
+    _loadingOverlayViewConstraints = @[
+        [NSLayoutConstraint constraintWithItem:self.loadingOverlayView
+                                     attribute:NSLayoutAttributeTop
+                                     relatedBy:NSLayoutRelationEqual
+                                        toItem:self.libraryTargetView
+                                     attribute:NSLayoutAttributeTop
+                                    multiplier:1
+                                      constant:0],
+        [NSLayoutConstraint constraintWithItem:self.loadingOverlayView
+                                     attribute:NSLayoutAttributeRight
+                                     relatedBy:NSLayoutRelationEqual
+                                        toItem:self.libraryTargetView
+                                     attribute:NSLayoutAttributeRight
+                                    multiplier:1
+                                      constant:0],
+        [NSLayoutConstraint constraintWithItem:self.loadingOverlayView
+                                     attribute:NSLayoutAttributeBottom
+                                     relatedBy:NSLayoutRelationEqual
+                                        toItem:self.libraryTargetView
+                                     attribute:NSLayoutAttributeBottom
+                                    multiplier:1
+                                      constant:0],
+        [NSLayoutConstraint constraintWithItem:self.loadingOverlayView
+                                     attribute:NSLayoutAttributeLeft
+                                     relatedBy:NSLayoutRelationEqual
+                                        toItem:self.libraryTargetView
+                                     attribute:NSLayoutAttributeLeft
+                                    multiplier:1
+                                      constant:0]
+    ];
+}
+
 // TODO: This is duplicated almost verbatim across all the library view
 // controllers. Ideally we should have the placeholder view handle this
 // itself, or move this into a common superclass
@@ -269,6 +329,51 @@
     }
 }
 
+- (void)libraryModelLongLoadStarted:(NSNotification *)notification
+{
+    if ([self.libraryTargetView.subviews containsObject:self.loadingOverlayView]) {
+        return;
+    }
+
+    [self.dataSource disconnect];
+
+    self.loadingOverlayView.wantsLayer = YES;
+    self.loadingOverlayView.alphaValue = 0.0;
+
+    NSArray * const views = [self.libraryTargetView.subviews arrayByAddingObject:self.loadingOverlayView];
+    self.libraryTargetView.subviews = views;
+    [self.libraryTargetView addConstraints:_loadingOverlayViewConstraints];
+
+    [NSAnimationContext runAnimationGroup:^(NSAnimationContext * const context) {
+        context.duration = 0.5;
+        self.loadingOverlayView.animator.alphaValue = 1.0;
+    } completionHandler:nil];
+    [self.loadingOverlayView.indicator startAnimation:self];
+}
+
+- (void)libraryModelLongLoadFinished:(NSNotification *)notification
+{
+    if (![self.libraryTargetView.subviews containsObject:self.loadingOverlayView]) {
+        return;
+    }
+
+    [self.dataSource connect];
+
+    self.loadingOverlayView.wantsLayer = YES;
+    self.loadingOverlayView.alphaValue = 1.0;
+
+    [NSAnimationContext runAnimationGroup:^(NSAnimationContext * const context) {
+        context.duration = 1.0;
+        self.loadingOverlayView.animator.alphaValue = 0.0;
+    } completionHandler:^{
+        [self.libraryTargetView removeConstraints:_loadingOverlayViewConstraints];
+        NSMutableArray * const views = self.libraryTargetView.subviews.mutableCopy;
+        [views removeObject:self.loadingOverlayView];
+        self.libraryTargetView.subviews = views.copy;
+        [self.loadingOverlayView.indicator stopAnimation:self];
+    }];
+}
+
 #pragma mark - NSSplitViewDelegate
 
 - (CGFloat)splitView:(NSSplitView *)splitView 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2e77112df59f0b739c70aed8f148c0e81200c6db...a4aea586c9f3ec467e468e15df59e3378ccedd56

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


VideoLAN code repository instance


More information about the vlc-commits mailing list