1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-19 22:27:43 +02:00

Add commands for muting/unmuting selected tracks

There was no convenient way of muting or unmuting some, but not all
tracks. With the new commands, it is possible to quickly select a subset
of all tracks via Shift+click and then mute or unmute them.
This commit is contained in:
Lukas Werling 2020-03-07 23:25:23 +01:00 committed by James Crook
parent 9210c2aa35
commit 6d30936d68

View File

@ -835,7 +835,7 @@ void OnRemoveTracks(const CommandContext &context)
TrackUtilities::DoRemoveTracks( context.project ); TrackUtilities::DoRemoveTracks( context.project );
} }
void OnMuteAllTracks(const CommandContext &context) static void MuteTracks(const CommandContext &context, bool mute, bool selected)
{ {
auto &project = context.project; auto &project = context.project;
const auto &settings = ProjectSettings::Get( project ); const auto &settings = ProjectSettings::Get( project );
@ -845,9 +845,10 @@ void OnMuteAllTracks(const CommandContext &context)
auto soloSimple = settings.IsSoloSimple(); auto soloSimple = settings.IsSoloSimple();
auto soloNone = settings.IsSoloNone(); auto soloNone = settings.IsSoloNone();
for (auto pt : tracks.Any<PlayableTrack>()) auto iter = selected ? tracks.Selected<PlayableTrack>() : tracks.Any<PlayableTrack>();
for (auto pt : iter)
{ {
pt->SetMute(true); pt->SetMute(mute);
if (soloSimple || soloNone) if (soloSimple || soloNone)
pt->SetSolo(false); pt->SetSolo(false);
} }
@ -855,24 +856,24 @@ void OnMuteAllTracks(const CommandContext &context)
ProjectHistory::Get( project ).ModifyState(true); ProjectHistory::Get( project ).ModifyState(true);
} }
void OnMuteAllTracks(const CommandContext &context)
{
MuteTracks(context, true, false);
}
void OnUnmuteAllTracks(const CommandContext &context) void OnUnmuteAllTracks(const CommandContext &context)
{ {
auto &project = context.project; MuteTracks(context, false, false);
const auto &settings = ProjectSettings::Get( project ); }
auto &tracks = TrackList::Get( project );
auto &window = ProjectWindow::Get( project );
auto soloSimple = settings.IsSoloSimple(); void OnMuteSelectedTracks(const CommandContext &context)
auto soloNone = settings.IsSoloNone(); {
MuteTracks(context, true, true);
}
for (auto pt : tracks.Any<PlayableTrack>()) void OnUnmuteSelectedTracks(const CommandContext &context)
{ {
pt->SetMute(false); MuteTracks(context, false, true);
if (soloSimple || soloNone)
pt->SetSolo(false);
}
ProjectHistory::Get( project ).ModifyState(true);
} }
void OnPanLeft(const CommandContext &context) void OnPanLeft(const CommandContext &context)
@ -1357,7 +1358,11 @@ BaseItemSharedPtr TracksMenu()
Command( wxT("MuteAllTracks"), XXO("&Mute All Tracks"), Command( wxT("MuteAllTracks"), XXO("&Mute All Tracks"),
FN(OnMuteAllTracks), AudioIONotBusyFlag(), wxT("Ctrl+U") ), FN(OnMuteAllTracks), AudioIONotBusyFlag(), wxT("Ctrl+U") ),
Command( wxT("UnmuteAllTracks"), XXO("&Unmute All Tracks"), Command( wxT("UnmuteAllTracks"), XXO("&Unmute All Tracks"),
FN(OnUnmuteAllTracks), AudioIONotBusyFlag(), wxT("Ctrl+Shift+U") ) FN(OnUnmuteAllTracks), AudioIONotBusyFlag(), wxT("Ctrl+Shift+U") ),
Command( wxT("MuteSelectedTracks"), XXO("&Mute Selected Tracks"),
FN(OnMuteSelectedTracks), AudioIONotBusyFlag(), wxT("Ctrl+Alt+U") ),
Command( wxT("UnmuteSelectedTracks"), XXO("&Unmute Selected Tracks"),
FN(OnUnmuteSelectedTracks), AudioIONotBusyFlag(), wxT("Ctrl+Alt+Shift+U") )
), ),
Menu( wxT("Pan"), XO("&Pan"), Menu( wxT("Pan"), XO("&Pan"),