[vlc-commits] macosx: allow simultanous video or SPU track selection
Felix Paul Kühne
git at videolan.org
Mon Aug 19 10:49:08 CEST 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Mon Aug 19 10:23:43 2019 +0200| [35d0d00ff644947c6f7507565b8c3addb561311a] | committer: Felix Paul Kühne
macosx: allow simultanous video or SPU track selection
Press the alt key to select more than 1 key.
This also fixes the state display in main menu when the selection changes.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=35d0d00ff644947c6f7507565b8c3addb561311a
---
modules/gui/macosx/menus/VLCMainMenu.m | 20 ++++++++++++++++++--
modules/gui/macosx/playlist/VLCPlayerController.h | 4 +++-
modules/gui/macosx/playlist/VLCPlayerController.m | 7 ++++---
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/modules/gui/macosx/menus/VLCMainMenu.m b/modules/gui/macosx/menus/VLCMainMenu.m
index 853f9de4fe..ebbe0296b4 100644
--- a/modules/gui/macosx/menus/VLCMainMenu.m
+++ b/modules/gui/macosx/menus/VLCMainMenu.m
@@ -187,6 +187,10 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
name:VLCPlayerTrackListChanged
object:nil];
[notificationCenter addObserver:self
+ selector:@selector(updateTrackHandlingMenus:)
+ name:VLCPlayerTrackSelectionChanged
+ object:nil];
+ [notificationCenter addObserver:self
selector:@selector(updateTitleAndChapterMenus:)
name:VLCPlayerTitleListChanged
object:nil];
@@ -906,6 +910,7 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
category:(enum es_format_category_e)category
{
[menu removeAllItems];
+ BOOL itemSelected = NO;
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:_NS("Disable")
action:@selector(unselectTrackCategory:)
@@ -923,14 +928,25 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
[menuItem setTarget:self];
[menuItem setRepresentedObject:metaDataItem];
[menuItem setEnabled:YES];
- [menuItem setState:metaDataItem.selected ? NSOnState : NSOffState];
+ if (metaDataItem.selected) {
+ itemSelected = YES;
+ [menuItem setState:NSOnState];
+ } else {
+ [menuItem setState:NSOffState];
+ }
[menu addItem:menuItem];
}
+
+ /* select the "Disabled" item in case no track is selected */
+ if (!itemSelected) {
+ [menu.itemArray.firstObject setState:NSOnState];
+ }
}
- (void)selectTrack:(NSMenuItem *)sender
{
- [_playerController selectTrack:[sender representedObject]];
+ NSEvent *currentEvent = [NSApp currentEvent];
+ [_playerController selectTrack:[sender representedObject] exclusively:!(currentEvent.modifierFlags & NSAlternateKeyMask)];
}
- (void)unselectTrackCategory:(NSMenuItem *)sender
diff --git a/modules/gui/macosx/playlist/VLCPlayerController.h b/modules/gui/macosx/playlist/VLCPlayerController.h
index 33f952f33e..77e3192ff0 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.h
+++ b/modules/gui/macosx/playlist/VLCPlayerController.h
@@ -716,10 +716,12 @@ extern const CGFloat VLCVolumeDefault;
/**
* select a track
+ * @param the track to select
+ * @param indicate whether multiple tracks may be played (video and SPU only)
* @note since tracks are unique, you do not need to specify the type
* @note listen to VLCTrackSelectionChanged to be notified once the change occured
*/
-- (void)selectTrack:(VLCTrackMetaData *)track;
+- (void)selectTrack:(VLCTrackMetaData *)track exclusively:(BOOL)exclusiveSelection;
/**
* unselect a track
diff --git a/modules/gui/macosx/playlist/VLCPlayerController.m b/modules/gui/macosx/playlist/VLCPlayerController.m
index 7401a1be02..d6a20b67ba 100644
--- a/modules/gui/macosx/playlist/VLCPlayerController.m
+++ b/modules/gui/macosx/playlist/VLCPlayerController.m
@@ -1387,10 +1387,11 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
[_defaultNotificationCenter postNotificationName:VLCPlayerTrackListChanged object:nil];
}
-- (void)selectTrack:(VLCTrackMetaData *)track
+- (void)selectTrack:(VLCTrackMetaData *)track exclusively:(BOOL)exclusiveSelection
{
vlc_player_Lock(_p_player);
- vlc_player_SelectEsId(_p_player, track.esID, VLC_PLAYER_SELECT_EXCLUSIVE);
+ const enum es_format_category_e formatCategory = vlc_es_id_GetCat(track.esID);
+ vlc_player_SelectEsId(_p_player, track.esID, (formatCategory == AUDIO_ES || exclusiveSelection) ? VLC_PLAYER_SELECT_EXCLUSIVE : VLC_PLAYER_SELECT_SIMULTANEOUS);
vlc_player_Unlock(_p_player);
}
@@ -1767,7 +1768,7 @@ static const struct vlc_player_aout_cbs player_aout_callbacks = {
- (NSString *)description
{
- return [NSString stringWithFormat:@"%@: name: %@", [VLCTrackMetaData className], self.name];
+ return [NSString stringWithFormat:@"%@: name: %@, selected: %i", [VLCTrackMetaData className], self.name, self.selected];
}
@end
More information about the vlc-commits
mailing list