[vlc-commits] [Git][videolan/vlc][master] 6 commits: macosx: Add basic placeholder label for media source view

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Dec 29 12:38:47 UTC 2023



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


Commits:
645c0dc9 by Claudio Cambra at 2023-12-29T12:16:02+00:00
macosx: Add basic placeholder label for media source view

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

- - - - -
63012de7 by Claudio Cambra at 2023-12-29T12:16:02+00:00
macosx: Centre no files label in screen

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

- - - - -
9ba3b324 by Claudio Cambra at 2023-12-29T12:16:02+00:00
macosx: Use bold and large font for no files label

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

- - - - -
7cad26c6 by Claudio Cambra at 2023-12-29T12:16:02+00:00
macosx: Emit notification when base data source updates

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

- - - - -
ecdd5a93 by Claudio Cambra at 2023-12-29T12:16:02+00:00
macosx: Emit notification when media source data source updates

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

- - - - -
bc0ae475 by Claudio Cambra at 2023-12-29T12:16:02+00:00
macosx: Respond to data source notifications and update placeholder label visibility

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

- - - - -


6 changed files:

- modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.h
- modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.m
- modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.h
- modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.m
- modules/gui/macosx/library/media-source/VLCMediaSourceDataSource.h
- modules/gui/macosx/library/media-source/VLCMediaSourceDataSource.m


Changes:

=====================================
modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.h
=====================================
@@ -41,6 +41,7 @@ NS_ASSUME_NONNULL_BEGIN
 @property (readonly) VLCInputNodePathControl *pathControl;
 @property (readonly) NSVisualEffectView *pathControlVisualEffectView;
 @property (readonly) NSSegmentedControl *gridVsListSegmentedControl;
+ at property (readonly) NSTextField *placeholderLabel;
 
 @property (readonly) VLCMediaSourceBaseDataSource *baseDataSource;
 


=====================================
modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.m
=====================================
@@ -23,6 +23,10 @@
 #import "VLCLibraryMediaSourceViewController.h"
 
 #import "VLCMediaSourceBaseDataSource.h"
+#import "VLCMediaSourceDataSource.h"
+
+#import "extensions/NSFont+VLCAdditions.h"
+#import "extensions/NSString+Helpers.h"
 
 #import "library/VLCLibraryCollectionViewFlowLayout.h"
 #import "library/VLCLibraryCollectionViewItem.h"
@@ -42,6 +46,17 @@
         [self setupBaseDataSource];
         [self setupCollectionView];
         [self setupMediaSourceLibraryViews];
+        [self setupPlaceholderLabel];
+
+        NSNotificationCenter * const defaultCenter = NSNotificationCenter.defaultCenter;
+        [defaultCenter addObserver:self 
+                          selector:@selector(updatePlaceholderLabel:) 
+                              name:VLCMediaSourceBaseDataSourceNodeChanged 
+                            object:nil];
+        [defaultCenter addObserver:self 
+                          selector:@selector(updatePlaceholderLabel:) 
+                              name:VLCMediaSourceDataSourceNodeChanged 
+                            object:nil];
     }
     return self;
 }
@@ -104,6 +119,34 @@
     _tableViewScrollView.scrollerInsets = scrollerInsets;
 }
 
+- (void)setupPlaceholderLabel
+{
+    if (@available(macOS 10.12, *)) {
+        _placeholderLabel = [NSTextField labelWithString:_NS("No files")];
+    } else {
+        _placeholderLabel = [[NSTextField alloc] init];
+        self.placeholderLabel.stringValue = _NS("No files");
+        self.placeholderLabel.editable = NO;
+    }
+    self.placeholderLabel.font = NSFont.VLClibrarySectionHeaderFont;
+    self.placeholderLabel.textColor = NSColor.secondaryLabelColor;
+    self.placeholderLabel.alignment = NSTextAlignmentCenter;
+    self.placeholderLabel.backgroundColor = NSColor.clearColor;
+    self.placeholderLabel.bezeled = NO;
+    self.placeholderLabel.translatesAutoresizingMaskIntoConstraints = NO;
+    [self.mediaSourceView addSubview:self.placeholderLabel];
+    [self.mediaSourceView addConstraints:@[
+        [self.placeholderLabel.centerXAnchor constraintEqualToAnchor:self.mediaSourceView.centerXAnchor],
+        [self.placeholderLabel.centerYAnchor constraintEqualToAnchor:self.mediaSourceView.centerYAnchor],
+    ]];
+    [self updatePlaceholderLabel:nil];
+}
+
+- (void)updatePlaceholderLabel:(NSNotification *)notification
+{
+    self.placeholderLabel.hidden = self.mediaSourceTableView.numberOfRows > 0;
+}
+
 - (void)presentBrowseView
 {
     [self presentMediaSourceView:VLCLibraryBrowseSegment];


=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.h
=====================================
@@ -22,16 +22,18 @@
 
 #import <Cocoa/Cocoa.h>
 
+NS_ASSUME_NONNULL_BEGIN
+
 typedef NS_ENUM(NSInteger, VLCMediaSourceMode) {
     VLCMediaSourceModeLAN,
     VLCMediaSourceModeInternet,
 };
 
-NS_ASSUME_NONNULL_BEGIN
-
 @class VLCInputNodePathControl;
 @class VLCMediaSourceDataSource;
 
+extern NSString * const VLCMediaSourceBaseDataSourceNodeChanged;
+
 @interface VLCMediaSourceBaseDataSource : NSObject <NSCollectionViewDataSource,
                                                     NSCollectionViewDelegate,
                                                     NSCollectionViewDelegateFlowLayout,


=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.m
=====================================
@@ -44,6 +44,8 @@
 
 #import "views/VLCImageView.h"
 
+NSString * const VLCMediaSourceBaseDataSourceNodeChanged = @"VLCMediaSourceBaseDataSourceNodeChanged";
+
 @interface VLCMediaSourceBaseDataSource () <NSCollectionViewDataSource, NSCollectionViewDelegate, NSTableViewDelegate, NSTableViewDataSource>
 {
     NSArray<VLCMediaSource *> *_mediaSources;
@@ -552,6 +554,9 @@ referenceSizeForHeaderInSection:(NSInteger)section
     } else {
         [self.tableView reloadData];
     }
+
+    [NSNotificationCenter.defaultCenter postNotificationName:VLCMediaSourceBaseDataSourceNodeChanged
+                                                      object:self];
 }
 
 - (void)reloadData
@@ -561,6 +566,9 @@ referenceSizeForHeaderInSection:(NSInteger)section
     } else {
         [self.tableView reloadData];
     }
+
+    [NSNotificationCenter.defaultCenter postNotificationName:VLCMediaSourceBaseDataSourceNodeChanged
+                                                      object:self];
 }
 
 @end


=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceDataSource.h
=====================================
@@ -29,6 +29,8 @@ NS_ASSUME_NONNULL_BEGIN
 @class VLCInputNodePathControl;
 @class VLCMediaSource;
 
+extern NSString * const VLCMediaSourceDataSourceNodeChanged;
+
 @interface VLCMediaSourceDataSource : NSObject <NSCollectionViewDataSource,
                                                 NSCollectionViewDelegate,
                                                 NSCollectionViewDelegateFlowLayout,


=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceDataSource.m
=====================================
@@ -41,6 +41,8 @@
 
 #import "views/VLCImageView.h"
 
+NSString * const VLCMediaSourceDataSourceNodeChanged = @"VLCMediaSourceDataSourceNodeChanged";
+
 @interface VLCMediaSourceDataSource()
 {
     VLCInputItem *_childRootInput;
@@ -217,6 +219,9 @@
     if(!_tableView.hidden) {
         [_tableView reloadData];
     }
+
+    [NSNotificationCenter.defaultCenter postNotificationName:VLCMediaSourceDataSourceNodeChanged
+                                                      object:self];
 }
 
 @end



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/41fca3e966c3d9ecf979551512a45840ad93c2cb...bc0ae4752e63638d5fe16d7304cb0edfa1f8c50f

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/41fca3e966c3d9ecf979551512a45840ad93c2cb...bc0ae4752e63638d5fe16d7304cb0edfa1f8c50f
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