[vlc-commits] [Git][videolan/vlc][master] 2 commits: macosx: Present a placeholder view in groups view controller when there are no groups

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Tue Oct 8 07:29:32 UTC 2024



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


Commits:
d5c1e55d by Claudio Cambra at 2024-10-08T06:42:42+00:00
macosx: Present a placeholder view in groups view controller when there are no groups

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

- - - - -
6288393d by Claudio Cambra at 2024-10-08T06:42:42+00:00
macosx: Fix configuration of placeholder image view constraints in groups view controller

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

- - - - -


1 changed file:

- modules/gui/macosx/library/groups-library/VLCLibraryGroupsViewController.m


Changes:

=====================================
modules/gui/macosx/library/groups-library/VLCLibraryGroupsViewController.m
=====================================
@@ -22,6 +22,8 @@
 
 #import "VLCLibraryGroupsViewController.h"
 
+#import "extensions/NSString+Helpers.h"
+
 #import "library/VLCLibraryCollectionViewDelegate.h"
 #import "library/VLCLibraryCollectionViewFlowLayout.h"
 #import "library/VLCLibraryCollectionViewItem.h"
@@ -40,6 +42,12 @@
 
 #import "main/VLCMain.h"
 
+ at interface VLCLibraryGroupsViewController ()
+{
+    NSArray<NSLayoutConstraint *> *_internalPlaceholderImageViewSizeConstraints;
+}
+ at end
+
 @implementation VLCLibraryGroupsViewController
 
 - (instancetype)initWithLibraryWindow:(VLCLibraryWindow *)libraryWindow
@@ -49,6 +57,7 @@
         [self setupDataSource];
         [self setupGridViewModeViews];
         [self setupListViewModeViews];
+        [self setupPlaceholderView];
     }
     return self;
 }
@@ -189,13 +198,65 @@
     self.selectedGroupTableView.dataSource = self.dataSource;
 }
 
+- (void)setupPlaceholderView
+{
+    _internalPlaceholderImageViewSizeConstraints = @[
+        [NSLayoutConstraint constraintWithItem:self.placeholderImageView
+                                     attribute:NSLayoutAttributeWidth
+                                     relatedBy:NSLayoutRelationEqual
+                                        toItem:nil
+                                     attribute:NSLayoutAttributeNotAnAttribute
+                                    multiplier:0.f
+                                      constant:182.f],
+        [NSLayoutConstraint constraintWithItem:self.placeholderImageView
+                                     attribute:NSLayoutAttributeHeight
+                                     relatedBy:NSLayoutRelationEqual
+                                        toItem:nil
+                                     attribute:NSLayoutAttributeNotAnAttribute
+                                    multiplier:0.f
+                                      constant:114.f],
+    ];
+}
+
 - (id<VLCLibraryDataSource>)currentDataSource
 {
     return self.dataSource;
 }
 
+- (NSArray<NSLayoutConstraint *> *)placeholderImageViewSizeConstraints
+{
+    return _internalPlaceholderImageViewSizeConstraints;
+}
+
+- (void)presentPlaceholderGroupsView
+{
+    NSArray<NSLayoutConstraint *> * const oldViewPlaceholderConstraints =
+        self.libraryWindow.librarySegmentViewController.placeholderImageViewSizeConstraints;
+    for (NSLayoutConstraint * const constraint in oldViewPlaceholderConstraints) {
+        constraint.active = NO;
+    }
+    for (NSLayoutConstraint *constraint in self.placeholderImageViewSizeConstraints) {
+        constraint.active = YES;
+    }
+
+    self.emptyLibraryView.translatesAutoresizingMaskIntoConstraints = NO;
+    self.libraryTargetView.subviews = @[self.emptyLibraryView];
+    NSView * const emptyLibraryView = self.emptyLibraryView;
+    NSDictionary * const dict = NSDictionaryOfVariableBindings(emptyLibraryView);
+    [self.libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[emptyLibraryView(>=572.)]|" options:0 metrics:0 views:dict]];
+    [self.libraryTargetView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[emptyLibraryView(>=444.)]|" options:0 metrics:0 views:dict]];
+
+    self.placeholderImageView.image = [NSImage imageNamed:@"placeholder-video"];
+    self.placeholderLabel.stringValue = _NS("Your favorite groups will appear here.");
+}
+
 - (void)presentGroupsView
 {
+    if (self.dataSource.libraryModel.numberOfGroups == 0) {
+        [self presentPlaceholderGroupsView];
+        return;
+    }
+
     const VLCLibraryViewModeSegment viewModeSegment =
         VLCLibraryWindowPersistentPreferences.sharedInstance.groupsLibraryViewMode;
     NSView *viewToPresent = nil;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0dd67938c02ed9a6cfe3f17fe314bc3c99998fae...6288393dce77e3e9b838c9f8da668c40a95f3def

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0dd67938c02ed9a6cfe3f17fe314bc3c99998fae...6288393dce77e3e9b838c9f8da668c40a95f3def
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