Commit 23ab7c47 authored by David Fuhrmann's avatar David Fuhrmann

macosx: Use enum to distinguish different events for playlist / main window states

No functional change.
parent a1e8dd24
...@@ -21,10 +21,10 @@ ...@@ -21,10 +21,10 @@
</object> </object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<integer value="4756"/>
<integer value="4722"/>
<integer value="4850"/> <integer value="4850"/>
<integer value="5260"/> <integer value="5260"/>
<integer value="21"/>
<integer value="4722"/>
</object> </object>
<object class="NSArray" key="IBDocument.PluginDependencies"> <object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
...@@ -1829,14 +1829,6 @@ ...@@ -1829,14 +1829,6 @@
</object> </object>
<int key="connectionID">4666</int> <int key="connectionID">4666</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">togglePlaylist:</string>
<reference key="source" ref="498338108"/>
<reference key="destination" ref="955174811"/>
</object>
<int key="connectionID">4674</int>
</object>
<object class="IBConnectionRecord"> <object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection"> <object class="IBOutletConnection" key="connection">
<string key="label">o_split_view</string> <string key="label">o_split_view</string>
...@@ -2493,6 +2485,14 @@ ...@@ -2493,6 +2485,14 @@
</object> </object>
<int key="connectionID">5603</int> <int key="connectionID">5603</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">togglePlaylist:</string>
<reference key="source" ref="878580547"/>
<reference key="destination" ref="955174811"/>
</object>
<int key="connectionID">5604</int>
</object>
</object> </object>
<object class="IBMutableOrderedSet" key="objectRecords"> <object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects"> <object class="NSArray" key="orderedObjects">
...@@ -4064,7 +4064,7 @@ ...@@ -4064,7 +4064,7 @@
</object> </object>
</object> </object>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">5603</int> <int key="maxID">5604</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions"> <object class="NSMutableArray" key="referencedPartialClassDescriptions">
...@@ -4687,7 +4687,6 @@ ...@@ -4687,7 +4687,6 @@
<string>dropzoneButtonAction:</string> <string>dropzoneButtonAction:</string>
<string>removePodcast:</string> <string>removePodcast:</string>
<string>removePodcastWindowAction:</string> <string>removePodcastWindowAction:</string>
<string>togglePlaylist:</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
...@@ -4696,7 +4695,6 @@ ...@@ -4696,7 +4695,6 @@
<string>id</string> <string>id</string>
<string>id</string> <string>id</string>
<string>id</string> <string>id</string>
<string>id</string>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="actionInfosByName"> <object class="NSMutableDictionary" key="actionInfosByName">
...@@ -4708,7 +4706,6 @@ ...@@ -4708,7 +4706,6 @@
<string>dropzoneButtonAction:</string> <string>dropzoneButtonAction:</string>
<string>removePodcast:</string> <string>removePodcast:</string>
<string>removePodcastWindowAction:</string> <string>removePodcastWindowAction:</string>
<string>togglePlaylist:</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
...@@ -4732,10 +4729,6 @@ ...@@ -4732,10 +4729,6 @@
<string key="name">removePodcastWindowAction:</string> <string key="name">removePodcastWindowAction:</string>
<string key="candidateClassName">id</string> <string key="candidateClassName">id</string>
</object> </object>
<object class="IBActionInfo">
<string key="name">togglePlaylist:</string>
<string key="candidateClassName">id</string>
</object>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="outlets"> <object class="NSMutableDictionary" key="outlets">
...@@ -4961,6 +4954,7 @@ ...@@ -4961,6 +4954,7 @@
<string>repeat:</string> <string>repeat:</string>
<string>shuffle:</string> <string>shuffle:</string>
<string>stop:</string> <string>stop:</string>
<string>togglePlaylist:</string>
<string>volumeAction:</string> <string>volumeAction:</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSMutableArray" key="dict.values">
...@@ -4970,6 +4964,7 @@ ...@@ -4970,6 +4964,7 @@
<string>id</string> <string>id</string>
<string>id</string> <string>id</string>
<string>id</string> <string>id</string>
<string>id</string>
</object> </object>
</object> </object>
<object class="NSMutableDictionary" key="actionInfosByName"> <object class="NSMutableDictionary" key="actionInfosByName">
...@@ -4980,6 +4975,7 @@ ...@@ -4980,6 +4975,7 @@
<string>repeat:</string> <string>repeat:</string>
<string>shuffle:</string> <string>shuffle:</string>
<string>stop:</string> <string>stop:</string>
<string>togglePlaylist:</string>
<string>volumeAction:</string> <string>volumeAction:</string>
</object> </object>
<object class="NSMutableArray" key="dict.values"> <object class="NSMutableArray" key="dict.values">
...@@ -5000,6 +4996,10 @@ ...@@ -5000,6 +4996,10 @@
<string key="name">stop:</string> <string key="name">stop:</string>
<string key="candidateClassName">id</string> <string key="candidateClassName">id</string>
</object> </object>
<object class="IBActionInfo">
<string key="name">togglePlaylist:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo"> <object class="IBActionInfo">
<string key="name">volumeAction:</string> <string key="name">volumeAction:</string>
<string key="candidateClassName">id</string> <string key="candidateClassName">id</string>
......
...@@ -145,6 +145,8 @@ ...@@ -145,6 +145,8 @@
- (void)setShuffle; - (void)setShuffle;
- (IBAction)shuffle:(id)sender; - (IBAction)shuffle:(id)sender;
- (IBAction)togglePlaylist:(id)sender;
- (void)toggleEffectsButton; - (void)toggleEffectsButton;
- (void)toggleJumpButtons; - (void)toggleJumpButtons;
- (void)togglePlaymodeButtons; - (void)togglePlaymodeButtons;
......
...@@ -1062,6 +1062,11 @@ else \ ...@@ -1062,6 +1062,11 @@ else \
[self setShuffle]; [self setShuffle];
} }
- (IBAction)togglePlaylist:(id)sender
{
[[[VLCMain sharedInstance] mainWindow] changePlaylistState: psUserEvent];
}
- (IBAction)volumeAction:(id)sender - (IBAction)volumeAction:(id)sender
{ {
if (sender == o_volume_sld) if (sender == o_volume_sld)
......
...@@ -1128,7 +1128,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -1128,7 +1128,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (IBAction)showPlaylist:(id)sender - (IBAction)showPlaylist:(id)sender
{ {
[[VLCMainWindow sharedInstance] togglePlaylist:sender]; [[VLCMainWindow sharedInstance] changePlaylistState: psUserMenuEvent];
} }
#pragma mark - #pragma mark -
......
...@@ -42,6 +42,13 @@ ...@@ -42,6 +42,13 @@
@class VLCMainWindowControlsBar; @class VLCMainWindowControlsBar;
@class VLCVoutView; @class VLCVoutView;
typedef enum {
psUserEvent,
psUserMenuEvent,
psVideoStartedOrStoppedEvent,
psPlaylistItemChangedEvent
} VLCPlaylistStateEvent;
@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;
...@@ -105,7 +112,7 @@ ...@@ -105,7 +112,7 @@
- (VLCMainWindowControlsBar *)controlsBar; - (VLCMainWindowControlsBar *)controlsBar;
- (IBAction)togglePlaylist:(id)sender; - (void)changePlaylistState:(VLCPlaylistStateEvent)event;
- (IBAction)dropzoneButtonAction:(id)sender; - (IBAction)dropzoneButtonAction:(id)sender;
......
...@@ -476,55 +476,48 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -476,55 +476,48 @@ static VLCMainWindow *_o_sharedInstance = nil;
[self makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]]; [self makeFirstResponder: [[o_video_view subviews] objectAtIndex:0]];
} }
// only exception for an controls bar button action
- (IBAction)togglePlaylist:(id)sender - (void)changePlaylistState:(VLCPlaylistStateEvent)event
{ {
// Beware, this code is really ugly // Beware, this code is really ugly
/* msg_Dbg(VLCIntf, "toggle playlist from state: removed splitview %i, minimized view %i. Event %i", b_splitview_removed, b_minimized_view, event);
* sender can be: if (![self isVisible] && event == psUserMenuEvent) {
* - nil if video playback is started or stopped [self makeKeyAndOrderFront: nil];
* - NSNumber with 1 if playlist item changes --> show video view
* - sender object if triggered through menu item or button
*/
BOOL b_unhide_videoview = NO;
if([sender isKindOfClass: [NSNumber class]] && [sender intValue] == 1) {
b_unhide_videoview = YES;
sender = nil;
}
msg_Dbg(VLCIntf, "toggle playlist from state: removed splitview %i, minimized view %i. Sender is %p, unhide video view %i", b_splitview_removed, b_minimized_view, sender, b_unhide_videoview);
if (![self isVisible] && sender != nil) {
[self makeKeyAndOrderFront: sender];
return; return;
} }
BOOL b_activeVideo = [[VLCMain sharedInstance] activeVideoPlayback]; BOOL b_activeVideo = [[VLCMain sharedInstance] activeVideoPlayback];
BOOL b_restored = NO; BOOL b_restored = NO;
// ignore alt if triggered through main menu shortcut
BOOL b_have_alt_key = ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) != 0; BOOL b_have_alt_key = ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) != 0;
if (sender && [sender isKindOfClass: [NSMenuItem class]]) if (event == psUserMenuEvent)
b_have_alt_key = NO; b_have_alt_key = NO;
// eUserMenuEvent is now handled same as eUserEvent
if(event == psUserMenuEvent)
event = psUserEvent;
if (b_dropzone_active && b_have_alt_key) { if (b_dropzone_active && b_have_alt_key) {
[self hideDropZone]; [self hideDropZone];
return; return;
} }
if (!(b_nativeFullscreenMode && b_fullscreen) && !b_splitview_removed && ((b_have_alt_key && b_activeVideo) if (!(b_nativeFullscreenMode && b_fullscreen) && !b_splitview_removed && ((b_have_alt_key && b_activeVideo)
|| (b_nonembedded && sender != nil) || (b_nonembedded && event == psUserEvent)
|| (!b_activeVideo && sender != nil) || (!b_activeVideo && event == psUserEvent)
|| (b_minimized_view && sender == nil && b_unhide_videoview == NO))) { || (b_minimized_view && event == psVideoStartedOrStoppedEvent))) {
// for starting playback, window is resized through resized events // for starting playback, window is resized through resized events
// for stopping playback, resize through reset to previous frame // for stopping playback, resize through reset to previous frame
[self hideSplitView: sender != nil]; [self hideSplitView: event != psVideoStartedOrStoppedEvent];
b_minimized_view = NO; b_minimized_view = NO;
} else { } else {
if (b_splitview_removed) { if (b_splitview_removed) {
if (!b_nonembedded || (sender != nil && b_nonembedded)) if (!b_nonembedded || (event == psUserEvent && b_nonembedded))
[self showSplitView: sender != nil || b_unhide_videoview]; [self showSplitView: event != psVideoStartedOrStoppedEvent];
if (sender == nil) if (event != psUserEvent)
b_minimized_view = YES; b_minimized_view = YES;
else else
b_minimized_view = NO; b_minimized_view = NO;
...@@ -534,7 +527,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -534,7 +527,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
if (!b_nonembedded) { if (!b_nonembedded) {
if (([o_video_view isHidden] && b_activeVideo) || b_restored || (b_activeVideo && sender == nil)) if (([o_video_view isHidden] && b_activeVideo) || b_restored || (b_activeVideo && event != psUserEvent))
[self makeSplitViewHidden]; [self makeSplitViewHidden];
else else
[self makeSplitViewVisible]; [self makeSplitViewVisible];
...@@ -815,6 +808,8 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -815,6 +808,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_fspanel setNonActive: nil]; [o_fspanel setNonActive: nil];
} }
} }
[self changePlaylistState: psVideoStartedOrStoppedEvent];
} }
#pragma mark - #pragma mark -
......
...@@ -1268,7 +1268,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1268,7 +1268,7 @@ static VLCMain *_o_sharedMainInstance = nil;
#pragma mark - #pragma mark -
#pragma mark Interface updaters #pragma mark Interface updaters
// This must be called on main thread
- (void)PlaylistItemChanged - (void)PlaylistItemChanged
{ {
if (p_current_input && (p_current_input->b_dead || !vlc_object_alive(p_current_input))) { if (p_current_input && (p_current_input->b_dead || !vlc_object_alive(p_current_input))) {
...@@ -1287,7 +1287,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1287,7 +1287,7 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_mainmenu setRateControlsEnabled: YES]; [o_mainmenu setRateControlsEnabled: YES];
if ([self activeVideoPlayback] && [[o_mainwindow videoView] isHidden]) { if ([self activeVideoPlayback] && [[o_mainwindow videoView] isHidden]) {
[o_mainwindow performSelectorOnMainThread:@selector(togglePlaylist:) withObject: [NSNumber numberWithInt:1] waitUntilDone:NO]; [o_mainwindow changePlaylistState: psPlaylistItemChangedEvent];
} }
p_input_changed = vlc_object_hold(p_current_input); p_input_changed = vlc_object_hold(p_current_input);
...@@ -1538,7 +1538,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1538,7 +1538,6 @@ static VLCMain *_o_sharedMainInstance = nil;
b_active_videoplayback = b_value; b_active_videoplayback = b_value;
if (o_mainwindow) { if (o_mainwindow) {
[o_mainwindow performSelectorOnMainThread:@selector(setVideoplayEnabled) withObject:nil waitUntilDone:YES]; [o_mainwindow performSelectorOnMainThread:@selector(setVideoplayEnabled) withObject:nil waitUntilDone:YES];
[o_mainwindow performSelectorOnMainThread:@selector(togglePlaylist:) withObject:nil waitUntilDone:NO];
} }
// update sleep blockers // update sleep blockers
......
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