[vlc-commits] [Git][videolan/vlc][master] macosx: Hide disclosure caret when nav sidebar item collapsing is disabled
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Sun Jul 6 17:19:15 UTC 2025
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
8f472e6f by Claudio Cambra at 2025-07-06T17:06:20+00:00
macosx: Hide disclosure caret when nav sidebar item collapsing is disabled
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
3 changed files:
- modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarOutlineView.h
- modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarOutlineView.m
- modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarViewController.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarOutlineView.h
=====================================
@@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCLibraryWindowNavigationSidebarOutlineView : NSOutlineView
+- (void)refreshDisclosureCaret;
+
@end
NS_ASSUME_NONNULL_END
=====================================
modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarOutlineView.m
=====================================
@@ -29,6 +29,67 @@
@implementation VLCLibraryWindowNavigationSidebarOutlineView
+- (NSRect)frameOfOutlineCellAtRow:(NSInteger)row
+{
+ if ([self shouldHideDisclosureCaretAtRow:row]) {
+ return NSZeroRect;
+ }
+ return [super frameOfOutlineCellAtRow:row];
+}
+
+- (BOOL)shouldHideDisclosureCaretAtRow:(NSInteger)row
+{
+ const id item = [self itemAtRow:row];
+ if (![self isExpandable:item]) {
+ return NO;
+ }
+
+ NSTreeNode * const treeNode = (NSTreeNode *)item;
+ VLCLibrarySegment * const segment = (VLCLibrarySegment *)treeNode.representedObject;
+
+ if (self.selectedRow < 0 || self.selectedRow >= self.numberOfRows) {
+ return NO; // No valid selection
+ }
+
+ NSTreeNode * const selectedSegmentItem = (NSTreeNode *)[self itemAtRow:self.selectedRow];
+ if (selectedSegmentItem == nil) {
+ return NO;
+ }
+
+ VLCLibrarySegment * const selectedSegment = (VLCLibrarySegment *)selectedSegmentItem.representedObject;
+ if (selectedSegment == nil) {
+ return NO;
+ }
+
+ const NSInteger childNodeIndex = [segment.childNodes indexOfObjectPassingTest:^BOOL(NSTreeNode * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
+ VLCLibrarySegment * const childSegment = (VLCLibrarySegment *)obj;
+ return childSegment.segmentType == selectedSegment.segmentType;
+ }];
+
+ // Hide triangle when collapsing would be disabled
+ return childNodeIndex != NSNotFound;
+}
+
+- (void)selectRowIndexes:(NSIndexSet *)indexes byExtendingSelection:(BOOL)extend
+{
+ [super selectRowIndexes:indexes byExtendingSelection:extend];
+ [self refreshDisclosureCaret];
+}
+
+- (void)refreshDisclosureCaret
+{
+ const NSInteger rowCount = self.numberOfRows;
+ for (NSInteger row = 0; row < rowCount; row++) {
+ const id item = [self itemAtRow:row];
+ if ([self isExpandable:item]) {
+ [self reloadItem:item reloadChildren:NO];
+ }
+ }
+
+ [self setNeedsDisplay:YES];
+ [self displayIfNeeded];
+}
+
- (NSMenu *)menuForEvent:(NSEvent *)event
{
const NSPoint location = [self convertPoint:event.locationInWindow fromView:nil];
=====================================
modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarViewController.m
=====================================
@@ -394,6 +394,9 @@ static NSString * const VLCLibrarySegmentCellIdentifier = @"VLCLibrarySegmentCel
} else if ([representedObject isKindOfClass:VLCMediaLibraryGroup.class]) {
[self.libraryWindow presentLibraryItem:(VLCMediaLibraryGroup *)representedObject];
}
+
+ // Refresh disclosure triangles when selection changes
+ [(VLCLibraryWindowNavigationSidebarOutlineView *)self.outlineView refreshDisclosureCaret];
}
- (BOOL)outlineView:(NSOutlineView*)outlineView isGroupItem:(id)item
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8f472e6f4da1b3adbef29ed92413b23f05429eba
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8f472e6f4da1b3adbef29ed92413b23f05429eba
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