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 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="4756"/>
<integer value="4722"/>
<integer value="4850"/>
<integer value="5260"/>
<integer value="21"/>
<integer value="4722"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
......@@ -1829,14 +1829,6 @@
</object>
<int key="connectionID">4666</int>
</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="IBOutletConnection" key="connection">
<string key="label">o_split_view</string>
......@@ -2493,6 +2485,14 @@
</object>
<int key="connectionID">5603</int>
</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 class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
......@@ -4064,7 +4064,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">5603</int>
<int key="maxID">5604</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
......@@ -4687,7 +4687,6 @@
<string>dropzoneButtonAction:</string>
<string>removePodcast:</string>
<string>removePodcastWindowAction:</string>
<string>togglePlaylist:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
......@@ -4696,7 +4695,6 @@
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
......@@ -4708,7 +4706,6 @@
<string>dropzoneButtonAction:</string>
<string>removePodcast:</string>
<string>removePodcastWindowAction:</string>
<string>togglePlaylist:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
......@@ -4732,10 +4729,6 @@
<string key="name">removePodcastWindowAction:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">togglePlaylist:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
......@@ -4961,6 +4954,7 @@
<string>repeat:</string>
<string>shuffle:</string>
<string>stop:</string>
<string>togglePlaylist:</string>
<string>volumeAction:</string>
</object>
<object class="NSMutableArray" key="dict.values">
......@@ -4970,6 +4964,7 @@
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
......@@ -4980,6 +4975,7 @@
<string>repeat:</string>
<string>shuffle:</string>
<string>stop:</string>
<string>togglePlaylist:</string>
<string>volumeAction:</string>
</object>
<object class="NSMutableArray" key="dict.values">
......@@ -5000,6 +4996,10 @@
<string key="name">stop:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">togglePlaylist:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">volumeAction:</string>
<string key="candidateClassName">id</string>
......
......@@ -145,6 +145,8 @@
- (void)setShuffle;
- (IBAction)shuffle:(id)sender;
- (IBAction)togglePlaylist:(id)sender;
- (void)toggleEffectsButton;
- (void)toggleJumpButtons;
- (void)togglePlaymodeButtons;
......
......@@ -1062,6 +1062,11 @@ else \
[self setShuffle];
}
- (IBAction)togglePlaylist:(id)sender
{
[[[VLCMain sharedInstance] mainWindow] changePlaylistState: psUserEvent];
}
- (IBAction)volumeAction:(id)sender
{
if (sender == o_volume_sld)
......
......@@ -1128,7 +1128,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (IBAction)showPlaylist:(id)sender
{
[[VLCMainWindow sharedInstance] togglePlaylist:sender];
[[VLCMainWindow sharedInstance] changePlaylistState: psUserMenuEvent];
}
#pragma mark -
......
......@@ -42,6 +42,13 @@
@class VLCMainWindowControlsBar;
@class VLCVoutView;
typedef enum {
psUserEvent,
psUserMenuEvent,
psVideoStartedOrStoppedEvent,
psPlaylistItemChangedEvent
} VLCPlaylistStateEvent;
@interface VLCMainWindow : VLCVideoWindowCommon <PXSourceListDataSource, PXSourceListDelegate, NSWindowDelegate, NSAnimationDelegate, NSSplitViewDelegate> {
IBOutlet id o_search_fld;
......@@ -105,7 +112,7 @@
- (VLCMainWindowControlsBar *)controlsBar;
- (IBAction)togglePlaylist:(id)sender;
- (void)changePlaylistState:(VLCPlaylistStateEvent)event;
- (IBAction)dropzoneButtonAction:(id)sender;
......
......@@ -476,55 +476,48 @@ static VLCMainWindow *_o_sharedInstance = nil;
[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
/*
* sender can be:
* - nil if video playback is started or stopped
* - 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];
msg_Dbg(VLCIntf, "toggle playlist from state: removed splitview %i, minimized view %i. Event %i", b_splitview_removed, b_minimized_view, event);
if (![self isVisible] && event == psUserMenuEvent) {
[self makeKeyAndOrderFront: nil];
return;
}
BOOL b_activeVideo = [[VLCMain sharedInstance] activeVideoPlayback];
BOOL b_restored = NO;
// ignore alt if triggered through main menu shortcut
BOOL b_have_alt_key = ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask) != 0;
if (sender && [sender isKindOfClass: [NSMenuItem class]])
if (event == psUserMenuEvent)
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) {
[self hideDropZone];
return;
}
if (!(b_nativeFullscreenMode && b_fullscreen) && !b_splitview_removed && ((b_have_alt_key && b_activeVideo)
|| (b_nonembedded && sender != nil)
|| (!b_activeVideo && sender != nil)
|| (b_minimized_view && sender == nil && b_unhide_videoview == NO))) {
|| (b_nonembedded && event == psUserEvent)
|| (!b_activeVideo && event == psUserEvent)
|| (b_minimized_view && event == psVideoStartedOrStoppedEvent))) {
// for starting playback, window is resized through resized events
// for stopping playback, resize through reset to previous frame
[self hideSplitView: sender != nil];
[self hideSplitView: event != psVideoStartedOrStoppedEvent];
b_minimized_view = NO;
} else {
if (b_splitview_removed) {
if (!b_nonembedded || (sender != nil && b_nonembedded))
[self showSplitView: sender != nil || b_unhide_videoview];
if (!b_nonembedded || (event == psUserEvent && b_nonembedded))
[self showSplitView: event != psVideoStartedOrStoppedEvent];
if (sender == nil)
if (event != psUserEvent)
b_minimized_view = YES;
else
b_minimized_view = NO;
......@@ -534,7 +527,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
}
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];
else
[self makeSplitViewVisible];
......@@ -815,6 +808,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_fspanel setNonActive: nil];
}
}
[self changePlaylistState: psVideoStartedOrStoppedEvent];
}
#pragma mark -
......
......@@ -1268,7 +1268,7 @@ static VLCMain *_o_sharedMainInstance = nil;
#pragma mark -
#pragma mark Interface updaters
// This must be called on main thread
- (void)PlaylistItemChanged
{
if (p_current_input && (p_current_input->b_dead || !vlc_object_alive(p_current_input))) {
......@@ -1287,7 +1287,7 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_mainmenu setRateControlsEnabled: YES];
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);
......@@ -1538,7 +1538,6 @@ static VLCMain *_o_sharedMainInstance = nil;
b_active_videoplayback = b_value;
if (o_mainwindow) {
[o_mainwindow performSelectorOnMainThread:@selector(setVideoplayEnabled) withObject:nil waitUntilDone:YES];
[o_mainwindow performSelectorOnMainThread:@selector(togglePlaylist:) withObject:nil waitUntilDone:NO];
}
// 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