[vlc-commits] [Git][videolan/vlc][master] 2 commits: macosx: Fix album table cell view automatic sizing
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Aug 4 03:08:25 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
ae331c6e by Claudio Cambra at 2026-08-04T02:56:42+00:00
macosx: Fix album table cell view automatic sizing
Addresses some visual bugs
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
27e087d9 by Claudio Cambra at 2026-08-04T02:56:42+00:00
macosx: Fix heightForAlbum calculation for short rows
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1 changed file:
- modules/gui/macosx/library/audio-library/VLCLibraryAlbumTableCellView.m
Changes:
=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAlbumTableCellView.m
=====================================
@@ -50,6 +50,7 @@ NSString * const VLCLibraryAlbumTableCellTableViewIdentifier = @"VLCLibraryAlbum
NSString * const VLCLibraryAlbumTableCellTableViewColumnIdentifier = @"VLCLibraryAlbumTableCellTableViewColumnIdentifier";
const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
+static const CGFloat VLCLibraryInternalMediaItemIntercellSpacing = 2.;
@interface VLCNonScrollableScrollView : NSScrollView
@end
@@ -71,6 +72,7 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
VLCLibraryAlbumTracksTableViewDelegate *_tracksTableViewDelegate;
VLCLibraryTableView *_tracksTableView;
NSScrollView *_tracksScrollView;
+ NSLayoutConstraint *_tracksScrollViewHeightConstraint;
NSTableColumn *_column;
}
@@ -89,26 +91,34 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
{
static CGFloat albumNameHeight;
static CGFloat artistNameHeight;
+ static CGFloat artworkAndSecondaryLabelsHeight;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
VLCLibraryAlbumTableCellView *prototype = [VLCLibraryAlbumTableCellView fromNibWithOwner:NSNull.null];
- albumNameHeight = prototype.albumNameTextField.intrinsicContentSize.height;
- artistNameHeight = prototype.artistNameTextButton.intrinsicContentSize.height;
+ albumNameHeight = prototype.albumNameTextField.frame.size.height;
+ artistNameHeight = prototype.artistNameTextButton.frame.size.height;
+ artworkAndSecondaryLabelsHeight = VLCUIUnits.largeSpacing +
+ prototype.representedImageView.frame.size.height +
+ VLCUIUnits.mediumSpacing +
+ prototype.summaryTextField.frame.size.height +
+ VLCUIUnits.smallSpacing +
+ prototype.yearTextField.frame.size.height +
+ VLCUIUnits.largeSpacing;
});
const NSUInteger numberOfTracks = album.numberOfTracks;
- const CGFloat intercellSpacing = numberOfTracks > 1 ? (numberOfTracks - 1) * 1. : 0;
- const CGFloat tracksHeight = numberOfTracks * VLCLibraryInternalMediaItemRowHeight + intercellSpacing + VLCUIUnits.mediumSpacing;
+ const CGFloat tracksHeight = numberOfTracks * (VLCLibraryInternalMediaItemRowHeight + VLCLibraryInternalMediaItemIntercellSpacing);
const CGFloat titleAndTableViewHeight = VLCUIUnits.largeSpacing +
albumNameHeight +
VLCUIUnits.smallSpacing +
artistNameHeight +
- VLCUIUnits.smallSpacing +
+ VLCUIUnits.mediumSpacing +
tracksHeight +
VLCUIUnits.largeSpacing;
- return MAX(titleAndTableViewHeight, VLCLibraryAlbumTableCellViewDefaultHeight);
+ return MAX(MAX(titleAndTableViewHeight, artworkAndSecondaryLabelsHeight),
+ VLCLibraryAlbumTableCellViewDefaultHeight);
}
- (CGFloat)height
@@ -133,7 +143,7 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
_albumNameTextField.frame.size.height +
VLCUIUnits.smallSpacing +
_artistNameTextButton.frame.size.height +
- VLCUIUnits.smallSpacing +
+ VLCUIUnits.mediumSpacing +
[self expectedTableViewHeight] +
VLCUIUnits.largeSpacing;
@@ -163,8 +173,7 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
}
const NSUInteger numberOfTracks = album.numberOfTracks;
- const CGFloat intercellSpacing = numberOfTracks > 1 ? (numberOfTracks - 1) * _tracksTableView.intercellSpacing.height : 0;
- return numberOfTracks * VLCLibraryInternalMediaItemRowHeight + intercellSpacing + VLCUIUnits.mediumSpacing;
+ return numberOfTracks * (VLCLibraryInternalMediaItemRowHeight + _tracksTableView.intercellSpacing.height);
}
- (void)awakeFromNib
@@ -230,6 +239,10 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
_tracksTableView.style = NSTableViewStyleFullWidth;
}
_tracksTableView.gridStyleMask = NSTableViewSolidHorizontalGridLineMask;
+ _tracksTableView.intercellSpacing = NSMakeSize(_tracksTableView.intercellSpacing.width,
+ VLCLibraryInternalMediaItemIntercellSpacing);
+ _tracksTableView.rowSizeStyle = NSTableViewRowSizeStyleCustom;
+ _tracksTableView.usesAutomaticRowHeights = NO;
_tracksTableView.rowHeight = VLCLibraryInternalMediaItemRowHeight;
_tracksTableView.backgroundColor = [NSColor clearColor];
@@ -255,6 +268,8 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
NSDictionary *dict = NSDictionaryOfVariableBindings(_tracksScrollView, _representedImageView, _albumNameTextField, _artistNameTextButton);
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:horizontalVisualConstraints options:0 metrics:0 views:dict]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:verticalVisualContraints options:0 metrics:0 views:dict]];
+ _tracksScrollViewHeightConstraint = [_tracksScrollView.heightAnchor constraintEqualToConstant:0.];
+ _tracksScrollViewHeightConstraint.active = YES;
NSNotificationCenter *notificationCenter = NSNotificationCenter.defaultCenter;
[notificationCenter addObserver:self
@@ -282,9 +297,15 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
}
_tracksDataSource.representedItem = nil;
+ _tracksScrollViewHeightConstraint.constant = 0.;
[_tracksTableView reloadData];
}
+- (void)updateTracksScrollViewHeight
+{
+ _tracksScrollViewHeightConstraint.constant = MAX(0., [self expectedTableViewHeight]);
+}
+
- (void)handleAlbumUpdated:(NSNotification *)notification
{
NSParameterAssert(notification);
@@ -386,6 +407,8 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
self.genreNameTextButton.contentTintColor = secondaryActionableDetail ? NSColor.secondaryLabelColor : NSColor.tertiaryLabelColor;
}
+ [self updateTracksScrollViewHeight];
+
__weak typeof(self) weakSelf = self;
[VLCLibraryImageCache thumbnailForLibraryItem:album withCompletion:^(NSImage * const thumbnail) {
if (!weakSelf || weakSelf.representedItem.item != album) {
@@ -399,6 +422,7 @@ const CGFloat VLCLibraryAlbumTableCellViewDefaultHeight = 168.;
if (strongSelf) {
[strongSelf->_tracksTableView reloadData];
+ [strongSelf updateTracksScrollViewHeight];
}
}];
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ed3b6eafc668ebf4ed76452e371c8f7ead02a7bd...27e087d9b90f83fe0d92a97bf3ef25df241d0c1a
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ed3b6eafc668ebf4ed76452e371c8f7ead02a7bd...27e087d9b90f83fe0d92a97bf3ef25df241d0c1a
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list