[vlc-commits] macosx/library: expose annotation information in video section

Felix Paul Kühne git at videolan.org
Mon Apr 29 19:27:09 CEST 2019


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Apr 28 16:17:01 2019 +0200| [83bc2b9e998d8f2c590a4444ff80765e0c7b2d63] | committer: Felix Paul Kühne

macosx/library: expose annotation information in video section

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=83bc2b9e998d8f2c590a4444ff80765e0c7b2d63
---

 modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib | 15 +++++++++++++--
 modules/gui/macosx/extensions/NSColor+VLCAdditions.h   |  2 ++
 modules/gui/macosx/extensions/NSColor+VLCAdditions.m   | 10 ++++++++++
 .../gui/macosx/library/VLCLibraryCollectionViewItem.h  |  1 +
 .../gui/macosx/library/VLCLibraryCollectionViewItem.m  | 18 ++++++++++++++++++
 modules/gui/macosx/library/VLCLibraryDataTypes.h       |  1 +
 modules/gui/macosx/library/VLCLibraryDataTypes.m       |  3 +++
 7 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib b/modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib
index 87147d3da2..ae7468c34e 100644
--- a/modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib
+++ b/modules/gui/macosx/UI/VLCLibraryCollectionViewItem.xib
@@ -8,6 +8,7 @@
         <customObject id="-2" userLabel="File's Owner" customClass="VLCLibraryCollectionViewItem">
             <connections>
                 <outlet property="addToPlaylistButton" destination="Ubz-8I-W2F" id="k0q-b1-PZi"/>
+                <outlet property="annotationTextField" destination="tm2-NW-WsZ" id="Miy-RS-Rol"/>
                 <outlet property="durationTextField" destination="VAn-gF-QiZ" id="U8T-Cs-HaL"/>
                 <outlet property="mediaImageView" destination="2aB-sB-hfY" id="Sv0-G1-KNm"/>
                 <outlet property="mediaTitleTextField" destination="OBS-Eh-1mT" id="h1n-PU-IAx"/>
@@ -34,6 +35,14 @@
                                 <action selector="playInstantly:" target="-2" id="E2B-oj-rx3"/>
                             </connections>
                         </button>
+                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tm2-NW-WsZ">
+                            <rect key="frame" x="12" y="144" width="37" height="17"/>
+                            <textFieldCell key="cell" lineBreakMode="clipping" title="Label" drawsBackground="YES" id="tyb-Ur-7J9">
+                                <font key="font" metaFont="system"/>
+                                <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
+                                <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                            </textFieldCell>
+                        </textField>
                     </subviews>
                     <constraints>
                         <constraint firstItem="S3I-5Z-qgS" firstAttribute="centerX" secondItem="2aB-sB-hfY" secondAttribute="centerX" id="Seo-tS-piW"/>
@@ -58,7 +67,7 @@
                     </textFieldCell>
                 </textField>
                 <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ubz-8I-W2F">
-                    <rect key="frame" x="216" y="174" width="20" height="20"/>
+                    <rect key="frame" x="216" y="187" width="20" height="20"/>
                     <constraints>
                         <constraint firstAttribute="width" constant="20" id="XhX-7U-Nxj"/>
                         <constraint firstAttribute="height" constant="20" id="ZDT-YM-Cbr"/>
@@ -75,10 +84,12 @@
             <constraints>
                 <constraint firstItem="VAn-gF-QiZ" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="0TA-ug-pKW"/>
                 <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="OBS-Eh-1mT" secondAttribute="trailing" id="457-oy-EbD"/>
-                <constraint firstItem="Ubz-8I-W2F" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="20" id="8Qf-Un-Gdl"/>
+                <constraint firstItem="Ubz-8I-W2F" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="7" id="8Qf-Un-Gdl"/>
                 <constraint firstAttribute="bottom" secondItem="VAn-gF-QiZ" secondAttribute="bottom" id="Kp0-Hx-3Ek"/>
                 <constraint firstItem="2aB-sB-hfY" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="YP6-lv-ECe"/>
                 <constraint firstAttribute="trailing" secondItem="Ubz-8I-W2F" secondAttribute="trailing" constant="20" id="ZVz-SL-rxZ"/>
+                <constraint firstItem="tm2-NW-WsZ" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="7" id="cvk-A5-enS"/>
+                <constraint firstItem="tm2-NW-WsZ" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="12" id="fH0-Om-7gV"/>
                 <constraint firstAttribute="trailing" secondItem="2aB-sB-hfY" secondAttribute="trailing" id="oZw-Ab-83p"/>
                 <constraint firstItem="2aB-sB-hfY" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="t9g-tX-AQX"/>
                 <constraint firstItem="OBS-Eh-1mT" firstAttribute="top" secondItem="2aB-sB-hfY" secondAttribute="bottom" constant="4" id="vJy-Kf-4Jh"/>
diff --git a/modules/gui/macosx/extensions/NSColor+VLCAdditions.h b/modules/gui/macosx/extensions/NSColor+VLCAdditions.h
index 0c46aff91a..122f44e4e9 100644
--- a/modules/gui/macosx/extensions/NSColor+VLCAdditions.h
+++ b/modules/gui/macosx/extensions/NSColor+VLCAdditions.h
@@ -30,6 +30,8 @@ NS_ASSUME_NONNULL_BEGIN
 + (instancetype)VLClibraryLightTitleColor;
 + (instancetype)VLClibraryDarkTitleColor;
 + (instancetype)VLClibrarySubtitleColor;
++ (instancetype)VLClibraryAnnotationColor;
++ (instancetype)VLClibraryAnnotationBackgroundColor;
 + (instancetype)VLClibrarySeparatorLightColor;
 + (instancetype)VLClibrarySeparatorDarkColor;
 
diff --git a/modules/gui/macosx/extensions/NSColor+VLCAdditions.m b/modules/gui/macosx/extensions/NSColor+VLCAdditions.m
index 33b3723fa1..5f9db425d6 100644
--- a/modules/gui/macosx/extensions/NSColor+VLCAdditions.m
+++ b/modules/gui/macosx/extensions/NSColor+VLCAdditions.m
@@ -44,6 +44,16 @@
     return [NSColor colorWithRed:0.52 green:0.57 blue:0.61 alpha:1.];
 }
 
++ (instancetype)VLClibraryAnnotationColor
+{
+    return [NSColor whiteColor];
+}
+
++ (instancetype)VLClibraryAnnotationBackgroundColor
+{
+    return [NSColor colorWithRed:0. green:0. blue:0. alpha:.4];
+}
+
 + (instancetype)VLClibrarySeparatorLightColor
 {
     return [NSColor colorWithRed:0.89 green:0.91 blue:0.93 alpha:1.];
diff --git a/modules/gui/macosx/library/VLCLibraryCollectionViewItem.h b/modules/gui/macosx/library/VLCLibraryCollectionViewItem.h
index df25052046..b35d009f02 100644
--- a/modules/gui/macosx/library/VLCLibraryCollectionViewItem.h
+++ b/modules/gui/macosx/library/VLCLibraryCollectionViewItem.h
@@ -32,6 +32,7 @@ extern NSString *VLCLibraryCellIdentifier;
 @interface VLCLibraryCollectionViewItem : NSCollectionViewItem
 
 @property (readwrite, assign) IBOutlet NSTextField *mediaTitleTextField;
+ at property (readwrite, assign) IBOutlet NSTextField *annotationTextField;
 @property (readwrite, assign) IBOutlet NSTextField *durationTextField;
 @property (readwrite, assign) IBOutlet VLCImageView *mediaImageView;
 @property (readwrite, assign) IBOutlet NSButton *playInstantlyButton;
diff --git a/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m b/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
index 84817d54ad..b907e5d8b0 100644
--- a/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
+++ b/modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
@@ -65,6 +65,11 @@ NSString *VLCLibraryCellIdentifier = @"VLCLibraryCellIdentifier";
     self.mediaTitleTextField.font = [NSFont VLClibraryCellTitleFont];
     self.durationTextField.font = [NSFont VLClibraryCellSubtitleFont];
     self.durationTextField.textColor = [NSColor VLClibrarySubtitleColor];
+    self.annotationTextField.font = [NSFont VLClibraryCellAnnotationFont];
+    self.annotationTextField.textColor = [NSColor VLClibraryAnnotationColor];
+    self.annotationTextField.backgroundColor = [NSColor VLClibraryAnnotationBackgroundColor];
+    self.annotationTextField.bezeled = YES;
+    self.annotationTextField.bezelStyle = NSTextFieldRoundedBezel;
 
     if (@available(macOS 10_14, *)) {
         [[NSApplication sharedApplication] addObserver:self
@@ -142,6 +147,19 @@ NSString *VLCLibraryCellIdentifier = @"VLCLibraryCellIdentifier";
         image = [NSImage imageNamed: @"noart.png"];
     }
     _mediaImageView.image = image;
+
+    VLCMediaLibraryTrack *videoTrack = _representedMediaItem.firstVideoTrack;
+    CGFloat width = videoTrack.videoWidth;
+    CGFloat height = videoTrack.videoHeight;
+    if (width >= 3840. || height >= 2160.) {
+        _annotationTextField.stringValue = @" 4K ";
+        _annotationTextField.hidden = NO;
+    } else if (width >= 1280. || height >= 720.) {
+        _annotationTextField.stringValue = @" HD ";
+        _annotationTextField.hidden = NO;
+    } else {
+        _annotationTextField.hidden = YES;
+    }
 }
 
 #pragma mark - actions
diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.h b/modules/gui/macosx/library/VLCLibraryDataTypes.h
index c92b76480f..c5789b4767 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.h
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.h
@@ -102,6 +102,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (readonly) NSArray <VLCMediaLibraryFile *> *files;
 @property (readonly) NSArray <VLCMediaLibraryTrack *> *tracks;
+ at property (readonly, nullable) VLCMediaLibraryTrack *firstVideoTrack;
 
 @property (readonly) int32_t year;
 @property (readonly) int64_t duration; /* Duration in milliseconds */
diff --git a/modules/gui/macosx/library/VLCLibraryDataTypes.m b/modules/gui/macosx/library/VLCLibraryDataTypes.m
index 9d682cff0c..9ea940b9b0 100644
--- a/modules/gui/macosx/library/VLCLibraryDataTypes.m
+++ b/modules/gui/macosx/library/VLCLibraryDataTypes.m
@@ -150,6 +150,9 @@
             VLCMediaLibraryTrack *track = [[VLCMediaLibraryTrack alloc] initWithTrack:&p_mediaItem->p_tracks->p_items[x]];
             if (track) {
                 [mutArray addObject:track];
+                if (track.trackType == VLC_ML_TRACK_TYPE_VIDEO && _firstVideoTrack == nil) {
+                    _firstVideoTrack = track;
+                }
             }
         }
         _tracks = [mutArray copy];



More information about the vlc-commits mailing list