[vlc-commits] [Git][videolan/vlc][master] 4 commits: macosx: Constify pointers in...
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Tue Jul 11 10:57:26 UTC 2023
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
409312b5 by Claudio Cambra at 2023-07-11T09:39:17+00:00
macosx: Constify pointers in VLCLibraryVideoCollectionViewsStackViewController.generateCollectionViewContainers
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
84b331ac by Claudio Cambra at 2023-07-11T09:39:17+00:00
macosx: Do not present Recents section in video collection view id there is no recent media
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
e79c0dc6 by Claudio Cambra at 2023-07-11T09:39:17+00:00
macosx: Do not show recents section in video library table view if no recent media items are available
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
ddac94b9 by Claudio Cambra at 2023-07-11T09:39:17+00:00
macosx: Fix name of video library section table view cell in video library table view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
3 changed files:
- modules/gui/macosx/library/VLCLibraryTableCellView.m
- modules/gui/macosx/library/video-library/VLCLibraryVideoCollectionViewsStackViewController.m
- modules/gui/macosx/library/video-library/VLCLibraryVideoTableViewDataSource.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryTableCellView.m
=====================================
@@ -30,6 +30,7 @@
#import "library/VLCLibraryController.h"
#import "library/VLCLibraryDataTypes.h"
#import "library/VLCLibraryImageCache.h"
+#import "library/VLCLibraryModel.h"
#import "library/video-library/VLCLibraryVideoGroupDescriptor.h"
@@ -106,8 +107,16 @@
- (void)setRepresentedVideoLibrarySection:(NSUInteger)section
{
+ // Group 0 is invalid so we need to adjust the selected row value to match the backing enum.
+ // Additionally, we hide recents when there are no recent media items. Since the recent group
+ // enum value is 1, we need to adjust by more if we are hiding it. Remember the groups are
+ // defined in the desired order.
+ VLCLibraryModel * const model = VLCMain.sharedInstance.libraryController.libraryModel;
+ const BOOL anyRecents = model.numberOfRecentMedia > 0;
+ const NSUInteger sectionAdjustment = anyRecents ? 1 : 2;
+
NSString *sectionString = @"";
- switch(section + 1) { // Group 0 is Invalid, so add one
+ switch(section + sectionAdjustment) { // Group 0 is Invalid, so add one
case VLCLibraryVideoRecentsGroup:
sectionString = _NS("Recents");
break;
=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoCollectionViewsStackViewController.m
=====================================
@@ -25,6 +25,7 @@
#import "library/VLCLibraryCollectionViewDelegate.h"
#import "library/VLCLibraryCollectionViewFlowLayout.h"
#import "library/VLCLibraryCollectionViewSupplementaryElementView.h"
+#import "library/VLCLibraryController.h"
#import "library/VLCLibraryModel.h"
#import "library/VLCLibraryUIUnits.h"
@@ -32,6 +33,8 @@
#import "library/video-library/VLCLibraryVideoCollectionViewContainerViewDataSource.h"
#import "library/video-library/VLCLibraryVideoGroupDescriptor.h"
+#import "main/VLCMain.h"
+
#import "views/VLCSubScrollView.h"
@interface VLCLibraryVideoCollectionViewsStackViewController()
@@ -58,10 +61,13 @@
- (void)generateCollectionViewContainers
{
- NSMutableArray *collectionViewContainers = [[NSMutableArray alloc] init];
+ NSMutableArray * const collectionViewContainers = [[NSMutableArray alloc] init];
+ VLCLibraryModel * const model = VLCMain.sharedInstance.libraryController.libraryModel;
+ const BOOL anyRecents = model.numberOfRecentMedia > 0;
+ NSUInteger i = anyRecents ? VLCLibraryVideoRecentsGroup : VLCLibraryVideoRecentsGroup + 1;
- for (NSUInteger i = VLCLibraryVideoRecentsGroup; i < VLCLibraryVideoSentinel; ++i) {
- VLCLibraryVideoCollectionViewContainerView *containerView = [[VLCLibraryVideoCollectionViewContainerView alloc] init];
+ for (; i < VLCLibraryVideoSentinel; ++i) {
+ VLCLibraryVideoCollectionViewContainerView * const containerView = [[VLCLibraryVideoCollectionViewContainerView alloc] init];
containerView.videoGroup = i;
[collectionViewContainers addObject:containerView];
}
=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoTableViewDataSource.m
=====================================
@@ -33,6 +33,7 @@
#import "library/video-library/VLCLibraryVideoGroupDescriptor.h"
#import "main/CompatibilityFixes.h"
+#import "main/VLCMain.h"
#import "extensions/NSString+Helpers.h"
#import "extensions/NSPasteboardItem+VLCAdditions.h"
@@ -270,9 +271,17 @@
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
if (tableView == _groupsTableView) {
- return 2;
+ const BOOL anyRecents = self.libraryModel.numberOfRecentMedia > 0;
+ return anyRecents ? 2 : 1;
} else if (tableView == _groupSelectionTableView && _groupsTableView.selectedRow > -1) {
- switch(_groupsTableView.selectedRow + 1) { // Group 0 is invalid so add one
+ // Group 0 is invalid so we need to adjust the selected row value to match the backing enum.
+ // Additionally, we hide recents when there are no recent media items. Since the recent group
+ // enum value is 1, we need to adjust by more if we are hiding it. Remember the groups are
+ // defined in the desired order.
+ const BOOL anyRecents = self.libraryModel.numberOfRecentMedia > 0;
+ const NSUInteger selectedRowAdjustment = anyRecents ? 1 : 2;
+
+ switch(_groupsTableView.selectedRow + selectedRowAdjustment) {
case VLCLibraryVideoRecentsGroup:
return _recentsArray.count;
case VLCLibraryVideoLibraryGroup:
@@ -297,7 +306,14 @@
forTableView:(NSTableView *)tableView
{
if (tableView == _groupSelectionTableView && _groupsTableView.selectedRow > -1) {
- switch(_groupsTableView.selectedRow + 1) { // Group 0 is invalid so add one
+ // Group 0 is invalid so we need to adjust the selected row value to match the backing enum.
+ // Additionally, we hide recents when there are no recent media items. Since the recent group
+ // enum value is 1, we need to adjust by more if we are hiding it. Remember the groups are
+ // defined in the desired order.
+ const BOOL anyRecents = self.libraryModel.numberOfRecentMedia > 0;
+ const NSUInteger rowAdjustment = anyRecents ? 1 : 2;
+
+ switch(_groupsTableView.selectedRow + rowAdjustment) {
case VLCLibraryVideoRecentsGroup:
return _recentsArray[row];
case VLCLibraryVideoLibraryGroup:
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a168eb015bf51517ba5ad34b6ebe65c1c0cea2ef...ddac94b990cee438d43ae9ccd6864e361be59b8f
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a168eb015bf51517ba5ad34b6ebe65c1c0cea2ef...ddac94b990cee438d43ae9ccd6864e361be59b8f
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