[vlc-commits] [Git][videolan/vlc][master] 7 commits: macosx: Add vlc title segment type

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Fri Sep 13 17:01:13 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
6d934962 by Claudio Cambra at 2024-09-13T16:49:27+00:00
macosx: Add vlc title segment type

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

- - - - -
c58b63b7 by Claudio Cambra at 2024-09-13T16:49:27+00:00
macosx: Add VLCLibraryHeaderSegment

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

- - - - -
feea59c2 by Claudio Cambra at 2024-09-13T16:49:27+00:00
macosx: Properly handle new header segment types' selection

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

- - - - -
5b0cf3e4 by Claudio Cambra at 2024-09-13T16:49:27+00:00
macosx: Classify header segment types as group items

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

- - - - -
24064c19 by Claudio Cambra at 2024-09-13T16:49:27+00:00
macosx: Remove defaults from segment switches

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

- - - - -
c38e7326 by Claudio Cambra at 2024-09-13T16:49:27+00:00
macosx: Give library header segment an icon

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

- - - - -
4e64551d by Claudio Cambra at 2024-09-13T16:49:27+00:00
macosx: Fix switch case and return warnings in VLCLibrarySegment

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

- - - - -


4 changed files:

- modules/gui/macosx/library/VLCLibrarySegment.h
- modules/gui/macosx/library/VLCLibrarySegment.m
- modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarViewController.m
- modules/gui/macosx/library/VLCLibraryWindowToolbarDelegate.m


Changes:

=====================================
modules/gui/macosx/library/VLCLibrarySegment.h
=====================================
@@ -29,6 +29,8 @@ extern NSString * const VLCLibraryBookmarkedLocationsChanged;
 
 typedef NS_ENUM(NSInteger, VLCLibrarySegmentType) {
     VLCLibraryLowSentinelSegment = -1,
+    VLCLibraryVLCTitleSegment,
+    VLCLibraryHeaderSegment,
     VLCLibraryHomeSegment,
     VLCLibraryVideoSegment,
     VLCLibraryShowsVideoSubSegment,


=====================================
modules/gui/macosx/library/VLCLibrarySegment.m
=====================================
@@ -42,6 +42,8 @@ NSString * const VLCLibraryBookmarkedLocationsChanged = @"VLCLibraryBookmarkedLo
 + (NSArray<VLCLibrarySegment *> *)librarySegments
 {
     return @[
+        [VLCLibrarySegment segmentWithSegmentType:VLCLibraryVLCTitleSegment],
+        [VLCLibrarySegment segmentWithSegmentType:VLCLibraryHeaderSegment],
         [VLCLibrarySegment segmentWithSegmentType:VLCLibraryHomeSegment],
         [VLCLibrarySegment segmentWithSegmentType:VLCLibraryVideoSegment],
         [VLCLibrarySegment segmentWithSegmentType:VLCLibraryMusicSegment],
@@ -179,6 +181,10 @@ NSString * const VLCLibraryBookmarkedLocationsChanged = @"VLCLibraryBookmarkedLo
 - (NSString *)displayStringForType:(VLCLibrarySegmentType)segmentType
 {
     switch (segmentType) {
+        case VLCLibraryVLCTitleSegment:
+            return _NS("VLC");
+        case VLCLibraryHeaderSegment:
+            return _NS("Library");
         case VLCLibraryHomeSegment:
             return _NS("Home");
         case VLCLibraryMusicSegment:
@@ -213,8 +219,7 @@ NSString * const VLCLibraryBookmarkedLocationsChanged = @"VLCLibraryBookmarkedLo
             NSAssert(NO, @"displayStringForType should not be called for this segment type");
         case VLCLibraryLowSentinelSegment:
         case VLCLibraryHighSentinelSegment:
-        default:
-            NSAssert(true, @"Invalid segment value");
+            NSAssert(NO, @"Invalid segment value");
     }
     return nil;
 }
@@ -222,6 +227,10 @@ NSString * const VLCLibraryBookmarkedLocationsChanged = @"VLCLibraryBookmarkedLo
 - (NSImage *)oldIconImageForType:(VLCLibrarySegmentType)segmentType
 {
     switch (segmentType) {
+        case VLCLibraryVLCTitleSegment:
+            return NSApp.applicationIconImage;
+        case VLCLibraryHeaderSegment:
+            return nil;
         case VLCLibraryHomeSegment:
             return [NSImage imageNamed:@"bw-home"];
         case VLCLibraryMusicSegment:
@@ -247,16 +256,24 @@ NSString * const VLCLibraryBookmarkedLocationsChanged = @"VLCLibraryBookmarkedLo
         case VLCLibraryGroupsSegment:
         case VLCLibraryGroupsGroupSubSegment:
             return [NSImage imageNamed:@"NSTouchBarTagIcon"];
-        default:
-            NSAssert(true, @"Invalid segment value");
+        case VLCLibraryLowSentinelSegment:
+        case VLCLibraryHighSentinelSegment:
+            NSAssert(NO, @"Invalid segment value");
             return nil;
     }
+
+    return nil;
 }
 
 - (NSImage *)newIconImageForType:(VLCLibrarySegmentType)segmentType
 {
     if (@available(macOS 11.0, *)) {
         switch (segmentType) {
+        case VLCLibraryVLCTitleSegment:
+            return NSApp.applicationIconImage;
+        case VLCLibraryHeaderSegment:
+            return [NSImage imageWithSystemSymbolName:@"books.vertical.fill"
+                             accessibilityDescription:@"Library icon"];
         case VLCLibraryHomeSegment:
             return [NSImage imageWithSystemSymbolName:@"house"
                              accessibilityDescription:@"Home icon"];
@@ -305,13 +322,13 @@ NSString * const VLCLibraryBookmarkedLocationsChanged = @"VLCLibraryBookmarkedLo
         case VLCLibraryGroupsGroupSubSegment:
             return [NSImage imageWithSystemSymbolName:@"play.rectangle"
                              accessibilityDescription:@"Group icon"];
-        default:
-            NSAssert(true, @"Invalid segment value");
+        case VLCLibraryLowSentinelSegment:
+        case VLCLibraryHighSentinelSegment:
+            NSAssert(NO, @"Invalid segment value");
             return nil;
         }
-    } else {
-        return nil;
     }
+    return nil;
 }
 
 - (NSImage *)iconForType:(VLCLibrarySegmentType)segmentType


=====================================
modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarViewController.m
=====================================
@@ -157,6 +157,10 @@ static NSString * const VLCLibrarySegmentCellIdentifier = @"VLCLibrarySegmentCel
              segmentType < VLCLibraryHighSentinelSegment,
              @"Invalid segment type value provided");
 
+    if (segmentType == VLCLibraryVLCTitleSegment || segmentType == VLCLibraryHeaderSegment) {
+        return;
+    }
+
     VLCLibrarySegment * const segment = [VLCLibrarySegment segmentWithSegmentType:segmentType];
     self.libraryWindow.librarySegmentType = segment.segmentType;
 
@@ -194,7 +198,10 @@ static NSString * const VLCLibrarySegmentCellIdentifier = @"VLCLibrarySegmentCel
         NSTreeNode * const node = [self.outlineView itemAtRow:proposedSelectionIndexes.firstIndex];
         VLCLibrarySegment * const segment = (VLCLibrarySegment *)node.representedObject;
 
-        if (segment.segmentType == VLCLibraryMusicSegment) {
+        if (segment.segmentType == VLCLibraryVLCTitleSegment ||
+            segment.segmentType == VLCLibraryHeaderSegment) {
+            return NSIndexSet.indexSet;
+        } else if (segment.segmentType == VLCLibraryMusicSegment) {
             [self.outlineView expandItem:[self nodeForSegmentType:VLCLibraryMusicSegment]];
             NSTreeNode * const artistsNode = [self nodeForSegmentType:VLCLibraryArtistsMusicSubSegment];
             const NSInteger artistsIndex = [self.outlineView rowForItem:artistsNode];
@@ -229,4 +236,11 @@ static NSString * const VLCLibrarySegmentCellIdentifier = @"VLCLibrarySegmentCel
     }
 }
 
+- (BOOL)outlineView:(NSOutlineView*)outlineView isGroupItem:(id)item
+{
+    NSTreeNode * const treeNode = (NSTreeNode *)item;
+    VLCLibrarySegment * const segment = (VLCLibrarySegment *)treeNode.representedObject;
+    return segment.segmentType == VLCLibraryHeaderSegment;
+}
+
 @end


=====================================
modules/gui/macosx/library/VLCLibraryWindowToolbarDelegate.m
=====================================
@@ -144,6 +144,8 @@ NSString * const VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier =
 {
     switch(segment) {
         case VLCLibraryLowSentinelSegment:
+        case VLCLibraryVLCTitleSegment:
+        case VLCLibraryHeaderSegment:
             vlc_assert_unreachable();
         case VLCLibraryHomeSegment:
             [self setForwardsBackwardsToolbarItemsVisible:NO];



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/69ad32384f749e9cd8f07dbb1a9854bde872bf7e...4e64551d00d1f2ee3bbb58bcd42e4c13662534b5

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/69ad32384f749e9cd8f07dbb1a9854bde872bf7e...4e64551d00d1f2ee3bbb58bcd42e4c13662534b5
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