Browse Source

macosx: Dynamically adjust the positioning of the library control buttons in VLCMainVideoView according to window titlebar

Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
pull/144/head
Claudio Cambra 3 years ago
committed by Jean-Baptiste Kempf
parent
commit
abec01b4e7
  1. 3
      modules/gui/macosx/UI/VLCMainVideoView.xib
  2. 2
      modules/gui/macosx/windows/video/VLCMainVideoViewController.h
  3. 25
      modules/gui/macosx/windows/video/VLCMainVideoViewController.m

3
modules/gui/macosx/UI/VLCMainVideoView.xib

@ -11,7 +11,10 @@
<connections>
<outlet property="controlsBar" destination="3" id="Mfq-2w-2uR"/>
<outlet property="mainControlsView" destination="D4V-Zd-qvB" id="KwM-ya-ETn"/>
<outlet property="playlistButton" destination="Drq-if-dw4" id="BZe-Cr-mzZ"/>
<outlet property="playlistButtonTopConstraint" destination="VyM-t4-y6F" id="V94-GS-KcS"/>
<outlet property="returnButton" destination="UoQ-34-Pox" id="nyY-OF-9zj"/>
<outlet property="returnButtonTopConstraint" destination="0l2-eC-67c" id="78K-sz-kmV"/>
<outlet property="view" destination="WRu-Ic-lQK" id="B9p-x5-Kd8"/>
<outlet property="voutView" destination="mAS-4a-RS8" id="GeX-XO-HYC"/>
</connections>

2
modules/gui/macosx/windows/video/VLCMainVideoViewController.h

@ -34,6 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (readwrite, strong) IBOutlet VLCControlsBarCommon *controlsBar;
@property (readwrite, strong) IBOutlet NSButton *returnButton;
@property (readwrite, strong) IBOutlet NSButton *playlistButton;
@property (readwrite, strong) IBOutlet NSLayoutConstraint *returnButtonTopConstraint;
@property (readwrite, strong) IBOutlet NSLayoutConstraint *playlistButtonTopConstraint;
@property (readwrite, nonatomic) BOOL autohideControls;
@property (readwrite, nonatomic) BOOL displayLibraryControls;

25
modules/gui/macosx/windows/video/VLCMainVideoViewController.m

@ -23,6 +23,7 @@
#import "VLCMainVideoViewController.h"
#import "library/VLCLibraryWindow.h"
#import "library/VLCLibraryUIUnits.h"
#import "main/VLCMain.h"
@ -53,6 +54,7 @@
[self setDisplayLibraryControls:[self.view.window class] == [VLCLibraryWindow class]];
[self updatePlaylistToggleState];
[self updateLibraryControlsTopConstraint];
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
@ -113,6 +115,7 @@
{
[self stopAutohideTimer];
[self updatePlaylistToggleState];
[self updateLibraryControlsTopConstraint];
if (!_mainControlsView.hidden && !_autohideControls) {
return;
@ -146,6 +149,28 @@
}
}
- (void)updateLibraryControlsTopConstraint
{
const NSWindow * const viewWindow = self.view.window;
const NSView * const titlebarView = [viewWindow standardWindowButton:NSWindowCloseButton].superview;
const CGFloat windowTitlebarHeight = titlebarView.frame.size.height;
const BOOL windowFullscreen = [(VLCWindow*)viewWindow isInNativeFullscreen] || [(VLCWindow*)viewWindow fullscreen];
const CGFloat spaceToTitlebar = viewWindow.titlebarAppearsTransparent ? [VLCLibraryUIUnits smallSpacing] : [VLCLibraryUIUnits mediumSpacing];
const CGFloat topSpaceWithTitlebar = windowTitlebarHeight + spaceToTitlebar;
// Since the close/maximise/minimise buttons go on the left, we want to make sure the return
// button does not overlap. But for the playlist button, as long as the toolbar and titlebar
// appears fully transparent, it looks nicer to leave it at the top
const CGFloat returnButtonTopSpace = titlebarView.hidden || windowFullscreen ?
[VLCLibraryUIUnits mediumSpacing] : topSpaceWithTitlebar;
const CGFloat playlistButtonTopSpace = viewWindow.toolbar.visible && viewWindow.titlebarAppearsTransparent && !windowFullscreen ?
topSpaceWithTitlebar : [VLCLibraryUIUnits mediumSpacing];
_returnButtonTopConstraint.constant = returnButtonTopSpace;
_playlistButtonTopConstraint.constant = playlistButtonTopSpace;
}
- (IBAction)togglePlaylist:(id)sender
{
VLCLibraryWindow *libraryWindow = (VLCLibraryWindow*)self.view.window;

Loading…
Cancel
Save