[vlc-commits] [Git][videolan/vlc][master] 7 commits: macosx: Replace implementation of VLCLibraryInformationPanel with scrollable...

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Dec 16 11:06:03 UTC 2022



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
75497dfe by Claudio Cambra at 2022-12-16T10:50:30+00:00
macosx: Replace implementation of VLCLibraryInformationPanel with scrollable stackview, fixing numerous layout/visual bugs

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
5fb9e37b by Claudio Cambra at 2022-12-16T10:50:30+00:00
macosx: Improve layout of VLCLibraryInformationPanel

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
72b9b098 by Claudio Cambra at 2022-12-16T10:50:30+00:00
macosx: Extract VLCMediaLibraryMediaItem detail string generation into separate method in VLCLibraryInformationPanel

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
b6558d8c by Claudio Cambra at 2022-12-16T10:50:30+00:00
macosx: Extract VLCMediaLibraryTrack detail string generation into separate method in VLCLibraryInformationPanel

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
656c9617 by Claudio Cambra at 2022-12-16T10:50:30+00:00
macosx: Extract generic library item detail string generation into separate method in VLCLibraryInformationPanel

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
0f290781 by Claudio Cambra at 2022-12-16T10:50:30+00:00
macosx: Extract library item file detail string generation into separate method in VLCLibraryInformationPanel

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -
bcfac273 by Claudio Cambra at 2022-12-16T10:50:30+00:00
macosx: Remove redundancy in BOOL checks for strings in VLCLibraryInformationPanel

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


3 changed files:

- modules/gui/macosx/UI/VLCLibraryInformationPanel.xib
- modules/gui/macosx/library/VLCLibraryInformationPanel.h
- modules/gui/macosx/library/VLCLibraryInformationPanel.m


Changes:

=====================================
modules/gui/macosx/UI/VLCLibraryInformationPanel.xib
=====================================
@@ -8,7 +8,7 @@
         <customObject id="-2" userLabel="File's Owner" customClass="VLCLibraryInformationPanel">
             <connections>
                 <outlet property="imageView" destination="N4h-LP-IRY" id="Ned-Ju-hyu"/>
-                <outlet property="textView" destination="BG5-o2-dKa" id="Q6T-Ol-Gdc"/>
+                <outlet property="textField" destination="eeq-7b-IbI" id="tex-TF-135"/>
                 <outlet property="window" destination="oPi-wT-0nK" id="ODs-Hv-85I"/>
             </connections>
         </customObject>
@@ -21,60 +21,82 @@
             <rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
             <value key="minSize" type="size" width="386" height="227"/>
             <view key="contentView" id="Nfs-rF-cUN">
-                <rect key="frame" x="0.0" y="0.0" width="512" height="640"/>
-                <autoresizingMask key="autoresizingMask"/>
+                <rect key="frame" x="0.0" y="0.0" width="544" height="640"/>
+                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                 <subviews>
-                    <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="N4h-LP-IRY">
-                        <rect key="frame" x="20" y="20" width="472" height="295"/>
-                        <constraints>
-                            <constraint firstAttribute="width" secondItem="N4h-LP-IRY" secondAttribute="height" multiplier="16:10" id="bqe-XE-yWC"/>
-                        </constraints>
-                        <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" id="8o3-U6-XgQ"/>
-                    </imageView>
-                    <scrollView borderType="none" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qS0-eY-moI">
-                        <rect key="frame" x="20" y="335" width="472" height="285"/>
-                        <clipView key="contentView" drawsBackground="NO" id="a0y-wC-gCb">
-                            <rect key="frame" x="0.0" y="0.0" width="457" height="285"/>
+                    <scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JzV-HY-whQ">
+                        <rect key="frame" x="0.0" y="0.0" width="512" height="640"/>
+                        <clipView key="contentView" id="Bl4-q7-swx">
+                            <rect key="frame" x="1" y="1" width="495" height="623"/>
                             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                             <subviews>
-                                <textView editable="NO" drawsBackground="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" spellingCorrection="YES" smartInsertDelete="YES" id="BG5-o2-dKa">
-                                    <rect key="frame" x="0.0" y="0.0" width="457" height="285"/>
-                                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                                    <color key="textColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                    <color key="backgroundColor" red="0.89527153969999995" green="0.9043967128" blue="0.92996197940000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
-                                    <size key="minSize" width="457" height="285"/>
-                                    <size key="maxSize" width="555" height="10000000"/>
-                                    <attributedString key="textStorage">
-                                        <fragment content="Media info">
-                                            <attributes>
-                                                <color key="NSColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                                <font key="NSFont" metaFont="system"/>
-                                                <paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
-                                            </attributes>
-                                        </fragment>
-                                    </attributedString>
-                                    <color key="insertionPointColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                                </textView>
+                                <view translatesAutoresizingMaskIntoConstraints="NO" id="bU3-vL-IQb">
+                                    <rect key="frame" x="15" y="194" width="480" height="429"/>
+                                    <subviews>
+                                        <stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wv4-dn-5EA">
+                                            <rect key="frame" x="0.0" y="0.0" width="480" height="429"/>
+                                            <subviews>
+                                                <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="eeq-7b-IbI">
+                                                    <rect key="frame" x="0.0" y="408" width="495" height="21"/>
+                                                    <textFieldCell key="cell" selectable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" id="Jc0-rT-PNg">
+                                                        <font key="font" metaFont="system"/>
+                                                        <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+                                                        <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+                                                    </textFieldCell>
+                                                </textField>
+                                                <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="N4h-LP-IRY">
+                                                    <rect key="frame" x="0.0" y="0.0" width="400" height="400"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="width" secondItem="N4h-LP-IRY" secondAttribute="height" multiplier="1:1" id="0Uq-LT-xPG"/>
+                                                        <constraint firstAttribute="height" constant="400" id="wfM-2D-T6r"/>
+                                                    </constraints>
+                                                    <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" id="8o3-U6-XgQ"/>
+                                                </imageView>
+                                            </subviews>
+                                            <constraints>
+                                                <constraint firstAttribute="trailing" secondItem="eeq-7b-IbI" secondAttribute="trailing" id="hIV-HK-m3A"/>
+                                                <constraint firstItem="N4h-LP-IRY" firstAttribute="centerX" secondItem="Wv4-dn-5EA" secondAttribute="centerX" id="iwt-XU-iJg"/>
+                                                <constraint firstItem="eeq-7b-IbI" firstAttribute="leading" secondItem="Wv4-dn-5EA" secondAttribute="leading" id="k7h-rh-AJ1"/>
+                                            </constraints>
+                                            <visibilityPriorities>
+                                                <integer value="1000"/>
+                                                <integer value="1000"/>
+                                            </visibilityPriorities>
+                                            <customSpacing>
+                                                <real value="3.4028234663852886e+38"/>
+                                                <real value="3.4028234663852886e+38"/>
+                                            </customSpacing>
+                                        </stackView>
+                                    </subviews>
+                                    <constraints>
+                                        <constraint firstItem="Wv4-dn-5EA" firstAttribute="leading" secondItem="bU3-vL-IQb" secondAttribute="leading" id="9xr-fq-dnp"/>
+                                        <constraint firstItem="Wv4-dn-5EA" firstAttribute="top" secondItem="bU3-vL-IQb" secondAttribute="top" id="DTh-1O-MlM"/>
+                                        <constraint firstAttribute="bottom" secondItem="Wv4-dn-5EA" secondAttribute="bottom" id="vJ1-Jp-H6q"/>
+                                        <constraint firstAttribute="trailing" secondItem="Wv4-dn-5EA" secondAttribute="trailing" id="zuB-nh-60R"/>
+                                    </constraints>
+                                </view>
                             </subviews>
+                            <constraints>
+                                <constraint firstAttribute="trailing" secondItem="bU3-vL-IQb" secondAttribute="trailing" id="Xcb-WE-2PK"/>
+                                <constraint firstItem="bU3-vL-IQb" firstAttribute="top" secondItem="Bl4-q7-swx" secondAttribute="top" id="eEV-Ix-okb"/>
+                                <constraint firstItem="bU3-vL-IQb" firstAttribute="leading" secondItem="Bl4-q7-swx" secondAttribute="leading" id="oko-yV-hzs"/>
+                            </constraints>
                         </clipView>
-                        <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="zeg-Td-OE6">
-                            <rect key="frame" x="-100" y="-100" width="225" height="15"/>
+                        <scroller key="horizontalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="ePK-Cw-UmB">
+                            <rect key="frame" x="1" y="624" width="495" height="15"/>
                             <autoresizingMask key="autoresizingMask"/>
                         </scroller>
-                        <scroller key="verticalScroller" verticalHuggingPriority="750" horizontal="NO" id="b3U-Br-b1q">
-                            <rect key="frame" x="457" y="0.0" width="15" height="285"/>
+                        <scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="SJs-Xf-ZA5">
+                            <rect key="frame" x="496" y="1" width="15" height="623"/>
                             <autoresizingMask key="autoresizingMask"/>
                         </scroller>
                     </scrollView>
                 </subviews>
                 <constraints>
-                    <constraint firstAttribute="trailing" secondItem="qS0-eY-moI" secondAttribute="trailing" constant="20" id="5zW-yH-q6o"/>
-                    <constraint firstItem="qS0-eY-moI" firstAttribute="leading" secondItem="Nfs-rF-cUN" secondAttribute="leading" constant="20" id="XAb-wK-mSu"/>
-                    <constraint firstAttribute="trailing" secondItem="N4h-LP-IRY" secondAttribute="trailing" constant="20" id="cEY-J9-usm"/>
-                    <constraint firstItem="N4h-LP-IRY" firstAttribute="leading" secondItem="Nfs-rF-cUN" secondAttribute="leading" constant="20" id="kKf-aB-0vG"/>
-                    <constraint firstItem="qS0-eY-moI" firstAttribute="bottom" secondItem="N4h-LP-IRY" secondAttribute="top" constant="-20" id="mH4-ni-caL"/>
-                    <constraint firstItem="qS0-eY-moI" firstAttribute="top" secondItem="Nfs-rF-cUN" secondAttribute="top" constant="20" id="p0Y-Nb-dxf"/>
-                    <constraint firstAttribute="bottom" secondItem="N4h-LP-IRY" secondAttribute="bottom" constant="20" id="zc5-8x-CjC"/>
+                    <constraint firstAttribute="bottom" secondItem="JzV-HY-whQ" secondAttribute="bottom" id="BzO-t8-fnM"/>
+                    <constraint firstItem="JzV-HY-whQ" firstAttribute="top" secondItem="Nfs-rF-cUN" secondAttribute="top" id="Rs3-rb-V0C"/>
+                    <constraint firstAttribute="trailing" secondItem="JzV-HY-whQ" secondAttribute="trailing" id="cpi-7A-Gzv"/>
+                    <constraint firstItem="JzV-HY-whQ" firstAttribute="leading" secondItem="Nfs-rF-cUN" secondAttribute="leading" id="eFQ-HA-0eR"/>
                 </constraints>
             </view>
             <point key="canvasLocation" x="209.5" y="121"/>


=====================================
modules/gui/macosx/library/VLCLibraryInformationPanel.h
=====================================
@@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface VLCLibraryInformationPanel : NSWindowController
 
- at property (readwrite) IBOutlet NSTextView *textView;
+ at property (readwrite, weak) IBOutlet NSTextField *textField;
 @property (readwrite, weak) IBOutlet NSImageView *imageView;
 
 - (void)setRepresentedItem:(id<VLCMediaLibraryItemProtocol>)representedItem;


=====================================
modules/gui/macosx/library/VLCLibraryInformationPanel.m
=====================================
@@ -49,43 +49,90 @@
 {
     NSMutableString *textContent = [[NSMutableString alloc] initWithFormat:@"Title: '%@', ID: %lli\n", _representedItem.displayString, _representedItem.libraryID];
 
+    NSString *itemDetailsString;
     if([_representedItem isKindOfClass:[VLCMediaLibraryMediaItem class]]) {
-        VLCMediaLibraryMediaItem *mediaItem = (VLCMediaLibraryMediaItem *)_representedItem;
-        if (mediaItem.mediaSubType != VLC_ML_MEDIA_SUBTYPE_UNKNOWN) {
-            [textContent appendFormat:@"Type: %@ — %@\n", mediaItem.readableMediaType, mediaItem.readableMediaSubType];
-        } else {
-            [textContent appendFormat:@"Type: %@\n", mediaItem.readableMediaType];
-        }
-        [textContent appendFormat:@"Duration: %@\n", _representedItem.durationString];
-        [textContent appendFormat:@"Play count: %u, last played: %@\n", mediaItem.playCount, [NSDateFormatter localizedStringFromDate:[NSDate dateWithTimeIntervalSince1970:mediaItem.lastPlayedDate] dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle]];
-        [textContent appendFormat:@"Small artwork generated? %@\n", _representedItem.smallArtworkGenerated == YES ? _NS("Yes") : _NS("No")];
-        [textContent appendFormat:@"Favorited? %@\n", mediaItem.favorited == YES ? _NS("Yes") : _NS("No")];
-        [textContent appendFormat:@"Playback progress: %2.f%%\n", mediaItem.progress * 100.]; // TODO: Calculate progress for other library item types
-
-        [textContent appendFormat:@"\nNumber of tracks: %lu\n", mediaItem.tracks.count];
-        for (VLCMediaLibraryTrack *track in mediaItem.tracks) {
-            [textContent appendFormat:@"Type: %@\n", track.readableTrackType];
-            [textContent appendFormat:@"Codec: %@ (%@) @ %u kB/s\n", track.readableCodecName, track.codec, track.bitrate / 1024 / 8];
-            if (track.language.length > 0) {
-                [textContent appendFormat:@"Language: %@\n", track.language];
-            }
-            if (track.trackDescription.length > 0) {
-                [textContent appendFormat:@"Description: %@\n", track.trackDescription];
-            }
-
-            if (track.trackType == VLC_ML_TRACK_TYPE_AUDIO) {
-                [textContent appendFormat:@"Number of Channels: %u, Sample rate: %u\n", track.numberOfAudioChannels, track.audioSampleRate];
-            } else if (track.trackType == VLC_ML_TRACK_TYPE_VIDEO) {
-                [textContent appendFormat:@"Dimensions: %ux%u px, Aspect-Ratio: %2.f\n", track.videoWidth, track.videoHeight, (float)track.sourceAspectRatio / track.sourceAspectRatioDenominator];
-                [textContent appendFormat:@"Framerate: %2.f\n", (float)track.frameRate / track.frameRateDenominator];
-            }
-            [textContent appendString:@"\n"];
-        }
+        itemDetailsString = [self detailsStringForMediaItem:(VLCMediaLibraryMediaItem *)_representedItem];
+    } else {
+        itemDetailsString = [self detailsStringForLibraryItem:_representedItem];
+    }
+    [textContent appendString:itemDetailsString];
+    
+    NSString *fileDetailsString = [self fileDetailsStringForLibraryItem:_representedItem];
+    [textContent appendString:fileDetailsString];
+    
+    _textField.attributedStringValue = [[NSAttributedString alloc] initWithString:textContent];
+    _textField.font = [NSFont systemFontOfSize:13.];
+    _textField.textColor = [NSColor whiteColor];
+    _imageView.image = _representedItem.smallArtworkImage;
+    self.window.title = _representedItem.displayString;
+}
+
+- (NSString *)detailsStringForMediaItem:(VLCMediaLibraryMediaItem *)mediaItem
+{
+    NSMutableString *detailsString = [[NSMutableString alloc] init];
+
+    if (mediaItem.mediaSubType != VLC_ML_MEDIA_SUBTYPE_UNKNOWN) {
+        [detailsString appendFormat:@"Type: %@ — %@\n", mediaItem.readableMediaType, mediaItem.readableMediaSubType];
     } else {
-        [textContent appendFormat:@"Duration: %@\n", _representedItem.durationString];
-        [textContent appendFormat:@"Small artwork generated? %@\n", _representedItem.smallArtworkGenerated == YES ? _NS("Yes") : _NS("No")];
+        [detailsString appendFormat:@"Type: %@\n", mediaItem.readableMediaType];
+    }
+
+    [detailsString appendFormat:@"Duration: %@\n", _representedItem.durationString];
+
+    [detailsString appendFormat:@"Play count: %u, last played: %@\n", mediaItem.playCount, [NSDateFormatter localizedStringFromDate:[NSDate dateWithTimeIntervalSince1970:mediaItem.lastPlayedDate] dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle]];
+
+    [detailsString appendFormat:@"Small artwork generated? %@\n", _representedItem.smallArtworkGenerated ? _NS("Yes") : _NS("No")];
+
+    [detailsString appendFormat:@"Favorited? %@\n", mediaItem.favorited ? _NS("Yes") : _NS("No")];
+
+    [detailsString appendFormat:@"Playback progress: %2.f%%\n", mediaItem.progress * 100.]; // TODO: Calculate progress for other library item types
+
+    [detailsString appendFormat:@"\nNumber of tracks: %lu\n", mediaItem.tracks.count];
+
+    for (VLCMediaLibraryTrack *track in mediaItem.tracks) {
+        NSString *trackDetailsString = [self detailsStringForTrack:track];
+        [detailsString appendString:trackDetailsString];
     }
 
+    return detailsString;
+}
+
+- (NSString *)detailsStringForTrack:(VLCMediaLibraryTrack *)track
+{
+    NSMutableString *detailsString = [[NSMutableString alloc] init];
+
+    [detailsString appendFormat:@"Type: %@\n", track.readableTrackType];
+    [detailsString appendFormat:@"Codec: %@ (%@) @ %u kB/s\n", track.readableCodecName, track.codec, track.bitrate / 1024 / 8];
+    if (track.language.length > 0) {
+        [detailsString appendFormat:@"Language: %@\n", track.language];
+    }
+    if (track.trackDescription.length > 0) {
+        [detailsString appendFormat:@"Description: %@\n", track.trackDescription];
+    }
+
+    if (track.trackType == VLC_ML_TRACK_TYPE_AUDIO) {
+        [detailsString appendFormat:@"Number of Channels: %u, Sample rate: %u\n", track.numberOfAudioChannels, track.audioSampleRate];
+    } else if (track.trackType == VLC_ML_TRACK_TYPE_VIDEO) {
+        [detailsString appendFormat:@"Dimensions: %ux%u px, Aspect-Ratio: %2.f\n", track.videoWidth, track.videoHeight, (float)track.sourceAspectRatio / track.sourceAspectRatioDenominator];
+        [detailsString appendFormat:@"Framerate: %2.f\n", (float)track.frameRate / track.frameRateDenominator];
+    }
+    [detailsString appendString:@"\n"];
+
+    return detailsString;
+}
+
+- (NSString *)detailsStringForLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem
+{
+    NSMutableString *detailsString = [[NSMutableString alloc] init];
+
+    [detailsString appendFormat:@"Duration: %@\n", libraryItem.durationString];
+    [detailsString appendFormat:@"Small artwork generated? %@\n", libraryItem.smallArtworkGenerated ? _NS("Yes") : _NS("No")];
+
+    return detailsString;
+}
+
+- (NSString *)fileDetailsStringForLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem
+{
     __block NSUInteger fileCount = 0;
     NSMutableString *fileDetails = [[NSMutableString alloc] init];
 
@@ -96,14 +143,9 @@
             [fileDetails appendFormat:@"Type: %@\n", file.readableFileType];
         }
     }];
-    [textContent appendFormat:@"\nNumber of files: %lu\n", fileCount];
-    [textContent appendString: fileDetails];
-    
-    [self.textView.textStorage setAttributedString: [[NSAttributedString alloc] initWithString:textContent]];
-    self.textView.textStorage.font = [NSFont systemFontOfSize:13.];
-    self.textView.textStorage.foregroundColor = [NSColor whiteColor];
-    self.window.title = _representedItem.displayString;
-    self.imageView.image = _representedItem.smallArtworkImage;
+    [fileDetails appendFormat:@"\nNumber of files: %lu\n", fileCount];
+
+    return fileDetails;
 }
 
 @end



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9ec02f074b9e2850021f16d8e33d9b27206b73ff...bcfac2734b3e72fb09c36e2d07f42ef253293f0b

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9ec02f074b9e2850021f16d8e33d9b27206b73ff...bcfac2734b3e72fb09c36e2d07f42ef253293f0b
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