[vlc-commits] [Git][videolan/vlc][master] 9 commits: macosx: Add highlight to media source collection view item XIB
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Dec 13 12:06:19 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
2a89d8f6 by Claudio Cambra at 2024-12-13T06:55:11+00:00
macosx: Add highlight to media source collection view item XIB
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
bf30d590 by Claudio Cambra at 2024-12-13T06:55:11+00:00
macosx: Update highlight depending on selection state in media source collection view item
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
fa4ff89c by Claudio Cambra at 2024-12-13T06:55:11+00:00
macosx: Extract input node from index path acquisition in media source data source to convenience method
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
5ce47e24 by Claudio Cambra at 2024-12-13T06:55:11+00:00
macosx: Add method to get input items at given index paths in VLCMediaSourceDataSource
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
664e16db by Claudio Cambra at 2024-12-13T06:55:11+00:00
macosx: Allow multiple selection in media source view controller's collection view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
5ea48c8d by Claudio Cambra at 2024-12-13T06:55:11+00:00
macosx: Do not trigger action for a given media source view input node if multiple items are selected
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
ca0ba22d by Claudio Cambra at 2024-12-13T06:55:11+00:00
macosx: Properly handle multiple media source view item selections with the context menu in collection view item
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
11ce45cd by Claudio Cambra at 2024-12-13T06:55:11+00:00
macosx: Fix wrong addInputItem behaviour in library menu controller
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
b49eeb41 by Claudio Cambra at 2024-12-13T06:55:11+00:00
macosx: Remove unneeded collectionview argument in mediaSourceInputItemsAtIndexPaths
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
7 changed files:
- modules/gui/macosx/UI/VLCMediaSourceCollectionViewItem.xib
- modules/gui/macosx/library/VLCLibraryMenuController.m
- modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.m
- modules/gui/macosx/library/media-source/VLCMediaSourceCollectionViewItem.h
- modules/gui/macosx/library/media-source/VLCMediaSourceCollectionViewItem.m
- modules/gui/macosx/library/media-source/VLCMediaSourceDataSource.h
- modules/gui/macosx/library/media-source/VLCMediaSourceDataSource.m
Changes:
=====================================
modules/gui/macosx/UI/VLCMediaSourceCollectionViewItem.xib
=====================================
@@ -9,6 +9,7 @@
<connections>
<outlet property="addToPlayQueueButton" destination="Ubz-8I-W2F" id="ywN-PH-QZt"/>
<outlet property="annotationTextField" destination="kHQ-HZ-YIi" id="XX9-Sc-oam"/>
+ <outlet property="highlightBox" destination="5Hg-64-CCp" id="Gc2-5h-Gj9"/>
<outlet property="mediaImageView" destination="2aB-sB-hfY" id="Sv0-G1-KNm"/>
<outlet property="mediaTitleTextField" destination="OBS-Eh-1mT" id="h1n-PU-IAx"/>
<outlet property="playInstantlyButton" destination="S3I-5Z-qgS" id="VV4-Lu-IMq"/>
@@ -51,7 +52,15 @@
<constraint firstItem="kHQ-HZ-YIi" firstAttribute="leading" secondItem="2aB-sB-hfY" secondAttribute="leading" constant="7" id="s9g-G1-oCF"/>
</constraints>
</customView>
- <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OBS-Eh-1mT">
+ <box boxType="custom" borderType="line" borderWidth="5" cornerRadius="4" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="5Hg-64-CCp">
+ <rect key="frame" x="0.0" y="32" width="207" height="207"/>
+ <view key="contentView" id="POR-eM-ISr">
+ <rect key="frame" x="5" y="5" width="197" height="197"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ </view>
+ <color key="borderColor" red="1" green="0.38123786450000002" blue="0.039215686270000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+ </box>
+ <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OBS-Eh-1mT">
<rect key="frame" x="-2" y="4" width="37" height="24"/>
<constraints>
<constraint firstAttribute="height" constant="24" id="wMC-00-Vuv"/>
@@ -80,9 +89,13 @@
<constraints>
<constraint firstItem="2aB-sB-hfY" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" id="3Ah-0T-rA9"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="OBS-Eh-1mT" secondAttribute="trailing" id="457-oy-EbD"/>
+ <constraint firstItem="5Hg-64-CCp" firstAttribute="leading" secondItem="2aB-sB-hfY" secondAttribute="leading" id="5Ac-bl-b4l"/>
<constraint firstItem="Ubz-8I-W2F" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="7" id="8Qf-Un-Gdl"/>
<constraint firstAttribute="trailing" secondItem="Ubz-8I-W2F" secondAttribute="trailing" constant="14" id="ZVz-SL-rxZ"/>
<constraint firstAttribute="bottom" secondItem="OBS-Eh-1mT" secondAttribute="bottom" constant="4" id="d6E-7J-S2d"/>
+ <constraint firstItem="5Hg-64-CCp" firstAttribute="bottom" secondItem="2aB-sB-hfY" secondAttribute="bottom" id="eRq-Jx-FiY"/>
+ <constraint firstItem="5Hg-64-CCp" firstAttribute="trailing" secondItem="2aB-sB-hfY" secondAttribute="trailing" id="ffy-WV-Vlh"/>
+ <constraint firstItem="5Hg-64-CCp" firstAttribute="top" secondItem="2aB-sB-hfY" secondAttribute="top" id="kUZ-iy-kzW"/>
<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"/>
=====================================
modules/gui/macosx/library/VLCLibraryMenuController.m
=====================================
@@ -164,7 +164,7 @@
playImmediately:(BOOL)playImmediately
{
NSParameterAssert(inputItem);
- [VLCMain.sharedInstance.playQueueController addInputItem:_representedInputItems.firstObject.vlcInputItem
+ [VLCMain.sharedInstance.playQueueController addInputItem:inputItem.vlcInputItem
atPosition:-1
startPlayback:playImmediately];
}
=====================================
modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.m
=====================================
@@ -95,8 +95,10 @@
- (void)setupCollectionView
{
+ self.collectionView.allowsMultipleSelection = YES;
+
VLCLibraryCollectionViewFlowLayout * const mediaSourceCollectionViewLayout = VLCLibraryCollectionViewFlowLayout.standardLayout;
- _collectionView.collectionViewLayout = mediaSourceCollectionViewLayout;
+ self.collectionView.collectionViewLayout = mediaSourceCollectionViewLayout;
mediaSourceCollectionViewLayout.itemSize = VLCLibraryCollectionViewItem.defaultSize;
}
=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceCollectionViewItem.h
=====================================
@@ -36,6 +36,7 @@ extern NSString *VLCMediaSourceCellIdentifier;
@property (readwrite, weak) IBOutlet VLCImageView *mediaImageView;
@property (readwrite, weak) IBOutlet NSButton *playInstantlyButton;
@property (readwrite, weak) IBOutlet NSButton *addToPlayQueueButton;
+ at property (readwrite, weak) IBOutlet NSBox *highlightBox;
@property (readwrite, strong, nonatomic) VLCInputItem *representedInputItem;
=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceCollectionViewItem.m
=====================================
@@ -31,6 +31,8 @@
#import "library/VLCLibraryMenuController.h"
#import "library/VLCLibraryImageCache.h"
+#import "library/media-source/VLCMediaSourceDataSource.h"
+
#import "main/VLCMain.h"
#import "playqueue/VLCPlayQueueController.h"
@@ -64,6 +66,7 @@ NSString *VLCMediaSourceCellIdentifier = @"VLCLibraryCellIdentifier";
self.annotationTextField.font = [NSFont systemFontOfSize:NSFont.systemFontSize weight:NSFontWeightBold];
self.annotationTextField.textColor = NSColor.VLClibraryAnnotationColor;
self.annotationTextField.backgroundColor = NSColor.VLClibraryAnnotationBackgroundColor;
+ self.highlightBox.borderColor = NSColor.VLCAccentColor;
if (@available(macOS 10.14, *)) {
[NSApplication.sharedApplication addObserver:self
@@ -110,6 +113,7 @@ NSString *VLCMediaSourceCellIdentifier = @"VLCLibraryCellIdentifier";
_annotationTextField.hidden = YES;
_mediaImageView.image = nil;
_addToPlayQueueButton.hidden = NO;
+ _highlightBox.hidden = YES;
}
- (void)setRepresentedInputItem:(VLCInputItem *)representedInputItem
@@ -118,6 +122,12 @@ NSString *VLCMediaSourceCellIdentifier = @"VLCLibraryCellIdentifier";
[self updateRepresentation];
}
+- (void)setSelected:(BOOL)selected
+{
+ super.selected = selected;
+ _highlightBox.hidden = !selected;
+}
+
- (void)updateRepresentation
{
if (_representedInputItem == nil) {
@@ -170,30 +180,49 @@ NSString *VLCMediaSourceCellIdentifier = @"VLCLibraryCellIdentifier";
[VLCMain.sharedInstance.playQueueController addInputItem:_representedInputItem.vlcInputItem atPosition:-1 startPlayback:NO];
}
--(void)mouseDown:(NSEvent *)theEvent
+- (void)openContextMenu:(NSEvent *)event
{
- if (theEvent.modifierFlags & NSControlKeyMask) {
- if (!_menuController) {
- _menuController = [[VLCLibraryMenuController alloc] init];
- }
+ if (!_menuController) {
+ _menuController = [[VLCLibraryMenuController alloc] init];
+ }
+
+ NSCollectionView * const collectionView = self.collectionView;
+ VLCMediaSourceDataSource * const dataSource =
+ (VLCMediaSourceDataSource *)collectionView.dataSource;
+ NSParameterAssert(dataSource != nil);
+ NSSet<NSIndexPath *> * const indexPaths = collectionView.selectionIndexPaths;
+ NSArray<VLCInputItem *> * const selectedInputItems =
+ [dataSource mediaSourceInputItemsAtIndexPaths:indexPaths];
+ const NSInteger mediaSourceItemIndex = [selectedInputItems indexOfObjectPassingTest:^BOOL(
+ VLCInputItem * const inputItem, const NSUInteger idx, BOOL * const stop
+ ) {
+ return [inputItem.MRL isEqualToString:_representedInputItem.MRL];
+ }];
+ NSArray<VLCInputItem *> *items = nil;
- [_menuController setRepresentedInputItems:@[_representedInputItem]];
- [_menuController popupMenuWithEvent:theEvent forView:self.view];
+ if (mediaSourceItemIndex == NSNotFound) {
+ items = @[_representedInputItem];
+ } else {
+ items = selectedInputItems;
}
- [super mouseDown:theEvent];
+ _menuController.representedInputItems = items;
+ [_menuController popupMenuWithEvent:event forView:self.view];
}
-- (void)rightMouseDown:(NSEvent *)theEvent
+-(void)mouseDown:(NSEvent *)event
{
- if (!_menuController) {
- _menuController = [[VLCLibraryMenuController alloc] init];
+ if (event.modifierFlags & NSControlKeyMask) {
+ [self openContextMenu:event];
}
- [_menuController setRepresentedInputItems:@[_representedInputItem]];
- [_menuController popupMenuWithEvent:theEvent forView:self.view];
+ [super mouseDown:event];
+}
- [super rightMouseDown:theEvent];
+- (void)rightMouseDown:(NSEvent *)event
+{
+ [self openContextMenu:event];
+ [super rightMouseDown:event];
}
@end
=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceDataSource.h
=====================================
@@ -44,7 +44,8 @@ extern NSString * const VLCMediaSourceDataSourceNodeChanged;
@property (readwrite, weak) VLCInputNodePathControl *pathControl;
- (void)setupViews;
-- (VLCInputItem*)mediaSourceInputItemAtRow:(NSInteger)tableViewRow;
+- (VLCInputItem *)mediaSourceInputItemAtRow:(NSInteger)tableViewRow;
+- (NSArray<VLCInputItem *> *)mediaSourceInputItemsAtIndexPaths:(NSSet<NSIndexPath *> *const)indexPaths;
@end
=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceDataSource.m
=====================================
@@ -64,6 +64,27 @@ NSString * const VLCMediaSourceDataSourceNodeChanged = @"VLCMediaSourceDataSourc
[self.tableView setTarget:self];
}
+- (VLCInputNode *)inputNodeForIndexPath:(NSIndexPath *)indexPath
+{
+ VLCInputNode * const rootNode = self.nodeToDisplay;
+ NSArray * const nodeChildren = rootNode.children;
+ return nodeChildren[indexPath.item];
+}
+
+- (NSArray<VLCInputItem *> *)mediaSourceInputItemsAtIndexPaths:(NSSet<NSIndexPath *> *const)indexPaths
+{
+ NSMutableArray<VLCInputItem *> * const inputItems =
+ [NSMutableArray arrayWithCapacity:indexPaths.count];
+
+ for (NSIndexPath * const indexPath in indexPaths) {
+ VLCInputNode * const inputNode = [self inputNodeForIndexPath:indexPath];
+ VLCInputItem * const inputItem = inputNode.inputItem;
+ [inputItems addObject:inputItem];
+ }
+
+ return inputItems.copy;
+}
+
#pragma mark - collection view data source and delegation
- (NSInteger)numberOfSectionsInCollectionView:(NSCollectionView *)collectionView
@@ -98,14 +119,15 @@ NSString * const VLCMediaSourceDataSourceNodeChanged = @"VLCMediaSourceDataSourc
- (void)collectionView:(NSCollectionView *)collectionView didSelectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths
{
- NSIndexPath *indexPath = indexPaths.anyObject;
- if (!indexPath) {
+ if (indexPaths.count != 1) {
return;
}
- VLCInputNode *rootNode = self.nodeToDisplay;
- NSArray *nodeChildren = rootNode.children;
- VLCInputNode *childNode = nodeChildren[indexPath.item];
+ NSIndexPath * const indexPath = indexPaths.anyObject;
+ if (!indexPath) {
+ return;
+ }
+ VLCInputNode * const childNode = [self inputNodeForIndexPath:indexPath];
[self performActionForNode:childNode allowPlayback:YES];
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/eadb563ce121941b50e6e4eaad7be086a7e746aa...b49eeb411dd485f850f6d2226151118d503f9951
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/eadb563ce121941b50e6e4eaad7be086a7e746aa...b49eeb411dd485f850f6d2226151118d503f9951
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