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 @@ ...@@ -80,6 +80,7 @@
IBOutlet NSMenu * o_mu_view; IBOutlet NSMenu * o_mu_view;
IBOutlet NSMenuItem * o_mi_toggleJumpButtons; IBOutlet NSMenuItem * o_mi_toggleJumpButtons;
IBOutlet NSMenuItem * o_mi_togglePlaymodeButtons; IBOutlet NSMenuItem * o_mi_togglePlaymodeButtons;
IBOutlet NSMenuItem * o_mi_toggleSidebar;
IBOutlet NSMenu * o_mu_playlistTableColumns; IBOutlet NSMenu * o_mu_playlistTableColumns;
NSMenu * o_mu_playlistTableColumnsContextMenu; NSMenu * o_mu_playlistTableColumnsContextMenu;
...@@ -215,6 +216,7 @@ ...@@ -215,6 +216,7 @@
- (void)setSubmenusEnabled:(BOOL)b_enabled; - (void)setSubmenusEnabled:(BOOL)b_enabled;
- (void)setRateControlsEnabled:(BOOL)b_enabled; - (void)setRateControlsEnabled:(BOOL)b_enabled;
- (void)setupExtensionsMenu; - (void)setupExtensionsMenu;
- (void)updateSidebarMenuItem;
- (IBAction)intfOpenFile:(id)sender; - (IBAction)intfOpenFile:(id)sender;
- (IBAction)intfOpenFileGeneric:(id)sender; - (IBAction)intfOpenFileGeneric:(id)sender;
...@@ -224,6 +226,7 @@ ...@@ -224,6 +226,7 @@
- (IBAction)toggleJumpButtons:(id)sender; - (IBAction)toggleJumpButtons:(id)sender;
- (IBAction)togglePlaymodeButtons:(id)sender; - (IBAction)togglePlaymodeButtons:(id)sender;
- (IBAction)toggleSidebar:(id)sender;
- (IBAction)togglePlaylistColumnTable:(id)sender; - (IBAction)togglePlaylistColumnTable:(id)sender;
- (void)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column; - (void)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column;
- (NSMenu *)setupPlaylistTableColumnsMenu; - (NSMenu *)setupPlaylistTableColumnsMenu;
......
...@@ -302,6 +302,8 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -302,6 +302,8 @@ static VLCMainMenu *_o_sharedInstance = nil;
[o_mi_toggleJumpButtons setState: config_GetInt(VLCIntf, "macosx-show-playback-buttons")]; [o_mi_toggleJumpButtons setState: config_GetInt(VLCIntf, "macosx-show-playback-buttons")];
[o_mi_togglePlaymodeButtons setTitle: _NS("Show Shuffle & Repeat Buttons")]; [o_mi_togglePlaymodeButtons setTitle: _NS("Show Shuffle & Repeat Buttons")];
[o_mi_togglePlaymodeButtons setState: config_GetInt(VLCIntf, "macosx-show-playmode-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_playlistTableColumns setTitle: _NS("Playlist Table Columns")];
[o_mu_controls setTitle: _NS("Playback")]; [o_mu_controls setTitle: _NS("Playback")];
...@@ -647,6 +649,19 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -647,6 +649,19 @@ static VLCMainMenu *_o_sharedInstance = nil;
[o_mi_togglePlaymodeButtons setState: b_value]; [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 - (IBAction)togglePlaylistColumnTable:(id)sender
{ {
NSInteger i_new_state = ![sender state]; NSInteger i_new_state = ![sender state];
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
@interface VLCMainWindow : VLCVideoWindowCommon <PXSourceListDataSource, PXSourceListDelegate, NSWindowDelegate, NSAnimationDelegate, NSSplitViewDelegate> { @interface VLCMainWindow : VLCVideoWindowCommon <PXSourceListDataSource, PXSourceListDelegate, NSWindowDelegate, NSAnimationDelegate, NSSplitViewDelegate> {
IBOutlet id o_search_fld; IBOutlet id o_search_fld;
IBOutlet id o_playlist_table; IBOutlet id o_playlist_table;
IBOutlet id o_split_view; IBOutlet id o_split_view;
IBOutlet id o_left_split_view; IBOutlet id o_left_split_view;
...@@ -82,7 +82,8 @@ ...@@ -82,7 +82,8 @@
BOOL b_splitview_removed; BOOL b_splitview_removed;
BOOL b_minimized_view; BOOL b_minimized_view;
int i_lastSplitViewHeight; NSUInteger i_lastSplitViewHeight;
NSUInteger i_lastLeftSplitViewWidth;
NSMutableArray *o_sidebaritems; NSMutableArray *o_sidebaritems;
...@@ -120,6 +121,7 @@ ...@@ -120,6 +121,7 @@
- (void)windowResizedOrMoved:(NSNotification *)notification; - (void)windowResizedOrMoved:(NSNotification *)notification;
- (void)toggleLeftSubSplitView;
- (void)showDropZone; - (void)showDropZone;
- (void)hideDropZone; - (void)hideDropZone;
- (void)showSplitView; - (void)showSplitView;
...@@ -150,4 +152,4 @@ ...@@ -150,4 +152,4 @@
VLCColorView * o_color_backdrop; VLCColorView * o_color_backdrop;
} }
@end @end
\ No newline at end of file
...@@ -370,8 +370,8 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -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(someWindowWillClose:) name: NSWindowWillCloseNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillMiniaturize:) name: NSWindowWillMiniaturizeNotification 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(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) { if (b_splitviewShouldBeHidden) {
[self hideSplitView]; [self hideSplitView];
i_lastSplitViewHeight = 300; i_lastSplitViewHeight = 300;
...@@ -385,13 +385,19 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -385,13 +385,19 @@ static VLCMainWindow *_o_sharedInstance = nil;
[self resizeWindow]; [self resizeWindow];
} }
// update fs button to reflect state for next startup /* update fs button to reflect state for next startup */
if (var_InheritBool(pl_Get(VLCIntf), "fullscreen")) { if (var_InheritBool(pl_Get(VLCIntf), "fullscreen"))
[o_controls_bar setFullscreenState:YES]; [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 -
#pragma mark appearance management
- (VLCMainWindowControlsBar *)controlsBar; - (VLCMainWindowControlsBar *)controlsBar;
{ {
...@@ -518,6 +524,8 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -518,6 +524,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (void)applicationWillTerminate:(NSNotification *)notification - (void)applicationWillTerminate:(NSNotification *)notification
{ {
config_PutInt(VLCIntf, "macosx-show-sidebar", ![o_split_view isSubviewCollapsed:o_left_split_view]);
[self saveFrameUsingName: [self frameAutosaveName]]; [self saveFrameUsingName: [self frameAutosaveName]];
} }
...@@ -959,6 +967,22 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -959,6 +967,22 @@ static VLCMainWindow *_o_sharedInstance = nil;
return YES; 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 -
#pragma mark Side Bar Data handling #pragma mark Side Bar Data handling
/* taken under BSD-new from the PXSourceList sample project, adapted for VLC */ /* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
......
...@@ -116,6 +116,9 @@ void WindowClose (vout_window_t *); ...@@ -116,6 +116,9 @@ void WindowClose (vout_window_t *);
#define PLAYMODEBUTTONS_TEXT N_("Show play mode control buttons") #define PLAYMODEBUTTONS_TEXT N_("Show play mode control buttons")
#define PLAYMODEBUTTONS_LONGTEXT N_("Shows the shuffle and repeat buttons in the main window") #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 () vlc_module_begin ()
set_description(N_("Mac OS X interface")) set_description(N_("Mac OS X interface"))
set_capability("interface", 200) set_capability("interface", 200)
...@@ -141,6 +144,7 @@ vlc_module_begin () ...@@ -141,6 +144,7 @@ vlc_module_begin ()
add_bool("macosx-icon-change", true, ICONCHANGE_TEXT, ICONCHANGE_LONGTEXT, true) 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-playback-buttons", false, JUMPBUTTONS_TEXT, JUMPBUTTONS_LONGTEXT, false)
add_bool("macosx-show-playmode-buttons", true, PLAYMODEBUTTONS_TEXT, PLAYMODEBUTTONS_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 () add_submodule ()
set_description("Mac OS X Video Output Provider") 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