[vlc-commits] [Git][videolan/vlc][master] 7 commits: macosx: Add VLCLibraryItemPresentingCapable
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Feb 8 13:30:41 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
659c46e2 by Claudio Cambra at 2025-02-08T13:17:00+00:00
macosx: Add VLCLibraryItemPresentingCapable
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
a56d3983 by Claudio Cambra at 2025-02-08T13:17:00+00:00
macosx: Mark library view controllers that already implement presentLibraryItem: as VLCLibraryItemPresentingCapable conforming
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
c6fca279 by Claudio Cambra at 2025-02-08T13:17:00+00:00
macosx: Mark VLCLibraryWindow as VLCLibraryItemPresentingCapable
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
532ed0ff by Claudio Cambra at 2025-02-08T13:17:00+00:00
macosx: Add method to get relevant library segment for a given library item
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
840affe8 by Claudio Cambra at 2025-02-08T13:17:00+00:00
macosx: Split application of a segment's relevant view into a different method in library window
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
db1ef0ee by Claudio Cambra at 2025-02-08T13:17:00+00:00
macosx: Deduplicate library item presentation procedure in library window
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
0c06c384 by Claudio Cambra at 2025-02-08T13:17:00+00:00
macosx: Make VLCLibraryGroupsViewController VLCLibraryItemPresentingCapable conforming
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
13 changed files:
- extras/package/macosx/VLC.xcodeproj/project.pbxproj
- modules/gui/macosx/Makefile.am
- + modules/gui/macosx/library/VLCLibraryItemPresentingCapable.h
- modules/gui/macosx/library/VLCLibrarySegment.h
- modules/gui/macosx/library/VLCLibrarySegment.m
- modules/gui/macosx/library/VLCLibraryWindow.h
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.h
- modules/gui/macosx/library/groups-library/VLCLibraryGroupsViewController.h
- modules/gui/macosx/library/groups-library/VLCLibraryGroupsViewController.m
- modules/gui/macosx/library/home-library/VLCLibraryHomeViewStackViewController.h
- modules/gui/macosx/library/home-library/VLCLibraryHomeViewVideoContainerView.h
- modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.h
Changes:
=====================================
extras/package/macosx/VLC.xcodeproj/project.pbxproj
=====================================
@@ -331,6 +331,7 @@
532CBCFD2C8E025F00899413 /* VLCLibraryDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryDataSource.h; sourceTree = "<group>"; };
533B5D2A29CF94C6003DE887 /* VLCBookmarksTableViewDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCBookmarksTableViewDataSource.h; sourceTree = "<group>"; };
533B5D2B29CF94C6003DE887 /* VLCBookmarksTableViewDataSource.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCBookmarksTableViewDataSource.m; sourceTree = "<group>"; };
+ 533D20432D549D2400AB146F /* VLCLibraryItemPresentingCapable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryItemPresentingCapable.h; sourceTree = "<group>"; };
5341F1472C96E544003BDF0A /* VLCLibraryWindowChaptersView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCLibraryWindowChaptersView.xib; sourceTree = "<group>"; };
5341F1482C9757EF003BDF0A /* VLCLibraryWindowChaptersSidebarViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCLibraryWindowChaptersSidebarViewController.h; sourceTree = "<group>"; };
5341F1492C9757EF003BDF0A /* VLCLibraryWindowChaptersSidebarViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCLibraryWindowChaptersSidebarViewController.m; sourceTree = "<group>"; };
@@ -1384,6 +1385,7 @@
7DFBDCAA2269E77F00B700A5 /* VLCLibraryModel.m */,
53D8ED982B583AAF00142EAD /* VLCLibraryModelChangeDelegate.h */,
53D8ED992B583AAF00142EAD /* VLCLibraryModelChangeDelegate.m */,
+ 533D20432D549D2400AB146F /* VLCLibraryItemPresentingCapable.h */,
530771F22AEBB80C00656D3D /* VLCLibraryRepresentedItem.h */,
530771F32AEBBD5B00656D3D /* VLCLibraryRepresentedItem.m */,
531343E82A8E8965007AEDFA /* VLCLibrarySegment.h */,
=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -135,6 +135,7 @@ libmacosx_plugin_la_SOURCES = \
gui/macosx/library/VLCLibraryImageCache.m \
gui/macosx/library/VLCLibraryItemInternalMediaItemsDataSource.h \
gui/macosx/library/VLCLibraryItemInternalMediaItemsDataSource.m \
+ gui/macosx/library/VLCLibraryItemPresentingCapable.h \
gui/macosx/library/VLCLibraryMasterDetailViewTableViewDataSource.h \
gui/macosx/library/VLCLibraryMasterDetailViewTableViewDelegate.h \
gui/macosx/library/VLCLibraryMasterDetailViewTableViewDelegate.m \
=====================================
modules/gui/macosx/library/VLCLibraryItemPresentingCapable.h
=====================================
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * VLCLibraryItemPresentingCapable.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2025 VLC authors and VideoLAN
+ *
+ * Authors: Claudio Cambra <developer at claudiocambra.com>
+ *
+ * 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 <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at protocol VLCMediaLibraryItemProtocol;
+
+ at protocol VLCLibraryItemPresentingCapable
+
+- (void)presentLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem;
+
+ at end
+
+NS_ASSUME_NONNULL_END
=====================================
modules/gui/macosx/library/VLCLibrarySegment.h
=====================================
@@ -25,6 +25,7 @@
NS_ASSUME_NONNULL_BEGIN
@class VLCLibraryAbstractSegmentViewController;
+ at protocol VLCMediaLibraryItemProtocol;
extern NSString * const VLCLibraryBookmarkedLocationsKey;
extern NSString * const VLCLibraryBookmarkedLocationsChanged;
@@ -63,6 +64,7 @@ typedef NS_ENUM(NSInteger, VLCLibrarySegmentType) {
@property (readonly) NSUInteger toolbarDisplayFlags;
+ (instancetype)segmentWithSegmentType:(VLCLibrarySegmentType)segmentType;
++ (instancetype)segmentForLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem;
- (nullable VLCLibraryAbstractSegmentViewController *)newLibraryViewController;
- (void)presentLibraryViewUsingController:(VLCLibraryAbstractSegmentViewController *)controller;
=====================================
modules/gui/macosx/library/VLCLibrarySegment.m
=====================================
@@ -26,6 +26,7 @@
#import "library/VLCInputItem.h"
#import "library/VLCLibraryController.h"
+#import "library/VLCLibraryDataTypes.h"
#import "library/VLCLibraryModel.h"
#import "library/VLCLibrarySegmentBookmarkedLocation.h"
#import "library/VLCLibraryWindow.h"
@@ -855,6 +856,33 @@ NSArray<NSString *> *defaultBookmarkedLocations()
}
}
++ (instancetype)segmentForLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem
+{
+ if ([libraryItem isKindOfClass:VLCMediaLibraryAlbum.class]) {
+ return [VLCLibrarySegment segmentWithSegmentType:VLCLibraryAlbumsMusicSubSegmentType];
+ } else if ([libraryItem isKindOfClass:VLCMediaLibraryArtist.class]) {
+ return [VLCLibrarySegment segmentWithSegmentType:VLCLibraryArtistsMusicSubSegmentType];
+ } else if ([libraryItem isKindOfClass:VLCMediaLibraryGenre.class]) {
+ return [VLCLibrarySegment segmentWithSegmentType:VLCLibraryGenresMusicSubSegmentType];
+ } else if ([libraryItem isKindOfClass:VLCMediaLibraryGroup.class]) {
+ return [VLCLibrarySegment segmentWithSegmentType:VLCLibraryGroupsSegmentType];
+ }
+
+ VLCMediaLibraryMediaItem * const mediaItem = (VLCMediaLibraryMediaItem *)libraryItem;
+ const BOOL validMediaItem = mediaItem != nil;
+ if (validMediaItem && mediaItem.mediaType == VLC_ML_MEDIA_TYPE_AUDIO) {
+ return [VLCLibrarySegment segmentWithSegmentType:VLCLibraryMusicSegmentType];
+ } else if (validMediaItem && mediaItem.mediaType == VLC_ML_MEDIA_TYPE_VIDEO) {
+ if (mediaItem.mediaSubType == VLC_ML_MEDIA_SUBTYPE_SHOW_EPISODE) {
+ return [VLCLibrarySegment segmentWithSegmentType:VLCLibraryShowsVideoSubSegmentType];
+ }
+ return [VLCLibrarySegment segmentWithSegmentType:VLCLibraryVideoSegmentType];
+ }
+
+ NSLog(@"Unknown library item type provided, cannot find segment for it: %@", libraryItem.displayString);
+ return nil;
+}
+
- (instancetype)initWithSegmentType:(VLCLibrarySegmentType)segmentType
{
return [VLCLibrarySegment treeNodeWithRepresentedObject:@(segmentType)];
=====================================
modules/gui/macosx/library/VLCLibraryWindow.h
=====================================
@@ -24,6 +24,8 @@
#import "views/VLCDragDropView.h"
+#import "library/VLCLibraryItemPresentingCapable.h"
+
NS_ASSUME_NONNULL_BEGIN
@class VLCMainWindowControlsBar;
@@ -50,7 +52,7 @@ typedef NS_ENUM(NSInteger, VLCLibraryViewModeSegment) {
VLCLibraryLargestSentinelViewModeSegment
};
- at interface VLCLibraryWindow : VLCFullVideoViewWindow<NSUserInterfaceItemIdentification, VLCDragDropTarget>
+ at interface VLCLibraryWindow : VLCFullVideoViewWindow<NSUserInterfaceItemIdentification, VLCDragDropTarget, VLCLibraryItemPresentingCapable>
extern const CGFloat VLCLibraryWindowMinimalWidth;
extern const CGFloat VLCLibraryWindowMinimalHeight;
@@ -137,7 +139,6 @@ extern const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier;
usingConstraints:(NSArray<NSLayoutConstraint *> *)constraints
displayingMessage:(NSString *)message;
- (void)displayNoResultsMessage;
-- (void)presentLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem;
- (void)goToLocalFolderMrl:(NSString *)mrl;
- (IBAction)goToBrowseSection:(id)sender;
=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -232,7 +232,11 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
{
const VLCLibrarySegmentType segmentType = self.librarySegmentType;
VLCLibrarySegment * const segment = [VLCLibrarySegment segmentWithSegmentType:segmentType];
+ [self applySegmentView:segment];
+}
+- (void)applySegmentView:(VLCLibrarySegment *)segment
+{
[self.toolbarDelegate applyVisiblityFlags:segment.toolbarDisplayFlags];
if (![self.librarySegmentViewController isKindOfClass:segment.libraryViewControllerClass]) {
_librarySegmentViewController = [segment newLibraryViewController];
@@ -316,49 +320,13 @@ static void addShadow(NSImageView *__unsafe_unretained imageView)
]];
}
-- (void)presentAudioLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem
-{
- self.librarySegmentType = VLCLibraryMusicSegmentType;
- [(VLCLibraryAudioViewController *)self.librarySegmentViewController presentLibraryItem:libraryItem];
-}
-
-- (void)presentVideoLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem
-{
- self.librarySegmentType = VLCLibraryVideoSegmentType;
- [(VLCLibraryVideoViewController *)self.librarySegmentViewController presentLibraryItem:libraryItem];
-}
-
-- (void)presentGroupLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem
-{
- self.librarySegmentType = VLCLibraryGroupsSegmentType;
- [(VLCLibraryGroupsViewController *)self.librarySegmentViewController presentGroup:libraryItem];
-}
-
- (void)presentLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem
{
- const BOOL isAudioGroup = [libraryItem isKindOfClass:VLCMediaLibraryAlbum.class] ||
- [libraryItem isKindOfClass:VLCMediaLibraryArtist.class] ||
- [libraryItem isKindOfClass:VLCMediaLibraryGenre.class];
-
- if (isAudioGroup) {
- [self presentAudioLibraryItem:libraryItem];
- return;
- } else if ([libraryItem isKindOfClass:VLCMediaLibraryGroup.class]) {
- [self presentGroupLibraryItem:libraryItem];
- return;
+ VLCLibrarySegment * const segment = [VLCLibrarySegment segmentForLibraryItem:libraryItem];
+ [self applySegmentView:segment];
+ if ([self.librarySegmentViewController conformsToProtocol:@protocol(VLCLibraryItemPresentingCapable)]) {
+ [(VLCLibraryAbstractSegmentViewController<VLCLibraryItemPresentingCapable> *)self.librarySegmentViewController presentLibraryItem:libraryItem];
}
-
- VLCMediaLibraryMediaItem * const mediaItem = (VLCMediaLibraryMediaItem *)libraryItem;
- const BOOL validMediaItem = mediaItem != nil;
- if (validMediaItem && mediaItem.mediaType == VLC_ML_MEDIA_TYPE_AUDIO) {
- [self presentAudioLibraryItem:libraryItem];
- return;
- } else if (validMediaItem && mediaItem.mediaType == VLC_ML_MEDIA_TYPE_VIDEO) {
- [self presentVideoLibraryItem:libraryItem];
- return;
- }
-
- NSLog(@"Unknown kind of library item provided, cannot present library view for it: %@", libraryItem.displayString);
}
- (void)goToLocalFolderMrl:(NSString *)mrl
=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.h
=====================================
@@ -24,6 +24,7 @@
#import "library/VLCLibrarySegment.h"
#import "library/VLCLibraryAbstractMediaLibrarySegmentViewController.h"
+#import "library/VLCLibraryItemPresentingCapable.h"
@class VLCLibraryAudioDataSource;
@class VLCLibraryAudioGroupDataSource;
@@ -34,7 +35,7 @@
NS_ASSUME_NONNULL_BEGIN
- at interface VLCLibraryAudioViewController : VLCLibraryAbstractMediaLibrarySegmentViewController
+ at interface VLCLibraryAudioViewController : VLCLibraryAbstractMediaLibrarySegmentViewController<VLCLibraryItemPresentingCapable>
@property (readonly, weak) NSView *audioLibraryView;
@property (readonly, weak) NSSplitView *audioLibrarySplitView;
@@ -59,7 +60,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)presentAudioView;
- (void)reloadData;
-- (void)presentLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem;
@end
=====================================
modules/gui/macosx/library/groups-library/VLCLibraryGroupsViewController.h
=====================================
@@ -23,6 +23,7 @@
#import <Cocoa/Cocoa.h>
#import "library/VLCLibraryAbstractMediaLibrarySegmentViewController.h"
+#import "library/VLCLibraryItemPresentingCapable.h"
NS_ASSUME_NONNULL_BEGIN
@@ -34,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN
@class VLCLibraryWindow;
@class VLCMediaLibraryGroup;
- at interface VLCLibraryGroupsViewController : VLCLibraryAbstractMediaLibrarySegmentViewController<NSSplitViewDelegate>
+ at interface VLCLibraryGroupsViewController : VLCLibraryAbstractMediaLibrarySegmentViewController<NSSplitViewDelegate, VLCLibraryItemPresentingCapable>
@property (readonly) NSScrollView *collectionViewScrollView;
@property (readonly) VLCLibraryCollectionView *collectionView;
@@ -51,7 +52,6 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithLibraryWindow:(VLCLibraryWindow *)libraryWindow;
- (void)presentGroupsView;
-- (void)presentGroup:(VLCMediaLibraryGroup *)group;
@end
=====================================
modules/gui/macosx/library/groups-library/VLCLibraryGroupsViewController.m
=====================================
@@ -254,19 +254,19 @@
}
}
-- (void)presentGroup:(VLCMediaLibraryGroup *)group
+- (void)presentLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem
{
[self presentGroupsView];
const VLCLibraryViewModeSegment viewModeSegment =
VLCLibraryWindowPersistentPreferences.sharedInstance.groupsLibraryViewMode;
if (viewModeSegment == VLCLibraryGridViewModeSegment) {
- NSIndexPath * const groupIndexPath = [self.dataSource indexPathForLibraryItem:group];
+ NSIndexPath * const groupIndexPath = [self.dataSource indexPathForLibraryItem:libraryItem];
NSSet<NSIndexPath *> * const groupIndexPathSet = [NSSet setWithObject:groupIndexPath];
[self.collectionView scrollToItemsAtIndexPaths:groupIndexPathSet
scrollPosition:NSCollectionViewScrollPositionTop];
} else {
- const NSInteger groupRow = [self.dataSource rowForLibraryItem:group];
+ const NSInteger groupRow = [self.dataSource rowForLibraryItem:libraryItem];
[self.groupsTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:groupRow]
byExtendingSelection:NO];
[self.groupsTableView scrollRowToVisible:groupRow];
=====================================
modules/gui/macosx/library/home-library/VLCLibraryHomeViewStackViewController.h
=====================================
@@ -22,6 +22,8 @@
#import <Cocoa/Cocoa.h>
+#import "library/VLCLibraryItemPresentingCapable.h"
+
NS_ASSUME_NONNULL_BEGIN
@class VLCLibraryHeroView;
@@ -30,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
@class VLCLibraryHomeViewVideoCarouselContainerView;
@protocol VLCMediaLibraryItemProtocol;
- at interface VLCLibraryHomeViewStackViewController : NSObject
+ at interface VLCLibraryHomeViewStackViewController : NSObject<VLCLibraryItemPresentingCapable>
@property (readwrite, assign, nonatomic) NSSize collectionViewItemSize;
@property (readwrite, assign, nonatomic) CGFloat collectionViewMinimumLineSpacing;
@@ -48,7 +50,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)reloadData;
- (void)connectContainers;
- (void)disconnectContainers;
-- (void)presentLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem;
@end
=====================================
modules/gui/macosx/library/home-library/VLCLibraryHomeViewVideoContainerView.h
=====================================
@@ -22,6 +22,7 @@
#import <Cocoa/Cocoa.h>
+#import "library/VLCLibraryItemPresentingCapable.h"
#import "library/home-library/VLCLibraryHomeViewContainerView.h"
#import "library/video-library/VLCLibraryVideoGroupDescriptor.h"
@@ -29,14 +30,13 @@
NS_ASSUME_NONNULL_BEGIN
- at protocol VLCLibraryHomeViewVideoContainerView <VLCLibraryHomeViewContainerView>
+ at protocol VLCLibraryHomeViewVideoContainerView <VLCLibraryHomeViewContainerView, VLCLibraryItemPresentingCapable>
@property (readonly) VLCLibraryVideoCollectionViewGroupDescriptor *groupDescriptor;
@property (readwrite, assign, nonatomic) VLCMediaLibraryParentGroupType videoGroup;
@property (readonly) VLCLibraryHomeViewVideoContainerViewDataSource *dataSource;
- (void)setVideoGroup:(VLCMediaLibraryParentGroupType)group;
-- (void)presentLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem;
@end
=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.h
=====================================
@@ -23,6 +23,7 @@
#import <Cocoa/Cocoa.h>
#import "library/VLCLibraryAbstractMediaLibrarySegmentViewController.h"
+#import "library/VLCLibraryItemPresentingCapable.h"
@class VLCLibraryCollectionView;
@class VLCLibraryWindow;
@@ -34,8 +35,7 @@
NS_ASSUME_NONNULL_BEGIN
// Controller for the video library views
-
- at interface VLCLibraryVideoViewController : VLCLibraryAbstractMediaLibrarySegmentViewController
+ at interface VLCLibraryVideoViewController : VLCLibraryAbstractMediaLibrarySegmentViewController<VLCLibraryItemPresentingCapable>
@property (readonly, weak) NSView *videoLibraryView;
@property (readonly, weak) NSSplitView *videoLibrarySplitView;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3d0e73a0e9c2e3f7b66f52a159e41233dcb866ba...0c06c384bc443ba37aae11a96e28fd6abf821b96
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/3d0e73a0e9c2e3f7b66f52a159e41233dcb866ba...0c06c384bc443ba37aae11a96e28fd6abf821b96
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