Move functions into new file TrackUtilities.cpp ...
... so that other files do not have link dependency on TrackMenus.cpp The new project enlargest the big s.c.c. by 1, to 25
This commit is contained in:
parent
02e620d35f
commit
d2f386a329
17
src/Menus.h
17
src/Menus.h
|
@ -138,23 +138,6 @@ void DoTogglePinnedHead( AudacityProject & );
|
|||
void DoRecord( AudacityProject & );
|
||||
}
|
||||
|
||||
/// Namespace for functions for Track menu
|
||||
namespace TrackActions {
|
||||
enum MoveChoice {
|
||||
OnMoveUpID, OnMoveDownID, OnMoveTopID, OnMoveBottomID
|
||||
};
|
||||
/// Move a track up, down, to top or to bottom.
|
||||
void DoMoveTrack( AudacityProject &project, Track* target, MoveChoice choice );
|
||||
// "exclusive" mute means mute the chosen track and unmute all others.
|
||||
void DoTrackMute( AudacityProject &project, Track *pTrack, bool exclusive );
|
||||
// Type of solo (standard or simple) follows the set preference, unless
|
||||
// exclusive == true, which causes the opposite behavior.
|
||||
void DoTrackSolo( AudacityProject &project, Track *pTrack, bool exclusive );
|
||||
void DoRemoveTrack( AudacityProject &project, Track * toRemove );
|
||||
void DoRemoveTracks( AudacityProject & );
|
||||
}
|
||||
|
||||
|
||||
/// Namespace for helper functions to do with plug ins
|
||||
namespace PluginActions {
|
||||
enum : unsigned {
|
||||
|
|
|
@ -29,8 +29,6 @@
|
|||
#include "AllThemeResources.h"
|
||||
#include "AudioIO.h"
|
||||
|
||||
#include "Menus.h"
|
||||
|
||||
#ifdef USE_MIDI
|
||||
#include "NoteTrack.h"
|
||||
#endif
|
||||
|
@ -44,6 +42,7 @@
|
|||
#include "ProjectWindow.h"
|
||||
#include "SelectUtilities.h"
|
||||
#include "TrackPanel.h" // for EVT_TRACK_PANEL_TIMER
|
||||
#include "TrackUtilities.h"
|
||||
#include "UndoManager.h"
|
||||
#include "WaveTrack.h"
|
||||
|
||||
|
@ -752,7 +751,7 @@ void MixerTrackCluster::OnSlider_Pan(wxCommandEvent& WXUNUSED(event))
|
|||
|
||||
void MixerTrackCluster::OnButton_Mute(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
TrackActions::DoTrackMute(
|
||||
TrackUtilities::DoTrackMute(
|
||||
*mProject, mTrack.get(), mToggleButton_Mute->WasShiftDown());
|
||||
mToggleButton_Mute->SetAlternateIdx(mTrack->GetSolo() ? 1 : 0);
|
||||
|
||||
|
@ -766,7 +765,7 @@ void MixerTrackCluster::OnButton_Mute(wxCommandEvent& WXUNUSED(event))
|
|||
|
||||
void MixerTrackCluster::OnButton_Solo(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
TrackActions::DoTrackSolo(
|
||||
TrackUtilities::DoTrackSolo(
|
||||
*mProject, mTrack.get(), mToggleButton_Solo->WasShiftDown());
|
||||
bool bIsSolo = mTrack->GetSolo();
|
||||
mToggleButton_Mute->SetAlternateIdx(bIsSolo ? 1 : 0);
|
||||
|
|
|
@ -33,6 +33,7 @@ Paul Licameli split from AudacityProject.cpp
|
|||
#include "ProjectWindow.h"
|
||||
#include "SelectUtilities.h"
|
||||
#include "TrackPanel.h"
|
||||
#include "TrackUtilities.h"
|
||||
#include "UndoManager.h"
|
||||
#include "WaveTrack.h"
|
||||
#include "wxFileNameWrapper.h"
|
||||
|
@ -736,7 +737,7 @@ void ProjectManager::ResetProjectToEmpty() {
|
|||
auto &viewInfo = ViewInfo::Get( project );
|
||||
|
||||
SelectUtilities::DoSelectAll( project );
|
||||
TrackActions::DoRemoveTracks( project );
|
||||
TrackUtilities::DoRemoveTracks( project );
|
||||
|
||||
// A new DirManager.
|
||||
DirManager::Reset( project );
|
||||
|
|
|
@ -0,0 +1,258 @@
|
|||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
TrackUtilities.cpp
|
||||
|
||||
Paul Licameli split from TrackMenus.cpp
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "TrackUtilities.h"
|
||||
|
||||
#include "ProjectHistory.h"
|
||||
#include "ProjectSettings.h"
|
||||
#include "ProjectWindow.h"
|
||||
#include "Track.h"
|
||||
#include "TrackPanel.h"
|
||||
|
||||
namespace TrackUtilities {
|
||||
|
||||
void DoRemoveTracks( AudacityProject &project )
|
||||
{
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
|
||||
std::vector<Track*> toRemove;
|
||||
for (auto track : tracks.Selected())
|
||||
toRemove.push_back(track);
|
||||
|
||||
// Capture the track preceding the first removed track
|
||||
Track *f{};
|
||||
if (!toRemove.empty()) {
|
||||
auto found = tracks.Find(toRemove[0]);
|
||||
f = *--found;
|
||||
}
|
||||
|
||||
for (auto track : toRemove)
|
||||
tracks.Remove(track);
|
||||
|
||||
if (!f)
|
||||
// try to use the last track
|
||||
f = *tracks.Any().rbegin();
|
||||
if (f) {
|
||||
// Try to use the first track after the removal
|
||||
auto found = tracks.FindLeader(f);
|
||||
auto t = *++found;
|
||||
if (t)
|
||||
f = t;
|
||||
}
|
||||
|
||||
// If we actually have something left, then make sure it's seen
|
||||
if (f)
|
||||
trackPanel.EnsureVisible(f);
|
||||
|
||||
ProjectHistory::Get( project )
|
||||
.PushState(_("Removed audio track(s)"), _("Remove Track"));
|
||||
|
||||
trackPanel.UpdateViewIfNoTracks();
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
void DoTrackMute(AudacityProject &project, Track *t, bool exclusive)
|
||||
{
|
||||
const auto &settings = ProjectSettings::Get( project );
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
|
||||
// Whatever t is, replace with lead channel
|
||||
t = *tracks.FindLeader(t);
|
||||
|
||||
// "exclusive" mute means mute the chosen track and unmute all others.
|
||||
if (exclusive) {
|
||||
for (auto leader : tracks.Leaders<PlayableTrack>()) {
|
||||
const auto group = TrackList::Channels(leader);
|
||||
bool chosen = (t == leader);
|
||||
for (auto channel : group)
|
||||
channel->SetMute( chosen ),
|
||||
channel->SetSolo( false );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Normal click toggles this track.
|
||||
auto pt = dynamic_cast<PlayableTrack *>( t );
|
||||
if (!pt)
|
||||
return;
|
||||
|
||||
bool wasMute = pt->GetMute();
|
||||
for (auto channel : TrackList::Channels(pt))
|
||||
channel->SetMute( !wasMute );
|
||||
|
||||
if (settings.IsSoloSimple() || settings.IsSoloNone())
|
||||
{
|
||||
// We also set a solo indicator if we have just one track / stereo pair playing.
|
||||
// in a group of more than one playable tracks.
|
||||
// otherwise clear solo on everything.
|
||||
|
||||
auto range = tracks.Leaders<PlayableTrack>();
|
||||
auto nPlayableTracks = range.size();
|
||||
auto nPlaying = (range - &PlayableTrack::GetMute).size();
|
||||
|
||||
for (auto track : tracks.Any<PlayableTrack>())
|
||||
// will set both of a stereo pair
|
||||
track->SetSolo( (nPlaying==1) && (nPlayableTracks > 1 ) && !track->GetMute() );
|
||||
}
|
||||
}
|
||||
ProjectHistory::Get( project ).ModifyState(true);
|
||||
|
||||
trackPanel.UpdateAccessibility();
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
void DoTrackSolo(AudacityProject &project, Track *t, bool exclusive)
|
||||
{
|
||||
const auto &settings = ProjectSettings::Get( project );
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
|
||||
// Whatever t is, replace with lead channel
|
||||
t = *tracks.FindLeader(t);
|
||||
|
||||
const auto pt = dynamic_cast<PlayableTrack *>( t );
|
||||
if (!pt)
|
||||
return;
|
||||
bool bWasSolo = pt->GetSolo();
|
||||
|
||||
bool bSoloMultiple = !settings.IsSoloSimple() ^ exclusive;
|
||||
|
||||
// Standard and Simple solo have opposite defaults:
|
||||
// Standard - Behaves as individual buttons, shift=radio buttons
|
||||
// Simple - Behaves as radio buttons, shift=individual
|
||||
// In addition, Simple solo will mute/unmute tracks
|
||||
// when in standard radio button mode.
|
||||
if ( bSoloMultiple )
|
||||
{
|
||||
for (auto channel : TrackList::Channels(pt))
|
||||
channel->SetSolo( !bWasSolo );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Normal click solo this track only, mute everything else.
|
||||
// OR unmute and unsolo everything.
|
||||
for (auto leader : tracks.Leaders<PlayableTrack>()) {
|
||||
const auto group = TrackList::Channels(leader);
|
||||
bool chosen = (t == leader);
|
||||
for (auto channel : group) {
|
||||
if (chosen) {
|
||||
channel->SetSolo( !bWasSolo );
|
||||
if( settings.IsSoloSimple() )
|
||||
channel->SetMute( false );
|
||||
}
|
||||
else {
|
||||
channel->SetSolo( false );
|
||||
if( settings.IsSoloSimple() )
|
||||
channel->SetMute( !bWasSolo );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ProjectHistory::Get( project ).ModifyState(true);
|
||||
|
||||
trackPanel.UpdateAccessibility();
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
void DoRemoveTrack(AudacityProject &project, Track * toRemove)
|
||||
{
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
// If it was focused, then NEW focus is the next or, if
|
||||
// unavailable, the previous track. (The NEW focus is set
|
||||
// after the track has been removed.)
|
||||
bool toRemoveWasFocused = trackPanel.GetFocusedTrack() == toRemove;
|
||||
Track* newFocus{};
|
||||
if (toRemoveWasFocused) {
|
||||
auto iterNext = tracks.FindLeader(toRemove), iterPrev = iterNext;
|
||||
newFocus = *++iterNext;
|
||||
if (!newFocus) {
|
||||
newFocus = *--iterPrev;
|
||||
}
|
||||
}
|
||||
|
||||
wxString name = toRemove->GetName();
|
||||
|
||||
auto channels = TrackList::Channels(toRemove);
|
||||
// Be careful to post-increment over positions that get erased!
|
||||
auto &iter = channels.first;
|
||||
while (iter != channels.end())
|
||||
tracks.Remove( * iter++ );
|
||||
|
||||
if (toRemoveWasFocused)
|
||||
trackPanel.SetFocusedTrack(newFocus);
|
||||
|
||||
ProjectHistory::Get( project ).PushState(
|
||||
wxString::Format(_("Removed track '%s.'"),
|
||||
name),
|
||||
_("Track Remove"));
|
||||
|
||||
window.FixScrollbars();
|
||||
window.HandleResize();
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
void DoMoveTrack
|
||||
(AudacityProject &project, Track* target, MoveChoice choice)
|
||||
{
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &tracks = TrackList::Get( project );
|
||||
|
||||
wxString longDesc, shortDesc;
|
||||
|
||||
switch (choice)
|
||||
{
|
||||
case OnMoveTopID:
|
||||
/* i18n-hint: Past tense of 'to move', as in 'moved audio track up'.*/
|
||||
longDesc = _("Moved '%s' to Top");
|
||||
shortDesc = _("Move Track to Top");
|
||||
|
||||
// TODO: write TrackList::Rotate to do this in one step and avoid emitting
|
||||
// an event for each swap
|
||||
while (tracks.CanMoveUp(target))
|
||||
tracks.Move(target, true);
|
||||
|
||||
break;
|
||||
case OnMoveBottomID:
|
||||
/* i18n-hint: Past tense of 'to move', as in 'moved audio track up'.*/
|
||||
longDesc = _("Moved '%s' to Bottom");
|
||||
shortDesc = _("Move Track to Bottom");
|
||||
|
||||
// TODO: write TrackList::Rotate to do this in one step and avoid emitting
|
||||
// an event for each swap
|
||||
while (tracks.CanMoveDown(target))
|
||||
tracks.Move(target, false);
|
||||
|
||||
break;
|
||||
default:
|
||||
bool bUp = (OnMoveUpID == choice);
|
||||
|
||||
tracks.Move(target, bUp);
|
||||
longDesc =
|
||||
/* i18n-hint: Past tense of 'to move', as in 'moved audio track up'.*/
|
||||
bUp? _("Moved '%s' Up")
|
||||
: _("Moved '%s' Down");
|
||||
shortDesc =
|
||||
/* i18n-hint: Past tense of 'to move', as in 'moved audio track up'.*/
|
||||
bUp? _("Move Track Up")
|
||||
: _("Move Track Down");
|
||||
|
||||
}
|
||||
|
||||
longDesc = longDesc.Format(target->GetName());
|
||||
|
||||
ProjectHistory::Get( project ).PushState(longDesc, shortDesc);
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
TrackUtilities.h
|
||||
|
||||
Paul Licameli split from TrackMenus.h
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_TRACK_UTILITIES__
|
||||
#define __AUDACITY_TRACK_UTILITIES__
|
||||
|
||||
class AudacityProject;
|
||||
class Track;
|
||||
|
||||
namespace TrackUtilities {
|
||||
|
||||
enum MoveChoice {
|
||||
OnMoveUpID, OnMoveDownID, OnMoveTopID, OnMoveBottomID
|
||||
};
|
||||
/// Move a track up, down, to top or to bottom.
|
||||
void DoMoveTrack( AudacityProject &project, Track* target, MoveChoice choice );
|
||||
// "exclusive" mute means mute the chosen track and unmute all others.
|
||||
void DoTrackMute( AudacityProject &project, Track *pTrack, bool exclusive );
|
||||
// Type of solo (standard or simple) follows the set preference, unless
|
||||
// exclusive == true, which causes the opposite behavior.
|
||||
void DoTrackSolo( AudacityProject &project, Track *pTrack, bool exclusive );
|
||||
void DoRemoveTrack( AudacityProject &project, Track * toRemove );
|
||||
void DoRemoveTracks( AudacityProject & );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -18,6 +18,7 @@
|
|||
#include "../ShuttleGui.h"
|
||||
#include "../TimeTrack.h"
|
||||
#include "../TrackPanel.h"
|
||||
#include "../TrackUtilities.h"
|
||||
#include "../UndoManager.h"
|
||||
#include "../WaveClip.h"
|
||||
#include "../ViewInfo.h"
|
||||
|
@ -567,245 +568,6 @@ void SetTrackPan(AudacityProject &project, WaveTrack * wt, LWSlider * slider)
|
|||
|
||||
namespace TrackActions {
|
||||
|
||||
// exported helper functions
|
||||
|
||||
void DoRemoveTracks( AudacityProject &project )
|
||||
{
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
|
||||
std::vector<Track*> toRemove;
|
||||
for (auto track : tracks.Selected())
|
||||
toRemove.push_back(track);
|
||||
|
||||
// Capture the track preceding the first removed track
|
||||
Track *f{};
|
||||
if (!toRemove.empty()) {
|
||||
auto found = tracks.Find(toRemove[0]);
|
||||
f = *--found;
|
||||
}
|
||||
|
||||
for (auto track : toRemove)
|
||||
tracks.Remove(track);
|
||||
|
||||
if (!f)
|
||||
// try to use the last track
|
||||
f = *tracks.Any().rbegin();
|
||||
if (f) {
|
||||
// Try to use the first track after the removal
|
||||
auto found = tracks.FindLeader(f);
|
||||
auto t = *++found;
|
||||
if (t)
|
||||
f = t;
|
||||
}
|
||||
|
||||
// If we actually have something left, then make sure it's seen
|
||||
if (f)
|
||||
trackPanel.EnsureVisible(f);
|
||||
|
||||
ProjectHistory::Get( project )
|
||||
.PushState(_("Removed audio track(s)"), _("Remove Track"));
|
||||
|
||||
trackPanel.UpdateViewIfNoTracks();
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
void DoTrackMute(AudacityProject &project, Track *t, bool exclusive)
|
||||
{
|
||||
const auto &settings = ProjectSettings::Get( project );
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
|
||||
// Whatever t is, replace with lead channel
|
||||
t = *tracks.FindLeader(t);
|
||||
|
||||
// "exclusive" mute means mute the chosen track and unmute all others.
|
||||
if (exclusive) {
|
||||
for (auto leader : tracks.Leaders<PlayableTrack>()) {
|
||||
const auto group = TrackList::Channels(leader);
|
||||
bool chosen = (t == leader);
|
||||
for (auto channel : group)
|
||||
channel->SetMute( chosen ),
|
||||
channel->SetSolo( false );
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Normal click toggles this track.
|
||||
auto pt = dynamic_cast<PlayableTrack *>( t );
|
||||
if (!pt)
|
||||
return;
|
||||
|
||||
bool wasMute = pt->GetMute();
|
||||
for (auto channel : TrackList::Channels(pt))
|
||||
channel->SetMute( !wasMute );
|
||||
|
||||
if (settings.IsSoloSimple() || settings.IsSoloNone())
|
||||
{
|
||||
// We also set a solo indicator if we have just one track / stereo pair playing.
|
||||
// in a group of more than one playable tracks.
|
||||
// otherwise clear solo on everything.
|
||||
|
||||
auto range = tracks.Leaders<PlayableTrack>();
|
||||
auto nPlayableTracks = range.size();
|
||||
auto nPlaying = (range - &PlayableTrack::GetMute).size();
|
||||
|
||||
for (auto track : tracks.Any<PlayableTrack>())
|
||||
// will set both of a stereo pair
|
||||
track->SetSolo( (nPlaying==1) && (nPlayableTracks > 1 ) && !track->GetMute() );
|
||||
}
|
||||
}
|
||||
ProjectHistory::Get( project ).ModifyState(true);
|
||||
|
||||
trackPanel.UpdateAccessibility();
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
void DoTrackSolo(AudacityProject &project, Track *t, bool exclusive)
|
||||
{
|
||||
const auto &settings = ProjectSettings::Get( project );
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
|
||||
// Whatever t is, replace with lead channel
|
||||
t = *tracks.FindLeader(t);
|
||||
|
||||
const auto pt = dynamic_cast<PlayableTrack *>( t );
|
||||
if (!pt)
|
||||
return;
|
||||
bool bWasSolo = pt->GetSolo();
|
||||
|
||||
bool bSoloMultiple = !settings.IsSoloSimple() ^ exclusive;
|
||||
|
||||
// Standard and Simple solo have opposite defaults:
|
||||
// Standard - Behaves as individual buttons, shift=radio buttons
|
||||
// Simple - Behaves as radio buttons, shift=individual
|
||||
// In addition, Simple solo will mute/unmute tracks
|
||||
// when in standard radio button mode.
|
||||
if ( bSoloMultiple )
|
||||
{
|
||||
for (auto channel : TrackList::Channels(pt))
|
||||
channel->SetSolo( !bWasSolo );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Normal click solo this track only, mute everything else.
|
||||
// OR unmute and unsolo everything.
|
||||
for (auto leader : tracks.Leaders<PlayableTrack>()) {
|
||||
const auto group = TrackList::Channels(leader);
|
||||
bool chosen = (t == leader);
|
||||
for (auto channel : group) {
|
||||
if (chosen) {
|
||||
channel->SetSolo( !bWasSolo );
|
||||
if( settings.IsSoloSimple() )
|
||||
channel->SetMute( false );
|
||||
}
|
||||
else {
|
||||
channel->SetSolo( false );
|
||||
if( settings.IsSoloSimple() )
|
||||
channel->SetMute( !bWasSolo );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ProjectHistory::Get( project ).ModifyState(true);
|
||||
|
||||
trackPanel.UpdateAccessibility();
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
void DoRemoveTrack(AudacityProject &project, Track * toRemove)
|
||||
{
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
// If it was focused, then NEW focus is the next or, if
|
||||
// unavailable, the previous track. (The NEW focus is set
|
||||
// after the track has been removed.)
|
||||
bool toRemoveWasFocused = trackPanel.GetFocusedTrack() == toRemove;
|
||||
Track* newFocus{};
|
||||
if (toRemoveWasFocused) {
|
||||
auto iterNext = tracks.FindLeader(toRemove), iterPrev = iterNext;
|
||||
newFocus = *++iterNext;
|
||||
if (!newFocus) {
|
||||
newFocus = *--iterPrev;
|
||||
}
|
||||
}
|
||||
|
||||
wxString name = toRemove->GetName();
|
||||
|
||||
auto channels = TrackList::Channels(toRemove);
|
||||
// Be careful to post-increment over positions that get erased!
|
||||
auto &iter = channels.first;
|
||||
while (iter != channels.end())
|
||||
tracks.Remove( * iter++ );
|
||||
|
||||
if (toRemoveWasFocused)
|
||||
trackPanel.SetFocusedTrack(newFocus);
|
||||
|
||||
ProjectHistory::Get( project ).PushState(
|
||||
wxString::Format(_("Removed track '%s.'"),
|
||||
name),
|
||||
_("Track Remove"));
|
||||
|
||||
window.FixScrollbars();
|
||||
window.HandleResize();
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
void DoMoveTrack
|
||||
(AudacityProject &project, Track* target, MoveChoice choice)
|
||||
{
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &tracks = TrackList::Get( project );
|
||||
|
||||
wxString longDesc, shortDesc;
|
||||
|
||||
switch (choice)
|
||||
{
|
||||
case OnMoveTopID:
|
||||
/* i18n-hint: Past tense of 'to move', as in 'moved audio track up'.*/
|
||||
longDesc = _("Moved '%s' to Top");
|
||||
shortDesc = _("Move Track to Top");
|
||||
|
||||
// TODO: write TrackList::Rotate to do this in one step and avoid emitting
|
||||
// an event for each swap
|
||||
while (tracks.CanMoveUp(target))
|
||||
tracks.Move(target, true);
|
||||
|
||||
break;
|
||||
case OnMoveBottomID:
|
||||
/* i18n-hint: Past tense of 'to move', as in 'moved audio track up'.*/
|
||||
longDesc = _("Moved '%s' to Bottom");
|
||||
shortDesc = _("Move Track to Bottom");
|
||||
|
||||
// TODO: write TrackList::Rotate to do this in one step and avoid emitting
|
||||
// an event for each swap
|
||||
while (tracks.CanMoveDown(target))
|
||||
tracks.Move(target, false);
|
||||
|
||||
break;
|
||||
default:
|
||||
bool bUp = (OnMoveUpID == choice);
|
||||
|
||||
tracks.Move(target, bUp);
|
||||
longDesc =
|
||||
/* i18n-hint: Past tense of 'to move', as in 'moved audio track up'.*/
|
||||
bUp? _("Moved '%s' Up")
|
||||
: _("Moved '%s' Down");
|
||||
shortDesc =
|
||||
/* i18n-hint: Past tense of 'to move', as in 'moved audio track up'.*/
|
||||
bUp? _("Move Track Up")
|
||||
: _("Move Track Down");
|
||||
|
||||
}
|
||||
|
||||
longDesc = longDesc.Format(target->GetName());
|
||||
|
||||
ProjectHistory::Get( project ).PushState(longDesc, shortDesc);
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
|
||||
// Menu handler functions
|
||||
|
||||
struct Handler : CommandHandlerObject {
|
||||
|
@ -1040,7 +802,7 @@ void OnResample(const CommandContext &context)
|
|||
|
||||
void OnRemoveTracks(const CommandContext &context)
|
||||
{
|
||||
DoRemoveTracks( context.project );
|
||||
TrackUtilities::DoRemoveTracks( context.project );
|
||||
}
|
||||
|
||||
void OnMuteAllTracks(const CommandContext &context)
|
||||
|
@ -1399,7 +1161,7 @@ void OnTrackMute(const CommandContext &context)
|
|||
|
||||
const auto track = trackPanel.GetFocusedTrack();
|
||||
if (track) track->TypeSwitch( [&](PlayableTrack *t) {
|
||||
DoTrackMute(project, t, false);
|
||||
TrackUtilities::DoTrackMute(project, t, false);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1410,7 +1172,7 @@ void OnTrackSolo(const CommandContext &context)
|
|||
|
||||
const auto track = trackPanel.GetFocusedTrack();
|
||||
if (track) track->TypeSwitch( [&](PlayableTrack *t) {
|
||||
DoTrackSolo(project, t, false);
|
||||
TrackUtilities::DoTrackSolo(project, t, false);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1433,7 +1195,7 @@ void OnTrackClose(const CommandContext &context)
|
|||
return;
|
||||
}
|
||||
|
||||
DoRemoveTrack(project, t);
|
||||
TrackUtilities::DoRemoveTrack(project, t);
|
||||
|
||||
trackPanel.UpdateViewIfNoTracks();
|
||||
trackPanel.Refresh(false);
|
||||
|
@ -1447,7 +1209,7 @@ void OnTrackMoveUp(const CommandContext &context)
|
|||
|
||||
Track *const focusedTrack = trackPanel.GetFocusedTrack();
|
||||
if (tracks.CanMoveUp(focusedTrack)) {
|
||||
DoMoveTrack(project, focusedTrack, OnMoveUpID);
|
||||
DoMoveTrack(project, focusedTrack, TrackUtilities::OnMoveUpID);
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
}
|
||||
|
@ -1460,7 +1222,7 @@ void OnTrackMoveDown(const CommandContext &context)
|
|||
|
||||
Track *const focusedTrack = trackPanel.GetFocusedTrack();
|
||||
if (tracks.CanMoveDown(focusedTrack)) {
|
||||
DoMoveTrack(project, focusedTrack, OnMoveDownID);
|
||||
DoMoveTrack(project, focusedTrack, TrackUtilities::OnMoveDownID);
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
}
|
||||
|
@ -1473,7 +1235,7 @@ void OnTrackMoveTop(const CommandContext &context)
|
|||
|
||||
Track *const focusedTrack = trackPanel.GetFocusedTrack();
|
||||
if (tracks.CanMoveUp(focusedTrack)) {
|
||||
DoMoveTrack(project, focusedTrack, OnMoveTopID);
|
||||
DoMoveTrack(project, focusedTrack, TrackUtilities::OnMoveTopID);
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
}
|
||||
|
@ -1486,7 +1248,7 @@ void OnTrackMoveBottom(const CommandContext &context)
|
|||
|
||||
Track *const focusedTrack = trackPanel.GetFocusedTrack();
|
||||
if (tracks.CanMoveDown(focusedTrack)) {
|
||||
DoMoveTrack(project, focusedTrack, OnMoveBottomID);
|
||||
DoMoveTrack(project, focusedTrack, TrackUtilities::OnMoveBottomID);
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ Paul Licameli split from TrackPanel.cpp
|
|||
|
||||
#include "PlayableTrackControls.h"
|
||||
#include "../../../commands/CommandManager.h"
|
||||
#include "../../../Menus.h"
|
||||
#include "../../../Project.h"
|
||||
#include "../../../ProjectSettings.h"
|
||||
#include "../../../RefreshCode.h"
|
||||
|
@ -21,6 +20,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#include "../../../TrackInfo.h"
|
||||
#include "../../../TrackPanel.h"
|
||||
#include "../../../TrackPanelMouseEvent.h"
|
||||
#include "../../../TrackUtilities.h"
|
||||
|
||||
MuteButtonHandle::MuteButtonHandle
|
||||
( const std::shared_ptr<Track> &pTrack, const wxRect &rect )
|
||||
|
@ -36,7 +36,7 @@ UIHandle::Result MuteButtonHandle::CommitChanges
|
|||
{
|
||||
auto pTrack = mpTrack.lock();
|
||||
if ( dynamic_cast< PlayableTrack* >( pTrack.get() ) )
|
||||
TrackActions::DoTrackMute(*pProject, pTrack.get(), event.ShiftDown());
|
||||
TrackUtilities::DoTrackMute(*pProject, pTrack.get(), event.ShiftDown());
|
||||
|
||||
return RefreshCode::RefreshNone;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ UIHandle::Result SoloButtonHandle::CommitChanges
|
|||
{
|
||||
auto pTrack = mpTrack.lock();
|
||||
if ( dynamic_cast< PlayableTrack* >( pTrack.get() ) )
|
||||
TrackActions::DoTrackSolo(*pProject, pTrack.get(), event.ShiftDown());
|
||||
TrackUtilities::DoTrackSolo(*pProject, pTrack.get(), event.ShiftDown());
|
||||
|
||||
return RefreshCode::RefreshNone;
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ Paul Licameli split from TrackControls.cpp
|
|||
#include "TrackButtonHandles.h"
|
||||
#include "TrackSelectHandle.h"
|
||||
#include "../../RefreshCode.h"
|
||||
#include "../../Menus.h"
|
||||
#include "../../Project.h"
|
||||
#include "../../ProjectHistory.h"
|
||||
#include "../../TrackInfo.h"
|
||||
#include "../../TrackPanelMouseEvent.h"
|
||||
#include "../../TrackUtilities.h"
|
||||
#include <wx/textdlg.h>
|
||||
#include "../../commands/CommandType.h"
|
||||
#include "../../commands/CommandManager.h"
|
||||
|
@ -220,21 +220,21 @@ void TrackMenuTable::OnSetName(wxCommandEvent &)
|
|||
void TrackMenuTable::OnMoveTrack(wxCommandEvent &event)
|
||||
{
|
||||
AudacityProject *const project = GetActiveProject();
|
||||
TrackActions::MoveChoice choice;
|
||||
TrackUtilities::MoveChoice choice;
|
||||
switch (event.GetId()) {
|
||||
default:
|
||||
wxASSERT(false);
|
||||
case OnMoveUpID:
|
||||
choice = TrackActions::OnMoveUpID; break;
|
||||
choice = TrackUtilities::OnMoveUpID; break;
|
||||
case OnMoveDownID:
|
||||
choice = TrackActions::OnMoveDownID; break;
|
||||
choice = TrackUtilities::OnMoveDownID; break;
|
||||
case OnMoveTopID:
|
||||
choice = TrackActions::OnMoveTopID; break;
|
||||
choice = TrackUtilities::OnMoveTopID; break;
|
||||
case OnMoveBottomID:
|
||||
choice = TrackActions::OnMoveBottomID; break;
|
||||
choice = TrackUtilities::OnMoveBottomID; break;
|
||||
}
|
||||
|
||||
TrackActions::DoMoveTrack(*project, mpData->pTrack, choice);
|
||||
TrackUtilities::DoMoveTrack(*project, mpData->pTrack, choice);
|
||||
|
||||
// MoveTrack already refreshed TrackPanel, which means repaint will happen.
|
||||
// This is a harmless redundancy:
|
||||
|
|
|
@ -20,6 +20,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||
#include "../../Track.h"
|
||||
#include "../../TrackInfo.h"
|
||||
#include "../../TrackPanel.h"
|
||||
#include "../../TrackUtilities.h"
|
||||
#include "../../commands/CommandManager.h"
|
||||
#include "../../tracks/ui/TrackView.h"
|
||||
|
||||
|
@ -156,7 +157,7 @@ UIHandle::Result CloseButtonHandle::CommitChanges
|
|||
TransportActions::StopIfPaused( *pProject );
|
||||
if (!ProjectAudioIO::Get( *pProject ).IsAudioActive()) {
|
||||
// This pushes an undo item:
|
||||
TrackActions::DoRemoveTrack(*pProject, pTrack.get());
|
||||
TrackUtilities::DoRemoveTrack(*pProject, pTrack.get());
|
||||
// Redraw all tracks when any one of them closes
|
||||
// (Could we invent a return code that draws only those at or below
|
||||
// the affected track?)
|
||||
|
|
Loading…
Reference in New Issue