[vlc-commits] [Git][videolan/vlc][master] macosx: Add minor enhancements to library view
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun Jul 4 06:40:23 UTC 2021
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
24c76d8a by Samuel Bassaly at 2021-07-04T06:21:06+00:00
macosx: Add minor enhancements to library view
Add sorting functionality to audio media library.
Fix two minor gui bugs:
- Show the Recents label.
- Revert colors of the slider, so that it seems more natural.
Limit files shown under Recents to videos only.
- - - - -
3 changed files:
- modules/gui/macosx/library/VLCLibraryModel.m
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/views/VLCSliderCell.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryModel.m
=====================================
@@ -140,7 +140,8 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
- (void)updateCachedListOfAudioMedia
{
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
- vlc_ml_media_list_t *p_media_list = vlc_ml_list_audio_media(self->_p_mediaLibrary, NULL);
+ const vlc_ml_query_params_t queryParams = { .i_sort = self->_sortCriteria, .b_desc = self->_sortDescending };
+ vlc_ml_media_list_t *p_media_list = vlc_ml_list_audio_media(self->_p_mediaLibrary, &queryParams);
if (!p_media_list) {
return;
}
@@ -179,7 +180,8 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
- (void)updateCachedListOfArtists
{
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
- vlc_ml_artist_list_t *p_artist_list = vlc_ml_list_artists(self->_p_mediaLibrary, NULL, NO);
+ const vlc_ml_query_params_t queryParams = { .i_sort = self->_sortCriteria, .b_desc = self->_sortDescending };
+ vlc_ml_artist_list_t *p_artist_list = vlc_ml_list_artists(self->_p_mediaLibrary, &queryParams, NO);
NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_artist_list->i_nb_items];
for (size_t x = 0; x < p_artist_list->i_nb_items; x++) {
VLCMediaLibraryArtist *artist = [[VLCMediaLibraryArtist alloc] initWithArtist:&p_artist_list->p_items[x]];
@@ -214,7 +216,8 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
- (void)updateCachedListOfAlbums
{
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
- vlc_ml_album_list_t *p_album_list = vlc_ml_list_albums(self->_p_mediaLibrary, NULL);
+ const vlc_ml_query_params_t queryParams = { .i_sort = self->_sortCriteria, .b_desc = self->_sortDescending };
+ vlc_ml_album_list_t *p_album_list = vlc_ml_list_albums(self->_p_mediaLibrary, &queryParams);
NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_album_list->i_nb_items];
for (size_t x = 0; x < p_album_list->i_nb_items; x++) {
VLCMediaLibraryAlbum *album = [[VLCMediaLibraryAlbum alloc] initWithAlbum:&p_album_list->p_items[x]];
@@ -247,7 +250,8 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
- (void)updateCachedListOfGenres
{
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
- vlc_ml_genre_list_t *p_genre_list = vlc_ml_list_genres(self->_p_mediaLibrary, NULL);
+ const vlc_ml_query_params_t queryParams = { .i_sort = self->_sortCriteria, .b_desc = self->_sortDescending };
+ vlc_ml_genre_list_t *p_genre_list = vlc_ml_list_genres(self->_p_mediaLibrary, &queryParams);
NSMutableArray *mutableArray = [[NSMutableArray alloc] initWithCapacity:p_genre_list->i_nb_items];
for (size_t x = 0; x < p_genre_list->i_nb_items; x++) {
VLCMediaLibraryGenre *genre = [[VLCMediaLibraryGenre alloc] initWithGenre:&p_genre_list->p_items[x]];
@@ -282,11 +286,11 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
- (void)updateCachedListOfVideoMedia
{
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
- vlc_ml_query_params_t queryParameters;
- memset(&queryParameters, 0, sizeof(vlc_ml_query_params_t));
- queryParameters.i_nbResults = 0;
- queryParameters.i_sort = self->_sortCriteria;
- queryParameters.b_desc = self->_sortDescending;
+ const vlc_ml_query_params_t queryParameters = {
+ .i_nbResults = 0,
+ .i_sort = self->_sortCriteria,
+ .b_desc = self->_sortDescending
+ };
vlc_ml_media_list_t *p_media_list = vlc_ml_list_video_media(self->_p_mediaLibrary, &queryParameters);
if (p_media_list == NULL) {
return;
@@ -319,11 +323,10 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
- (void)updateCachedListOfRecentMedia
{
dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
- vlc_ml_query_params_t queryParameters;
- memset(&queryParameters, 0, sizeof(vlc_ml_query_params_t));
- queryParameters.i_nbResults = 20;
+ const vlc_ml_query_params_t queryParameters = { .i_nbResults = 20 };
// we don't set the sorting criteria here as they are not applicable to history
- vlc_ml_media_list_t *p_media_list = vlc_ml_list_history(self->_p_mediaLibrary, &queryParameters);
+ // we only show videos for recents
+ vlc_ml_media_list_t *p_media_list = vlc_ml_list_history_by_type(self->_p_mediaLibrary, &queryParameters, VLC_ML_MEDIA_TYPE_VIDEO);
if (p_media_list == NULL) {
return;
}
@@ -384,7 +387,8 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
- (nullable NSArray <VLCMediaLibraryAlbum *>*)listAlbumsOfParentType:(enum vlc_ml_parent_type)parentType forID:(int64_t)ID;
{
- vlc_ml_album_list_t *p_albumList = vlc_ml_list_albums_of(_p_mediaLibrary, NULL, parentType, ID);
+ const vlc_ml_query_params_t queryParams = { .i_sort = self->_sortCriteria, .b_desc = self->_sortDescending };
+ vlc_ml_album_list_t *p_albumList = vlc_ml_list_albums_of(_p_mediaLibrary, &queryParams, parentType, ID);
if (p_albumList == NULL) {
return nil;
}
@@ -407,6 +411,10 @@ static void libraryCallback(void *p_data, const vlc_ml_event_t *p_event)
- (void)dropCaches
{
_cachedVideoMedia = nil;
+ _cachedAlbums = nil;
+ _cachedGenres = nil;
+ _cachedArtists = nil;
+ _cachedAudioMedia = nil;
[_defaultNotificationCenter postNotificationName:VLCLibraryModelVideoMediaListUpdated object:nil];
}
=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -149,6 +149,14 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
selector:@selector(updateLibraryRepresentation:)
name:VLCLibraryModelAudioMediaListUpdated
object:nil];
+ [notificationCenter addObserver:self
+ selector:@selector(updateLibraryRepresentation:)
+ name:VLCLibraryModelArtistListUpdated
+ object:nil];
+ [notificationCenter addObserver:self
+ selector:@selector(updateLibraryRepresentation:)
+ name:VLCLibraryModelAlbumListUpdated
+ object:nil];
[notificationCenter addObserver:self
selector:@selector(updateLibraryRepresentation:)
name:VLCLibraryModelVideoMediaListUpdated
@@ -223,7 +231,11 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
_recentVideoLibraryCollectionView.dataSource = _libraryVideoDataSource;
_recentVideoLibraryCollectionView.delegate = _libraryVideoDataSource;
[_recentVideoLibraryCollectionView registerClass:[VLCLibraryCollectionViewItem class] forItemWithIdentifier:VLCLibraryCellIdentifier];
- [_videoLibraryCollectionView setDraggingSourceOperationMask:NSDragOperationCopy forLocal:NO];
+ [_recentVideoLibraryCollectionView registerClass:[VLCLibraryCollectionViewSupplementaryElementView class]
+ forSupplementaryViewOfKind:NSCollectionElementKindSectionHeader
+ withIdentifier:VLCLibrarySupplementaryElementViewIdentifier];
+ [(NSCollectionViewFlowLayout *)_recentVideoLibraryCollectionView.collectionViewLayout setHeaderReferenceSize:[VLCLibraryCollectionViewSupplementaryElementView defaultHeaderSize]];
+ [_recentVideoLibraryCollectionView setDraggingSourceOperationMask:NSDragOperationCopy forLocal:NO];
_libraryAudioDataSource = [[VLCLibraryAudioDataSource alloc] init];
_libraryAudioDataSource.libraryModel = mainInstance.libraryController.libraryModel;
@@ -631,8 +643,12 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
#pragma mark - library representation and interaction
- (void)updateLibraryRepresentation:(NSNotification *)aNotification
{
- [_videoLibraryCollectionView reloadData];
- [_recentVideoLibraryCollectionView reloadData];
+ if (_videoLibraryStackView.superview != nil) {
+ [_videoLibraryCollectionView reloadData];
+ [_recentVideoLibraryCollectionView reloadData];
+ } else if (_audioLibraryView.superview != nil) {
+ [_libraryAudioDataSource reloadAppearance];
+ }
}
#pragma mark -
=====================================
modules/gui/macosx/views/VLCSliderCell.m
=====================================
@@ -84,15 +84,15 @@
{
// Color Declarations
if (@available(macOS 10.14, *)) {
- _gradientColor = [NSColor colorWithCalibratedRed: 0.20 green: 0.20 blue: 0.20 alpha: 1];
+ _gradientColor2 = [NSColor colorWithCalibratedRed: 0.20 green: 0.20 blue: 0.20 alpha: 1];
_knobFillColor = [NSColor colorWithCalibratedRed: 0.81 green: 0.81 blue: 0.81 alpha: 1];
_activeKnobFillColor = [NSColor colorWithCalibratedRed: 0.76 green: 0.76 blue: 0.76 alpha: 1];
} else {
- _gradientColor = [NSColor colorWithCalibratedRed: 0.24 green: 0.24 blue: 0.24 alpha: 1];
+ _gradientColor2 = [NSColor colorWithCalibratedRed: 0.24 green: 0.24 blue: 0.24 alpha: 1];
_knobFillColor = [NSColor colorWithCalibratedRed: 1 green: 1 blue: 1 alpha: 1];
_activeKnobFillColor = [NSColor colorWithCalibratedRed: 0.95 green: 0.95 blue: 0.95 alpha: 1];
}
- _gradientColor2 = [NSColor colorWithCalibratedRed: 0.15 green: 0.15 blue: 0.15 alpha: 1];
+ _gradientColor = [NSColor colorWithCalibratedRed: 0.15 green: 0.15 blue: 0.15 alpha: 1];
_trackStrokeColor = [NSColor colorWithCalibratedRed: 0.23 green: 0.23 blue: 0.23 alpha: 1];
_filledTrackColor = [NSColor colorWithCalibratedRed: 0.15 green: 0.15 blue: 0.15 alpha: 1];
_shadowColor = [NSColor colorWithCalibratedRed: 0.32 green: 0.32 blue: 0.32 alpha: 1];
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/24c76d8af25efa5e5f589300adb85cbd479775ea
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/24c76d8af25efa5e5f589300adb85cbd479775ea
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list