[vlc-commits] [Git][videolan/vlc][master] 6 commits: macosx: Add openContextMenu method to carousel view item view
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Mon Jul 1 10:41:36 UTC 2024
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
f23a12e0 by Claudio Cambra at 2024-07-01T09:56:41+00:00
macosx: Add openContextMenu method to carousel view item view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
cbd2b9c3 by Claudio Cambra at 2024-07-01T09:56:41+00:00
macosx: React to control clicks by trying to open clicked-on item's context menu in iCarousel
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
440f91e6 by Claudio Cambra at 2024-07-01T09:56:41+00:00
macosx: Implement right-click context menu for carousel items in iCarousel
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
6e287574 by Claudio Cambra at 2024-07-01T09:56:41+00:00
macosx: Add iCarouselItemView protocol
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
e986c667 by Claudio Cambra at 2024-07-01T09:56:41+00:00
macosx: Use iCarouselItemView protocol in VLCLibraryCarouselViewItemView
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
c5c00e56 by Claudio Cambra at 2024-07-01T09:56:41+00:00
macosx: Use iCarouselItemView protocol for context menu purposes in iCarousel
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
4 changed files:
- modules/gui/macosx/library/VLCLibraryCarouselViewItemView.h
- modules/gui/macosx/library/VLCLibraryCarouselViewItemView.m
- modules/gui/macosx/views/iCarousel/iCarousel.h
- modules/gui/macosx/views/iCarousel/iCarousel.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryCarouselViewItemView.h
=====================================
@@ -22,13 +22,15 @@
#import <Cocoa/Cocoa.h>
+#import "views/iCarousel/iCarousel.h"
+
NS_ASSUME_NONNULL_BEGIN
@class VLCImageView;
@class VLCLinearProgressIndicator;
@class VLCLibraryRepresentedItem;
- at interface VLCLibraryCarouselViewItemView : NSView
+ at interface VLCLibraryCarouselViewItemView : NSView<iCarouselItemView>
@property (readwrite, weak) IBOutlet VLCImageView *imageView;
@property (readwrite, weak) IBOutlet NSTextField *annotationTextField;
=====================================
modules/gui/macosx/library/VLCLibraryCarouselViewItemView.m
=====================================
@@ -30,6 +30,7 @@
#import "library/VLCLibraryController.h"
#import "library/VLCLibraryDataTypes.h"
#import "library/VLCLibraryImageCache.h"
+#import "library/VLCLibraryMenuController.h"
#import "library/VLCLibraryRepresentedItem.h"
#import "main/VLCMain.h"
@@ -37,6 +38,12 @@
#import "views/VLCImageView.h"
#import "views/VLCLinearProgressIndicator.h"
+ at interface VLCLibraryCarouselViewItemView ()
+
+ at property (readonly) VLCLibraryMenuController *menuController;
+
+ at end
+
@implementation VLCLibraryCarouselViewItemView
+ (instancetype)fromNibWithOwner:(id)owner
@@ -166,4 +173,14 @@
[self.representedItem play];
}
+- (void)openContextMenu:(NSEvent *)event
+{
+ if (self.menuController == nil) {
+ _menuController = [[VLCLibraryMenuController alloc] init];
+ }
+
+ self.menuController.representedItems = @[self.representedItem];
+ [self.menuController popupMenuWithEvent:event forView:self];
+}
+
@end
=====================================
modules/gui/macosx/views/iCarousel/iCarousel.h
=====================================
@@ -199,6 +199,13 @@ NS_ASSUME_NONNULL_BEGIN
@end
+ at protocol iCarouselItemView <NSObject>
+
+ at optional
+- (void)openContextMenu:(NSEvent *)event;
+
+ at end
+
NS_ASSUME_NONNULL_END
#pragma clang diagnostic pop
=====================================
modules/gui/macosx/views/iCarousel/iCarousel.m
=====================================
@@ -2271,14 +2271,23 @@ NSComparisonResult compareViewDepth(UIView *view1, UIView *view2, iCarousel *sel
if (!_didDrag)
{
//convert position to view
- CGPoint position = [theEvent locationInWindow];
- position = [self convertPoint:position fromView:self.window.contentView];
+ const CGPoint position = [self convertPoint:theEvent.locationInWindow
+ fromView:self.window.contentView];
//check for tapped view
- UIView *itemView = [self itemViewAtPoint:position];
- NSInteger index = itemView? [self indexOfItemView: itemView]: NSNotFound;
- if (index != NSNotFound)
- {
+ UIView * const itemView = [self itemViewAtPoint:position];
+
+ if (theEvent.modifierFlags & NSEventModifierFlagControl) {
+ UIView<iCarouselItemView> * const carouselItemView =
+ (UIView<iCarouselItemView> *)itemView;
+ if ([carouselItemView respondsToSelector:@selector(openContextMenu:)]) {
+ [carouselItemView openContextMenu:theEvent];
+ }
+ return;
+ }
+
+ const NSInteger index = itemView ? [self indexOfItemView: itemView] : NSNotFound;
+ if (index != NSNotFound) {
if (_centerItemWhenSelected && index != self.currentItemIndex)
{
[self scrollToItemAtIndex:index animated:YES];
@@ -2325,6 +2334,19 @@ NSComparisonResult compareViewDepth(UIView *view1, UIView *view2, iCarousel *sel
}
}
+- (void)rightMouseDown:(NSEvent *)event
+{
+ //convert position to view
+ const CGPoint position = [self convertPoint:event.locationInWindow
+ fromView:self.window.contentView];
+
+ //check for tapped view
+ UIView<iCarouselItemView> * const itemView =
+ (UIView<iCarouselItemView> *)[self itemViewAtPoint:position];
+ if ([itemView respondsToSelector:@selector(openContextMenu:)]) {
+ [itemView openContextMenu:event];
+ }
+}
#pragma mark -
#pragma mark Keyboard control
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/644dd7f62cedabcfceb4bce1d5cc1ade350d838c...c5c00e561a3fc4d34bb05dbb07e7f0e9f5159c79
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/644dd7f62cedabcfceb4bce1d5cc1ade350d838c...c5c00e561a3fc4d34bb05dbb07e7f0e9f5159c79
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