mirror of https://code.videolan.org/videolan/vlc
macosx: Reorganise toolbar delegate implementation
Signed-off-by: Claudio Cambra <developer@claudiocambra.com>
This commit is contained in:
parent
7dbfe6bc1e
commit
710b53a12f
|
@ -35,6 +35,8 @@ NSString * const VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier = @"VLCL
|
|||
|
||||
@implementation VLCLibraryWindowToolbarDelegate
|
||||
|
||||
#pragma mark - XIB handling
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
self.toolbar.allowsUserCustomization = NO;
|
||||
|
@ -72,12 +74,7 @@ NSString * const VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier = @"VLCL
|
|||
[self updatePlayqueueToggleState];
|
||||
}
|
||||
|
||||
- (IBAction)rendererControlAction:(id)sender
|
||||
{
|
||||
[NSMenu popUpContextMenu:VLCMain.sharedInstance.mainMenu.rendererMenu
|
||||
withEvent:NSApp.currentEvent
|
||||
forView:sender];
|
||||
}
|
||||
#pragma mark - toolbar delegate methods
|
||||
|
||||
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
|
||||
itemForItemIdentifier:(NSToolbarItemIdentifier)itemIdentifier
|
||||
|
@ -85,13 +82,25 @@ NSString * const VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier = @"VLCL
|
|||
{
|
||||
if ([itemIdentifier isEqualToString:VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier]) {
|
||||
if (@available(macOS 11.0, *)) {
|
||||
return [NSTrackingSeparatorToolbarItem trackingSeparatorToolbarItemWithIdentifier:itemIdentifier splitView:self.libraryWindow.mainSplitView dividerIndex:VLCLibraryWindowNavigationSidebarSplitViewDividerIndex];
|
||||
return [NSTrackingSeparatorToolbarItem
|
||||
trackingSeparatorToolbarItemWithIdentifier:itemIdentifier
|
||||
splitView:self.libraryWindow.mainSplitView
|
||||
dividerIndex:VLCLibraryWindowNavigationSidebarSplitViewDividerIndex];
|
||||
}
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
#pragma mark - renderers toolbar item handling
|
||||
|
||||
- (IBAction)rendererControlAction:(id)sender
|
||||
{
|
||||
[NSMenu popUpContextMenu:VLCMain.sharedInstance.mainMenu.rendererMenu
|
||||
withEvent:NSApp.currentEvent
|
||||
forView:sender];
|
||||
}
|
||||
|
||||
- (void)renderersChanged:(NSNotification *)notification
|
||||
{
|
||||
const NSUInteger rendererCount =
|
||||
|
@ -110,6 +119,19 @@ NSString * const VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier = @"VLCL
|
|||
}
|
||||
}
|
||||
|
||||
#pragma mark - play queue toggle toolbar item handling
|
||||
|
||||
- (void)updatePlayqueueToggleState
|
||||
{
|
||||
NSView * const playlistView =
|
||||
self.libraryWindow.splitViewController.playlistSidebarViewController.view;
|
||||
self.libraryWindow.playQueueToggle.state =
|
||||
[self.libraryWindow.mainSplitView isSubviewCollapsed:playlistView] ?
|
||||
NSControlStateValueOff : NSControlStateValueOn;
|
||||
}
|
||||
|
||||
#pragma mark - item visibility handling
|
||||
|
||||
- (void)hideToolbarItem:(NSToolbarItem *)toolbarItem
|
||||
{
|
||||
const NSInteger toolbarItemIndex = [self.toolbar.items indexOfObject:toolbarItem];
|
||||
|
@ -151,6 +173,8 @@ NSString * const VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier = @"VLCL
|
|||
[self.toolbar insertItemWithItemIdentifier:toolbarItem.itemIdentifier atIndex:0];
|
||||
}
|
||||
|
||||
#pragma mark - convenience methods for hiding/showing and positioning certain toolbar items
|
||||
|
||||
- (void)setForwardsBackwardsToolbarItemsVisible:(BOOL)visible
|
||||
{
|
||||
if (!visible) {
|
||||
|
@ -219,13 +243,4 @@ NSString * const VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier = @"VLCL
|
|||
self.backwardsToolbarItem]];
|
||||
}
|
||||
|
||||
- (void)updatePlayqueueToggleState
|
||||
{
|
||||
NSView * const playlistView =
|
||||
self.libraryWindow.splitViewController.playlistSidebarViewController.view;
|
||||
self.libraryWindow.playQueueToggle.state =
|
||||
[self.libraryWindow.mainSplitView isSubviewCollapsed:playlistView] ?
|
||||
NSControlStateValueOff : NSControlStateValueOn;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue