[vlc-commits] [Git][videolan/vlc][master] 2 commits: macosx: Use safe area insets and layout
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Mon Jun 8 07:34:35 UTC 2026
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
4141c9b4 by Claudio Cambra at 2026-06-08T09:22:25+02:00
macosx: Use safe area insets and layout
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
92c5e348 by Claudio Cambra at 2026-06-08T09:22:25+02:00
macosx: Fall back to content layout guide on macOS <11
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
7 changed files:
- modules/gui/macosx/library/VLCLibraryUIUnits.h
- modules/gui/macosx/library/VLCLibraryUIUnits.m
- modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarViewController.m
- modules/gui/macosx/library/VLCLibraryWindowSidebarRootViewController.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
- modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.m
- modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.m
Changes:
=====================================
modules/gui/macosx/library/VLCLibraryUIUnits.h
=====================================
@@ -80,6 +80,8 @@ extern NSString * const VLCLibraryCollectionViewItemAdjustmentKey;
@property (class, readonly) const NSEdgeInsets libraryViewScrollViewDetailGridContentInsets;
@property (class, readonly) const NSEdgeInsets libraryViewScrollViewScrollerInsets;
+ at property (class, readonly) const CGFloat libraryWindowContentSafeTopInset;
+
@property (class, readonly) const CGFloat controlsFadeAnimationDuration;
@property (class, readonly) const CGFloat libraryWindowControlsBarHeight;
=====================================
modules/gui/macosx/library/VLCLibraryUIUnits.m
=====================================
@@ -217,10 +217,23 @@ NSString * const VLCLibraryCollectionViewItemAdjustmentKey = @"VLCLibraryCollect
return 180;
}
-+ (const NSEdgeInsets)libraryViewScrollViewContentInsets
++ (const CGFloat)libraryWindowContentSafeTopInset
{
VLCLibraryWindow * const libraryWindow = VLCMain.sharedInstance.libraryWindow;
- const CGFloat toolbarHeight = libraryWindow.titlebarHeight;
+ if (@available(macOS 11.0, *)) {
+ return libraryWindow.contentView.safeAreaInsets.top;
+ }
+
+ if (libraryWindow.styleMask & NSWindowStyleMaskFullSizeContentView) {
+ return libraryWindow.contentView.frame.size.height - libraryWindow.contentLayoutRect.size.height;
+ }
+
+ return 0;
+}
+
++ (const NSEdgeInsets)libraryViewScrollViewContentInsets
+{
+ const CGFloat toolbarHeight = VLCLibraryUIUnits.libraryWindowContentSafeTopInset;
const CGFloat controlsBarHeight = VLCLibraryUIUnits.libraryWindowControlsBarHeight;
const CGFloat controlsBarPadding = VLCLibraryUIUnits.largeSpacing * 2; // Additional padding for floating controls bar
@@ -254,8 +267,7 @@ NSString * const VLCLibraryCollectionViewItemAdjustmentKey = @"VLCLibraryCollect
+ (const NSEdgeInsets)libraryViewScrollViewScrollerInsets
{
- VLCLibraryWindow * const libraryWindow = VLCMain.sharedInstance.libraryWindow;
- const CGFloat toolbarHeight = libraryWindow.titlebarHeight;
+ const CGFloat toolbarHeight = VLCLibraryUIUnits.libraryWindowContentSafeTopInset;
const NSEdgeInsets contentInsets = [self libraryViewScrollViewContentInsets];
return NSEdgeInsetsMake(-contentInsets.top + toolbarHeight,
=====================================
modules/gui/macosx/library/VLCLibraryWindowNavigationSidebarViewController.m
=====================================
@@ -30,6 +30,7 @@
#import "library/VLCLibraryWindowNavigationSidebarOutlineView.h"
#import "library/VLCLibraryController.h"
+#import "library/VLCLibraryUIUnits.h"
#import "main/VLCMain.h"
@@ -86,7 +87,7 @@ static NSString * const VLCLibrarySegmentCellIdentifier = @"VLCLibrarySegmentCel
const NSEdgeInsets scrollViewInsets = self.outlineViewScrollView.contentInsets;
_scrollViewInsets =
- NSEdgeInsetsMake(scrollViewInsets.top + self.libraryWindow.titlebarHeight,
+ NSEdgeInsetsMake(scrollViewInsets.top + VLCLibraryUIUnits.libraryWindowContentSafeTopInset,
scrollViewInsets.left,
scrollViewInsets.bottom,
scrollViewInsets.right);
=====================================
modules/gui/macosx/library/VLCLibraryWindowSidebarRootViewController.m
=====================================
@@ -66,6 +66,10 @@
[self setupPlayQueueTitle];
[self setupCounterLabel];
+ _topInternalConstraint =
+ [self.viewSelector.topAnchor constraintEqualToAnchor:self.view.topAnchor
+ constant:VLCLibraryUIUnits.libraryWindowContentSafeTopInset + VLCLibraryUIUnits.smallSpacing];
+
self.mainVideoModeEnabled = NO;
_playQueueSidebarViewController =
@@ -103,9 +107,10 @@
self.playQueueHeaderLabel.textColor = NSColor.headerTextColor;
[self.view addSubview:self.playQueueHeaderLabel];
+
_playQueueHeaderTopConstraint =
[self.playQueueHeaderLabel.topAnchor constraintEqualToAnchor:self.view.topAnchor
- constant:VLCLibraryUIUnits.smallSpacing];
+ constant:VLCLibraryUIUnits.libraryWindowContentSafeTopInset + VLCLibraryUIUnits.smallSpacing];
[NSLayoutConstraint activateConstraints:@[
self.playQueueHeaderTopConstraint,
[self.playQueueHeaderLabel.bottomAnchor constraintEqualToAnchor:self.targetView.topAnchor
@@ -251,11 +256,8 @@
- (void)updateTopConstraints
{
- CGFloat internalTopConstraintConstant = VLCLibraryUIUnits.smallSpacing;
- if (!self.mainVideoModeEnabled && self.libraryWindow.styleMask & NSWindowStyleMaskFullSizeContentView) {
- // Compensate for full content view window's titlebar height, prevent top being cut off
- internalTopConstraintConstant += self.libraryWindow.titlebarHeight;
- }
+ const CGFloat internalTopConstraintConstant =
+ VLCLibraryUIUnits.libraryWindowContentSafeTopInset + VLCLibraryUIUnits.smallSpacing;
self.topInternalConstraint.constant = internalTopConstraintConstant;
self.playQueueHeaderTopConstraint.constant = internalTopConstraintConstant;
}
=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
=====================================
@@ -292,7 +292,7 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
const CGFloat controlsBarHeight = VLCLibraryUIUnits.libraryWindowControlsBarHeight;
const CGFloat controlsBarPadding = VLCLibraryUIUnits.largeSpacing * 2;
NSClipView * const clipView = _audioSongTableViewScrollView.contentView;
- const CGFloat topInset = self.libraryWindow.titlebarHeight + self.audioSongTableView.headerView.frame.size.height;
+ const CGFloat topInset = VLCLibraryUIUnits.libraryWindowContentSafeTopInset + self.audioSongTableView.headerView.frame.size.height;
clipView.automaticallyAdjustsContentInsets = NO;
clipView.contentInsets = NSEdgeInsetsMake(topInset, 0, controlsBarHeight + controlsBarPadding, 0);
}
=====================================
modules/gui/macosx/library/media-source/VLCLibraryMediaSourceViewController.m
=====================================
@@ -174,8 +174,11 @@
[self.pathControlVisualEffectView removeFromSuperview];
[self.mediaSourceView addSubview:self.pathControlGlassEffectView];
+ NSLayoutYAxisAnchor *topAnchor = self.mediaSourceView.topAnchor;
+ const CGFloat topConstant = VLCLibraryUIUnits.libraryWindowContentSafeTopInset;
+
_pathControlViewTopConstraintToSuperview =
- [self.pathControlGlassEffectView.topAnchor constraintEqualToAnchor:self.mediaSourceView.topAnchor constant:self.libraryWindow.titlebarHeight];
+ [self.pathControlGlassEffectView.topAnchor constraintEqualToAnchor:topAnchor constant:topConstant];
[NSLayoutConstraint activateConstraints:@[
[self.pathControlGlassEffectView.leadingAnchor constraintEqualToAnchor:self.mediaSourceView.leadingAnchor constant:VLCLibraryUIUnits.smallSpacing],
[self.pathControlGlassEffectView.trailingAnchor constraintEqualToAnchor:self.mediaSourceView.trailingAnchor constant:-VLCLibraryUIUnits.smallSpacing],
@@ -199,8 +202,11 @@
self.pathControlGlassEffectView.contentView = pathControlContainer;
#endif
} else {
+ NSLayoutYAxisAnchor *topAnchor = self.mediaSourceView.topAnchor;
+ const CGFloat topConstant = VLCLibraryUIUnits.libraryWindowContentSafeTopInset;
+
_pathControlViewTopConstraintToSuperview =
- [self.pathControlVisualEffectView.topAnchor constraintEqualToAnchor:self.mediaSourceView.topAnchor constant:self.libraryWindow.titlebarHeight];
+ [self.pathControlVisualEffectView.topAnchor constraintEqualToAnchor:topAnchor constant:topConstant];
}
_pathControlViewTopConstraintToSuperview.active = YES;
}
=====================================
modules/gui/macosx/library/media-source/VLCMediaSourceBaseDataSource.m
=====================================
@@ -587,7 +587,7 @@ referenceSizeForHeaderInSection:(NSInteger)section
_collectionViewScrollView.scrollerInsets = scrollerInsets;
_tableViewScrollView.automaticallyAdjustsContentInsets = NO;
- _tableViewScrollView.contentInsets = NSEdgeInsetsMake(scrollViewsTopSpace + _tableViewScrollView.window.titlebarHeight, 0, scrollViewInsets.bottom, 0);
+ _tableViewScrollView.contentInsets = NSEdgeInsetsMake(scrollViewsTopSpace + VLCLibraryUIUnits.libraryWindowContentSafeTopInset, 0, scrollViewInsets.bottom, 0);
_tableViewScrollView.scrollerInsets = NSEdgeInsetsMake(0, 0, -scrollViewInsets.bottom, 0);
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2476eb53e76d650fbd85fc79f301637a600353c3...92c5e348afce855a11e46a44d85f8228d7004f40
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2476eb53e76d650fbd85fc79f301637a600353c3...92c5e348afce855a11e46a44d85f8228d7004f40
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