[vlc-commits] [Git][videolan/vlc][master] 11 commits: macosx: Add clickable buttons for carousel base container view
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Mon Jun 3 09:25:35 UTC 2024
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
d8c777d2 by Claudio Cambra at 2024-06-03T09:12:03+00:00
macosx: Add clickable buttons for carousel base container view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
5921d482 by Claudio Cambra at 2024-06-03T09:12:03+00:00
macosx: Make left and right buttons in carousel view functional
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
9404a842 by Claudio Cambra at 2024-06-03T09:12:03+00:00
macosx: Clean up instantiation of buttons and images in carousel view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
2ec631c4 by Claudio Cambra at 2024-06-03T09:12:03+00:00
macosx: Expose left and right buttons as properties of carousel view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
f0c23ce3 by Claudio Cambra at 2024-06-03T09:12:03+00:00
macosx: Improve styling of left and right buttons in carousel view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
bc3745c8 by Claudio Cambra at 2024-06-03T09:12:03+00:00
macosx: Improve left and right button sizing in carousel views
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
cffaefbd by Claudio Cambra at 2024-06-03T09:12:03+00:00
macosx: Add padding between carousel items and leading button
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
4a89acef by Claudio Cambra at 2024-06-03T09:12:03+00:00
macosx: Use circular buttons for carousel
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
e057cefe by Claudio Cambra at 2024-06-03T09:12:03+00:00
macosx: Update visibility of buttons depending on current button in carousel views
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
3b5b3b5d by Claudio Cambra at 2024-06-03T09:12:03+00:00
macosx: Remove leading padding for carousel in carousel view
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
c27a4b9d by Claudio Cambra at 2024-06-03T09:12:03+00:00
macosx: Do not show carousel buttons if only one item (or fewer)
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
2 changed files:
- modules/gui/macosx/library/home-library/VLCLibraryHomeViewBaseCarouselContainerView.h
- modules/gui/macosx/library/home-library/VLCLibraryHomeViewBaseCarouselContainerView.m
Changes:
=====================================
modules/gui/macosx/library/home-library/VLCLibraryHomeViewBaseCarouselContainerView.h
=====================================
@@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly) NSTextField *titleView;
@property (readonly) iCarousel *carouselView;
+ at property (readonly) NSButton *leftButton;
+ at property (readonly) NSButton *rightButton;
@property (readonly) NSObject<iCarouselDelegate> *delegate;
@property (readonly) NSObject<VLCLibraryCollectionViewDataSource, iCarouselDataSource> *dataSource;
// We want the carousel view to be packed tight around the actual items and not have excess space.
=====================================
modules/gui/macosx/library/home-library/VLCLibraryHomeViewBaseCarouselContainerView.m
=====================================
@@ -109,10 +109,41 @@
[self.bottomAnchor constraintEqualToAnchor:self.carouselView.bottomAnchor]
]];
+ const CGFloat buttonWidth = VLCLibraryUIUnits.largeSpacing;
+ const CGFloat buttonHeight =
+ VLCLibraryUIUnits.carouselViewItemViewHeight - VLCLibraryUIUnits.largeSpacing;
+
+ NSImage * const leftImage = [NSImage imageNamed:@"NSGoLeftTemplate"];
+ _leftButton = [[NSButton alloc] initWithFrame:NSZeroRect];
+ self.leftButton.translatesAutoresizingMaskIntoConstraints = NO;
+ self.leftButton.image = leftImage;
+ self.leftButton.bezelStyle = NSBezelStyleCircular;
+ self.leftButton.target = self;
+ self.leftButton.action = @selector(scrollLeft:);
+ [self addSubview:self.leftButton];
+ [NSLayoutConstraint activateConstraints:@[
+ [self.leftButton.leadingAnchor constraintEqualToAnchor:self.leadingAnchor],
+ [self.leftButton.centerYAnchor constraintEqualToAnchor:self.carouselView.centerYAnchor]
+ ]];
+
+ NSImage * const rightImage = [NSImage imageNamed:@"NSGoRightTemplate"];
+ _rightButton = [[NSButton alloc] initWithFrame:NSZeroRect];
+ self.rightButton.translatesAutoresizingMaskIntoConstraints = NO;
+ self.rightButton.image = rightImage;
+ self.rightButton.bezelStyle = NSBezelStyleCircular;
+ self.rightButton.target = self;
+ self.rightButton.action = @selector(scrollRight:);
+ [self addSubview:self.rightButton];
+ [NSLayoutConstraint activateConstraints:@[
+ [self.rightButton.trailingAnchor constraintEqualToAnchor:self.carouselView.trailingAnchor],
+ [self.rightButton.centerYAnchor constraintEqualToAnchor:self.carouselView.centerYAnchor]
+ ]];
+
_itemHeight = VLCLibraryUIUnits.carouselViewItemViewHeight;
[self updateCarouselViewHeight];
[self updateCarouselOffset];
+ [self updateCarouselButtonVisibility];
}
- (void)connect
@@ -142,12 +173,25 @@
- (void)updateCarouselOffset
{
const CGFloat widthToFirstItemCenter = self.frame.size.width / 2;
- const CGFloat leadingPadding = VLCLibraryUIUnits.largeSpacing;
const CGFloat itemWidth = self.carouselView.itemWidth;
- const CGFloat horizontalOffset = (-(widthToFirstItemCenter - itemWidth / 2)) + leadingPadding;
+ const CGFloat horizontalOffset = (-(widthToFirstItemCenter - itemWidth / 2));
self.carouselView.contentOffset = NSMakeSize(horizontalOffset, 0);
}
+- (void)updateCarouselButtonVisibility
+{
+ if (self.carouselView.numberOfItems <= 1) {
+ self.leftButton.hidden = YES;
+ self.rightButton.hidden = YES;
+ return;
+ }
+
+ const NSInteger currentItemIndex = self.carouselView.currentItemIndex;
+ const NSInteger numberOfItems = self.carouselView.numberOfItems;
+ self.leftButton.hidden = currentItemIndex == 0;
+ self.rightButton.hidden = currentItemIndex == numberOfItems - 1;
+}
+
- (void)resizeWithOldSuperviewSize:(NSSize)oldSize
{
[super resizeWithOldSuperviewSize:oldSize];
@@ -184,6 +228,16 @@
[self updateCarouselViewHeight];
}
+- (void)scrollLeft:(id)sender
+{
+ [self.carouselView scrollToItemAtIndex:self.carouselView.currentItemIndex - 1 animated:YES];
+}
+
+- (void)scrollRight:(id)sender
+{
+ [self.carouselView scrollToItemAtIndex:self.carouselView.currentItemIndex + 1 animated:YES];
+}
+
// pragma mark - iCarousel delegate methods
- (CGFloat)carousel:(iCarousel *)carousel
@@ -223,6 +277,8 @@
self.selectedItemView.selected = NO;
carouselItemView.selected = YES;
self.selectedItemView = carouselItemView;
+
+ [self updateCarouselButtonVisibility];
}
- (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/25dfe4a2efd0db5995427e5a5b816dbe1d65e3da...c27a4b9d5e9a30848b0d7bde02ba947e290d2bdc
--
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/25dfe4a2efd0db5995427e5a5b816dbe1d65e3da...c27a4b9d5e9a30848b0d7bde02ba947e290d2bdc
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