[vlc-commits] [Git][videolan/vlc][master] 4 commits: macosx: Do not propagate click through library collection view supplementary detail views
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Dec 15 08:42:49 UTC 2023
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
62845687 by Claudio Cambra at 2023-12-15T07:42:39+00:00
macosx: Do not propagate click through library collection view supplementary detail views
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
4315a7ba by Claudio Cambra at 2023-12-15T07:42:39+00:00
macosx: Add a property for deselecting collection view item upon click if it's already selected
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
aa94f73e by Claudio Cambra at 2023-12-15T07:42:39+00:00
macosx: Implement deselection of collection view item when clicked if already selected
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1326d662 by Claudio Cambra at 2023-12-15T07:42:39+00:00
macosx: Implement indexPathForLibraryItem in VLCLibraryAudioGroupDataSource
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
4 changed files:
- modules/gui/macosx/library/VLCLibraryCollectionViewItem.h
- modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
- modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryDetailView.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioGroupDataSource.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewItem.h
=====================================
@@ -40,6 +40,8 @@ extern NSString *VLCLibraryCellIdentifier;
@property (class, readonly) const CGFloat bottomTextViewsHeight;
@property (class, readonly) const CGFloat videoHeightAspectRatioMultiplier;
+ at property (readwrite, assign) BOOL deselectWhenClickedIfSelected;
+
@property (readwrite, assign) IBOutlet NSTextField *mediaTitleTextField;
@property (readwrite, assign) IBOutlet NSTextField *annotationTextField;
@property (readwrite, assign) IBOutlet NSTextField *unplayedIndicatorTextField;
=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewItem.m
=====================================
@@ -27,6 +27,8 @@
#import "extensions/NSColor+VLCAdditions.h"
#import "extensions/NSView+VLCAdditions.h"
+#import "library/VLCLibraryCollectionViewDataSource.h"
+#import "library/VLCLibraryCollectionViewFlowLayout.h"
#import "library/VLCLibraryController.h"
#import "library/VLCLibraryDataTypes.h"
#import "library/VLCLibraryImageCache.h"
@@ -112,6 +114,7 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
- (void)awakeFromNib
{
+ _deselectWhenClickedIfSelected = YES;
_videoImageViewAspectRatioConstraint = [NSLayoutConstraint constraintWithItem:_mediaImageView
attribute:NSLayoutAttributeHeight
relatedBy:NSLayoutRelationEqual
@@ -289,6 +292,18 @@ const CGFloat VLCLibraryCollectionViewItemMaximumDisplayedProgress = 0.95;
[_menuController setRepresentedItem:self.representedItem];
[_menuController popupMenuWithEvent:theEvent forView:self.view];
+ } else if (self.deselectWhenClickedIfSelected &&
+ self.selected &&
+ [self.collectionView.dataSource conformsToProtocol:@protocol(VLCLibraryCollectionViewDataSource)]) {
+ NSObject<VLCLibraryCollectionViewDataSource> * const dataSource = (NSObject<VLCLibraryCollectionViewDataSource> *)self.collectionView.dataSource;
+ NSIndexPath * const indexPath = [dataSource indexPathForLibraryItem:self.representedItem.item];
+ NSSet<NSIndexPath *> * const indexPathSet = [NSSet setWithObject:indexPath];
+ [self.collectionView deselectItemsAtIndexPaths:indexPathSet];
+
+ if ([self.collectionView.collectionViewLayout isKindOfClass:[VLCLibraryCollectionViewFlowLayout class]]) {
+ VLCLibraryCollectionViewFlowLayout * const flowLayout = (VLCLibraryCollectionViewFlowLayout *)self.collectionView.collectionViewLayout;
+ [flowLayout collapseDetailSectionAtIndex:indexPath];
+ }
}
[super mouseDown:theEvent];
=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewSupplementaryDetailView.m
=====================================
@@ -36,7 +36,13 @@ static const CGFloat kBackgroundCornerRadius = 10.;
@implementation VLCLibraryCollectionViewSupplementaryDetailView
-- (void)drawRect:(NSRect)dirtyRect {
+- (void)mouseDown:(NSEvent *)event
+{
+ // Do not propagate the event as this will lead to subject collection view item being deselected
+}
+
+- (void)drawRect:(NSRect)dirtyRect
+{
if(NSEqualSizes(_arrowSize, NSZeroSize)) {
_arrowSize = NSMakeSize(kArrowWidth, kArrowHeight);
}
=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioGroupDataSource.m
=====================================
@@ -225,4 +225,14 @@ viewForSupplementaryElementOfKind:(NSCollectionViewSupplementaryElementKind)kind
return self.representedListOfAlbums[indexPathItem];
}
+- (NSIndexPath *)indexPathForLibraryItem:(id<VLCMediaLibraryItemProtocol>)libraryItem
+{
+ if (libraryItem == nil) {
+ return nil;
+ }
+
+ const NSInteger arrayIdx = [self rowForLibraryItem:libraryItem];
+ return [NSIndexPath indexPathForItem:arrayIdx inSection:0];
+}
+
@end
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9ca953e1d4dc05113457845315fe02a90fdcc007...1326d6628be54bd6fa9cfe421f71c4048b98427a
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9ca953e1d4dc05113457845315fe02a90fdcc007...1326d6628be54bd6fa9cfe421f71c4048b98427a
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