Commit ca80c3e8 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: added menu item and advanced option to hide the main window's sidebar

parent 16e6cbda
......@@ -80,6 +80,7 @@
IBOutlet NSMenu * o_mu_view;
IBOutlet NSMenuItem * o_mi_toggleJumpButtons;
IBOutlet NSMenuItem * o_mi_togglePlaymodeButtons;
IBOutlet NSMenuItem * o_mi_toggleSidebar;
IBOutlet NSMenu * o_mu_playlistTableColumns;
NSMenu * o_mu_playlistTableColumnsContextMenu;
......@@ -215,6 +216,7 @@
- (void)setSubmenusEnabled:(BOOL)b_enabled;
- (void)setRateControlsEnabled:(BOOL)b_enabled;
- (void)setupExtensionsMenu;
- (void)updateSidebarMenuItem;
- (IBAction)intfOpenFile:(id)sender;
- (IBAction)intfOpenFileGeneric:(id)sender;
......@@ -224,6 +226,7 @@
- (IBAction)toggleJumpButtons:(id)sender;
- (IBAction)togglePlaymodeButtons:(id)sender;
- (IBAction)toggleSidebar:(id)sender;
- (IBAction)togglePlaylistColumnTable:(id)sender;
- (void)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column;
- (NSMenu *)setupPlaylistTableColumnsMenu;
......
......@@ -302,6 +302,8 @@ static VLCMainMenu *_o_sharedInstance = nil;
[o_mi_toggleJumpButtons setState: config_GetInt(VLCIntf, "macosx-show-playback-buttons")];
[o_mi_togglePlaymodeButtons setTitle: _NS("Show Shuffle & Repeat Buttons")];
[o_mi_togglePlaymodeButtons setState: config_GetInt(VLCIntf, "macosx-show-playmode-buttons")];
[o_mi_toggleSidebar setTitle: _NS("Show Sidebar")];
[o_mi_toggleSidebar setState: config_GetInt(VLCIntf, "macosx-show-sidebar")];
[o_mu_playlistTableColumns setTitle: _NS("Playlist Table Columns")];
[o_mu_controls setTitle: _NS("Playback")];
......@@ -647,6 +649,19 @@ static VLCMainMenu *_o_sharedInstance = nil;
[o_mi_togglePlaymodeButtons setState: b_value];
}
- (IBAction)toggleSidebar:(id)sender
{
BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-sidebar");
config_PutInt(VLCIntf, "macosx-show-sidebar", b_value);
[[[VLCMain sharedInstance] mainWindow] toggleLeftSubSplitView];
[o_mi_toggleSidebar setState: b_value];
}
- (void)updateSidebarMenuItem
{
[o_mi_toggleSidebar setState: config_GetInt(VLCIntf, "macosx-show-sidebar")];
}
- (IBAction)togglePlaylistColumnTable:(id)sender
{
NSInteger i_new_state = ![sender state];
......
......@@ -82,7 +82,8 @@
BOOL b_splitview_removed;
BOOL b_minimized_view;
int i_lastSplitViewHeight;
NSUInteger i_lastSplitViewHeight;
NSUInteger i_lastLeftSplitViewWidth;
NSMutableArray *o_sidebaritems;
......@@ -120,6 +121,7 @@
- (void)windowResizedOrMoved:(NSNotification *)notification;
- (void)toggleLeftSubSplitView;
- (void)showDropZone;
- (void)hideDropZone;
- (void)showSplitView;
......
......@@ -370,8 +370,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillClose:) name: NSWindowWillCloseNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillMiniaturize:) name: NSWindowWillMiniaturizeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainSplitViewWillResizeSubviews:) name:NSSplitViewWillResizeSubviewsNotification object:o_split_view];
[o_split_view setAutosaveName:@"10thanniversary-splitview"];
if (b_splitviewShouldBeHidden) {
[self hideSplitView];
i_lastSplitViewHeight = 300;
......@@ -385,13 +385,19 @@ static VLCMainWindow *_o_sharedInstance = nil;
[self resizeWindow];
}
// update fs button to reflect state for next startup
if (var_InheritBool(pl_Get(VLCIntf), "fullscreen")) {
/* update fs button to reflect state for next startup */
if (var_InheritBool(pl_Get(VLCIntf), "fullscreen"))
[o_controls_bar setFullscreenState:YES];
}
/* restore split view */
i_lastLeftSplitViewWidth = 200;
/* trick NSSplitView implementation, which pretends to know better than us */
if (!config_GetInt(VLCIntf, "macosx-show-sidebar"))
[self performSelector:@selector(toggleLeftSubSplitView) withObject:nil afterDelay:0.05];
}
#pragma mark -
#pragma mark appearance management
- (VLCMainWindowControlsBar *)controlsBar;
{
......@@ -518,6 +524,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (void)applicationWillTerminate:(NSNotification *)notification
{
config_PutInt(VLCIntf, "macosx-show-sidebar", ![o_split_view isSubviewCollapsed:o_left_split_view]);
[self saveFrameUsingName: [self frameAutosaveName]];
}
......@@ -959,6 +967,22 @@ static VLCMainWindow *_o_sharedInstance = nil;
return YES;
}
- (void)mainSplitViewWillResizeSubviews:(id)object
{
i_lastLeftSplitViewWidth = [o_left_split_view frame].size.width;
config_PutInt(VLCIntf, "macosx-show-sidebar", ![o_split_view isSubviewCollapsed:o_left_split_view]);
[[[VLCMain sharedInstance] mainMenu] updateSidebarMenuItem];
}
- (void)toggleLeftSubSplitView
{
[o_split_view adjustSubviews];
if ([o_split_view isSubviewCollapsed:o_left_split_view])
[o_split_view setPosition:i_lastLeftSplitViewWidth ofDividerAtIndex:0];
else
[o_split_view setPosition:[o_split_view minPossiblePositionOfDividerAtIndex:0] ofDividerAtIndex:0];
}
#pragma mark -
#pragma mark Side Bar Data handling
/* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
......
......@@ -116,6 +116,9 @@ void WindowClose (vout_window_t *);
#define PLAYMODEBUTTONS_TEXT N_("Show play mode control buttons")
#define PLAYMODEBUTTONS_LONGTEXT N_("Shows the shuffle and repeat buttons in the main window")
#define SIDEBAR_TEXT N_("Show sidebar")
#define SIDEBAR_LONGTEXT N_("Shows a sidebar in the main window listing media sources")
vlc_module_begin ()
set_description(N_("Mac OS X interface"))
set_capability("interface", 200)
......@@ -141,6 +144,7 @@ vlc_module_begin ()
add_bool("macosx-icon-change", true, ICONCHANGE_TEXT, ICONCHANGE_LONGTEXT, true)
add_bool("macosx-show-playback-buttons", false, JUMPBUTTONS_TEXT, JUMPBUTTONS_LONGTEXT, false)
add_bool("macosx-show-playmode-buttons", true, PLAYMODEBUTTONS_TEXT, PLAYMODEBUTTONS_LONGTEXT, false)
add_bool("macosx-show-sidebar", true, SIDEBAR_TEXT, SIDEBAR_LONGTEXT, false)
add_submodule ()
set_description("Mac OS X Video Output Provider")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment