[vlc-commits] [Git][videolan/vlc][master] 4 commits: macosx: Add function to fetch labels for a media library item
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Aug 9 12:15:23 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
84aceae0 by Claudio Cambra at 2024-08-09T12:01:36+00:00
macosx: Add function to fetch labels for a media library item
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
6e6ccc50 by Claudio Cambra at 2024-08-09T12:01:36+00:00
macosx: Add labels property to media library item protocol
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
0cb68b52 by Claudio Cambra at 2024-08-09T12:01:36+00:00
macosx: Add media item labels stack view and labels textfield to media item supplementary detail view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
4c595eeb by Claudio Cambra at 2024-08-09T12:01:36+00:00
macosx: Configure presentation of labels in updateRepresentation of media item supplementary detail view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
5 changed files:
- modules/gui/macosx/UI/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.xib
- modules/gui/macosx/library/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.h
- modules/gui/macosx/library/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.m
- modules/gui/macosx/library/VLCLibraryDataTypes.h
- modules/gui/macosx/library/VLCLibraryDataTypes.m
Changes:
=====================================
modules/gui/macosx/UI/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.xib
=====================================
@@ -80,10 +80,10 @@
</customSpacing>
</stackView>
<stackView distribution="fillEqually" orientation="vertical" alignment="leading" spacing="5" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" horizontalCompressionResistancePriority="250" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bw7-QB-Ssc">
- <rect key="frame" x="200" y="115" width="877" height="110"/>
+ <rect key="frame" x="200" y="94" width="877" height="131"/>
<subviews>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nCe-dY-YMM">
- <rect key="frame" x="-2" y="84" width="167" height="26"/>
+ <rect key="frame" x="-2" y="105" width="167" height="26"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" title="Media item name" id="6RM-x8-Y4y">
<font key="font" textStyle="title1" name=".SFNS-Regular"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
@@ -91,7 +91,7 @@
</textFieldCell>
</textField>
<stackView distribution="fill" orientation="horizontal" alignment="top" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="JzZ-K9-xaP">
- <rect key="frame" x="0.0" y="63" width="417" height="16"/>
+ <rect key="frame" x="0.0" y="84" width="417" height="16"/>
<subviews>
<button verticalHuggingPriority="750" horizontalCompressionResistancePriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="S5i-gd-zkt">
<rect key="frame" x="0.0" y="0.0" width="196" height="16"/>
@@ -132,7 +132,7 @@
</customSpacing>
</stackView>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="QuO-3G-BMT">
- <rect key="frame" x="-2" y="42" width="94" height="16"/>
+ <rect key="frame" x="-2" y="63" width="94" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Year · Duration" id="JBg-wo-ZeE">
<font key="font" metaFont="system"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
@@ -140,7 +140,7 @@
</textFieldCell>
</textField>
<stackView distribution="fill" orientation="horizontal" alignment="top" spacing="5" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fiJ-9f-ecF">
- <rect key="frame" x="0.0" y="21" width="106" height="16"/>
+ <rect key="frame" x="0.0" y="42" width="106" height="16"/>
<subviews>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="NZk-WW-Uay">
<rect key="frame" x="-2" y="0.0" width="72" height="16"/>
@@ -168,6 +168,38 @@
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
+ <stackView distribution="fill" orientation="horizontal" alignment="top" spacing="5" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ebw-bB-VfF">
+ <rect key="frame" x="0.0" y="21" width="85" height="16"/>
+ <subviews>
+ <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" verticalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="uhm-9P-6qk">
+ <rect key="frame" x="-2" y="0.0" width="51" height="16"/>
+ <textFieldCell key="cell" lineBreakMode="clipping" title="Labels:" id="FCe-hT-5o4">
+ <font key="font" metaFont="systemBold"/>
+ <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ </textField>
+ <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="HyO-9K-R7L">
+ <rect key="frame" x="50" y="0.0" width="37" height="16"/>
+ <textFieldCell key="cell" title="Label" id="eIz-b2-2PE">
+ <font key="font" usesAppearanceFont="YES"/>
+ <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+ </textFieldCell>
+ </textField>
+ </subviews>
+ <constraints>
+ <constraint firstAttribute="height" secondItem="HyO-9K-R7L" secondAttribute="height" id="a6R-zu-2jO"/>
+ </constraints>
+ <visibilityPriorities>
+ <integer value="1000"/>
+ <integer value="1000"/>
+ </visibilityPriorities>
+ <customSpacing>
+ <real value="3.4028234663852886e+38"/>
+ <real value="3.4028234663852886e+38"/>
+ </customSpacing>
+ </stackView>
<stackView distribution="fill" orientation="horizontal" alignment="top" spacing="5" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="B2d-Zo-xAO">
<rect key="frame" x="0.0" y="0.0" width="72" height="16"/>
<subviews>
@@ -207,6 +239,7 @@
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
+ <integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
@@ -214,6 +247,7 @@
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
+ <real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
@@ -248,6 +282,8 @@
<outlet property="contentViewTopConstraint" destination="Mr1-w0-CQK" id="T0p-C1-1nv"/>
<outlet property="mediaItemArtworkImageView" destination="xZd-Hk-h2M" id="J8l-V9-P06"/>
<outlet property="mediaItemFileNameTextField" destination="VxL-BW-3eh" id="fiL-3N-m3P"/>
+ <outlet property="mediaItemLabelsStackView" destination="ebw-bB-VfF" id="nNJ-gF-ib6"/>
+ <outlet property="mediaItemLabelsTextField" destination="HyO-9K-R7L" id="5V0-iU-KA0"/>
<outlet property="mediaItemPathTextField" destination="7gY-3s-Kay" id="P4t-h1-m3P"/>
<outlet property="mediaItemPrimaryDetailButton" destination="S5i-gd-zkt" id="ssB-Jg-jcf"/>
<outlet property="mediaItemSecondaryDetailButton" destination="9CH-03-Iu3" id="J8O-hB-tHb"/>
=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.h
=====================================
@@ -38,6 +38,8 @@ extern NSCollectionViewSupplementaryElementKind const VLCLibraryCollectionViewMe
@property (readwrite, weak) IBOutlet NSTextField *mediaItemYearAndDurationTextField;
@property (readwrite, weak) IBOutlet NSTextField *mediaItemFileNameTextField;
@property (readwrite, weak) IBOutlet NSTextField *mediaItemPathTextField;
+ at property (readwrite, weak) IBOutlet NSStackView *mediaItemLabelsStackView;
+ at property (readwrite, weak) IBOutlet NSTextField *mediaItemLabelsTextField;
@property (readwrite, weak) IBOutlet VLCImageView *mediaItemArtworkImageView;
@property (readwrite, weak) IBOutlet NSButton *playMediaItemButton;
=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewMediaItemSupplementaryDetailView.m
=====================================
@@ -113,6 +113,12 @@ NSCollectionViewSupplementaryElementKind const VLCLibraryCollectionViewMediaItem
self.mediaItemPrimaryDetailButton.action = @selector(primaryDetailAction:);
self.mediaItemSecondaryDetailButton.action = @selector(secondaryDetailAction:);
+ NSArray<NSString *> * const mediaItemLabels = self.representedItem.item.labels;
+ self.mediaItemLabelsStackView.hidden = mediaItemLabels.count == 0;
+ if (!self.mediaItemLabelsStackView.hidden) {
+ self.mediaItemLabelsTextField.stringValue = [mediaItemLabels componentsJoinedByString:@", "];
+ }
+
[VLCLibraryImageCache thumbnailForLibraryItem:actualItem withCompletion:^(NSImage * const thumbnail) {
self->_mediaItemArtworkImageView.image = thumbnail;
}];
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.h
=====================================
@@ -148,6 +148,7 @@ typedef NS_ENUM(NSUInteger, VLCMediaLibraryParentGroupType) {
@property (readonly) id<VLCMediaLibraryItemProtocol> primaryActionableDetailLibraryItem;
@property (readonly) BOOL secondaryActionableDetail;
@property (readonly) id<VLCMediaLibraryItemProtocol> secondaryActionableDetailLibraryItem;
+ at property (readonly) NSArray<NSString *> *labels;
- (void)iterateMediaItemsWithBlock:(void (^)(VLCMediaLibraryMediaItem*))mediaItemBlock;
=====================================
modules/gui/macosx/library/VLCLibraryDataTypes.m
=====================================
@@ -114,6 +114,26 @@ static NSArray<VLCMediaLibraryArtist *> *fetchArtistsForLibraryItem(library_arti
return [mutableArray copy];
}
+static NSArray<NSString *> *labelsForMediaLibraryItem(const int64_t libraryID) {
+ vlc_medialibrary_t * const p_mediaLibrary = getMediaLibrary();
+ if (!p_mediaLibrary) {
+ return @[];
+ }
+
+ vlc_ml_label_list_t * const vlc_labels =
+ vlc_ml_list_media_labels(p_mediaLibrary, NULL, libraryID);
+ if (!vlc_labels) {
+ return @[];
+ }
+
+ NSMutableArray<NSString *> * const labels = NSMutableArray.array;
+ for (size_t i = 0; i < vlc_labels->i_nb_items; i++) {
+ vlc_ml_label_t * const label = &vlc_labels->p_items[i];
+ [labels addObject:toNSStr(label->psz_name)];
+ }
+ return labels.copy;
+}
+
static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const genres)
{
const NSUInteger genreCount = genres.count;
@@ -286,6 +306,7 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
@property (readwrite, atomic, strong) NSString *primaryDetailString;
@property (readwrite, atomic, strong) NSString *secondaryDetailString;
@property (readwrite, atomic, strong) NSString *durationString;
+ at property (readwrite, atomic, strong, nullable) NSArray<NSString *> *internalLabels;
@end
@@ -331,6 +352,14 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
[self doesNotRecognizeSelector:_cmd];
}
+- (NSArray<NSString *> *)labels
+{
+ if (self.internalLabels == nil) {
+ self.internalLabels = labelsForMediaLibraryItem(self.libraryID);
+ }
+ return self.internalLabels;
+}
+
@end
@interface VLCAbstractMediaLibraryAudioGroup ()
@@ -925,6 +954,7 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
@interface VLCMediaLibraryMediaItem ()
@property (readwrite, assign) vlc_medialibrary_t *p_mediaLibrary;
+ at property (readwrite, strong, atomic, nullable) NSArray<NSString *> *internalLabels;
@end
@@ -1525,6 +1555,14 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
[libraryController reloadMediaLibraryFoldersForInputItems:@[self.inputItem]];
}
+- (NSArray<NSString *> *)labels
+{
+ if (self.internalLabels == nil) {
+ self.internalLabels = labelsForMediaLibraryItem(self.libraryID);
+ }
+ return self.internalLabels;
+}
+
@end
@implementation VLCMediaLibraryShow
@@ -1604,6 +1642,7 @@ static NSString *genreArrayDisplayString(NSArray<VLCMediaLibraryGenre *> * const
@synthesize primaryActionableDetailLibraryItem = _primaryActionableDetailLibraryItem;
@synthesize secondaryActionableDetail = _secondaryActionableDetail;
@synthesize secondaryActionableDetailLibraryItem = _secondaryActionableDetailLibraryItem;
+ at synthesize labels = _labels;
- (instancetype)initWithDisplayString:(NSString *)displayString
withPrimaryDetailString:(nullable NSString *)primaryDetailString
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6880921445bc38e6294ed6ebb52d08e731320c73...4c595eebe8144d3d4537e72d98e2d1f0e5e028aa
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6880921445bc38e6294ed6ebb52d08e731320c73...4c595eebe8144d3d4537e72d98e2d1f0e5e028aa
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