1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-24 16:20:05 +02:00

Merge branch 'macros'

This commit is contained in:
James Crook 2018-03-17 19:19:40 +00:00
commit 750ee4f462
4 changed files with 57 additions and 38 deletions

View File

@ -107,6 +107,7 @@ MacroCommands::MacroCommands()
static const wxString MP3Conversion = XO("MP3 Conversion");
static const wxString FadeEnds = XO("Fade Ends");
static const wxString SelectToEnds = XO("Select to Ends");
wxArrayString MacroCommands::GetNamesOfDefaultMacros()
@ -114,6 +115,7 @@ wxArrayString MacroCommands::GetNamesOfDefaultMacros()
wxArrayString defaults;
defaults.Add( GetCustomTranslation( MP3Conversion ) );
defaults.Add( GetCustomTranslation( FadeEnds ) );
defaults.Add( GetCustomTranslation( SelectToEnds ) );
return defaults;
}
@ -128,10 +130,13 @@ void MacroCommands::RestoreMacro(const wxString & name)
} else if (name == GetCustomTranslation( FadeEnds ) ){
AddToMacro( wxT("Select"), wxT("Start=\"0\" End=\"1\"") );
AddToMacro( wxT("FadeIn") );
AddToMacro( wxT("Select"), wxT("Start=\"0\" End=\"1\" FromEnd=\"1\"") );
AddToMacro( wxT("Select"), wxT("Start=\"0\" End=\"1\" RelativeTo=\"Project End\"") );
AddToMacro( wxT("FadeOut") );
AddToMacro( wxT("Select"), wxT("Start=\"0\" End=\"0\"") );
}
} else if (name == GetCustomTranslation( SelectToEnds ) ){
AddToMacro( wxT("SelCursorEnd") );
AddToMacro( wxT("SelStartCursor") );
}
}
wxString MacroCommands::GetCommand(int index)

View File

@ -70,7 +70,7 @@ BEGIN_EVENT_TABLE(ApplyMacroDialog, wxDialogWrapper)
END_EVENT_TABLE()
ApplyMacroDialog::ApplyMacroDialog(wxWindow * parent, bool bInherited):
wxDialogWrapper(parent, wxID_ANY, _("Apply Macros"),
wxDialogWrapper(parent, wxID_ANY, _("Macros Palette"),
wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
, mCatalog( GetActiveProject() )
@ -80,8 +80,8 @@ ApplyMacroDialog::ApplyMacroDialog(wxWindow * parent, bool bInherited):
mbExpanded = false;
if( bInherited )
return;
SetLabel(_("Apply Macros")); // Provide visual label
SetName(_("Apply Macros")); // Provide audible label
SetLabel(_("Macros Palette")); // Provide visual label
SetName(_("Macros Palette")); // Provide audible label
Populate();
}
@ -149,17 +149,21 @@ void ApplyMacroDialog::PopulateOrExchange(ShuttleGui &S)
}
/// This clears and updates the contents of mMacros, the list of macros.
/// It has cut-and-paste code from PopulateList, and both should call
/// a shared function.
void ApplyMacroDialog::PopulateMacros()
{
wxArrayString names = mMacroCommands.GetNames();
int i;
int topItem = mMacros->GetTopItem();
mMacros->DeleteAllItems();
for (i = 0; i < (int)names.GetCount(); i++) {
mMacros->InsertItem(i, names[i]);
}
int item = mMacros->FindItem(-1, mActiveMacro);
bool bFound = item >=0;
if (item == -1) {
item = 0;
mActiveMacro = mMacros->GetItemText(0);
@ -167,11 +171,19 @@ void ApplyMacroDialog::PopulateMacros()
// Select the name in the list...this will fire an event.
mMacros->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
if( 0 <= topItem && topItem < (int)mMacros->GetItemCount())
{
// Workaround for scrolling being windows only.
// Try to scroll back to where we once were...
mMacros->EnsureVisible( (int)mMacros->GetItemCount() -1 );
mMacros->EnsureVisible( topItem );
// And then make sure whatever is selected is still visible...
if( bFound )
mMacros->EnsureVisible( item );
}
}
void ApplyMacroDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
{
wxString page = GetHelpPageName();
@ -272,19 +284,8 @@ void ApplyMacroDialog::ApplyMacroToProject( int iMacro, bool bHasGui )
if( !bHasGui )
return;
if (!success) {
Show();
Raise();
return;
}
if( mbExpanded )
Hide();
else
{
Show();
Raise();
}
Show();
Raise();
}
void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
@ -457,13 +458,9 @@ void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
project->OnRemoveTracks(*project);
}
project->OnRemoveTracks(*project);
if( mbExpanded )
Hide();
else
{
Show();
Raise();
}
Show();
Raise();
}
void ApplyMacroDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
@ -533,7 +530,7 @@ MacrosWindow::MacrosWindow(wxWindow * parent, bool bExpanded):
ApplyMacroDialog(parent, true)
{
mbExpanded = bExpanded;
wxString Title = mbExpanded ? _("Manage Macros") : _("Apply Macros");
wxString Title = mbExpanded ? _("Manage Macros") : _("Macros Palette");
SetLabel( Title ); // Provide visual label
SetName( Title ); // Provide audible label
SetTitle( Title );
@ -666,6 +663,7 @@ void MacrosWindow::PopulateOrExchange(ShuttleGui & S)
/// This clears and updates the contents of mList, the commands for the current macro.
void MacrosWindow::PopulateList()
{
int topItem = mList->GetTopItem();
mList->DeleteAllItems();
for (int i = 0; i < mMacroCommands.GetCount(); i++) {
@ -680,6 +678,15 @@ void MacrosWindow::PopulateList()
mSelectedCommand = 0;
}
mList->SetItemState(mSelectedCommand, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
if( 0 <= topItem && topItem < (int)mList->GetItemCount())
{
// Workaround for scrolling being windows only.
// Try to scroll back to where we once were...
mList->EnsureVisible( (int)mList->GetItemCount() -1 );
mList->EnsureVisible( topItem );
// And then make sure whatever is selected is still visible...
mList->EnsureVisible( mSelectedCommand );
}
}
/// Add one item into mList
@ -736,7 +743,7 @@ void MacrosWindow::UpdateDisplay( bool bExpanded )
SetPosition( p );
mResize->SetFocus();
wxString Title = mbExpanded ? _("Manage Macros") : _("Apply Macros");
wxString Title = mbExpanded ? _("Manage Macros") : _("Macros Palette");
SetLabel( Title ); // Provide visual label
SetName( Title ); // Provide audible label
SetTitle( Title );
@ -965,6 +972,7 @@ void MacrosWindow::OnRemove(wxCommandEvent & WXUNUSED(event))
mMacroCommands.DeleteMacro(name);
item++;
if (item >= (mMacros->GetItemCount() - 1) && item >= 0) {
item--;
}

View File

@ -46,12 +46,12 @@ explicitly code all three.
const int nRelativeTos =6;
static const wxString kRelativeTo[nRelativeTos] =
{
XO("ProjectStart"),
XO("Project Start"),
XO("Project"),
XO("ProjectEnd"),
XO("SelectionStart"),
XO("Project End"),
XO("Selection Start"),
XO("Selection"),
XO("SelectionEnd")
XO("Selection End")
};
bool SelectTimeCommand::DefineParams( ShuttleParams & S ){

View File

@ -216,14 +216,20 @@ bool SetTrackCommand::Apply(const CommandContext & context)
case kHalfWave: wt->SetDisplayBounds(0,1); break;
}
}
// In stereo tracks, both channels need selecting/deselecting.
if( bHasSelected )
t->SetSelected(bSelected);
// These ones don't make sense on the second channel of a stereo track.
if( !bIsSecondChannel ){
if( bHasSelected )
t->SetSelected(bSelected);
if( bHasFocused && bFocused)
if( bHasFocused )
{
TrackPanel *panel = context.GetProject()->GetTrackPanel();
panel->SetFocusedTrack( t );
if( bFocused)
panel->SetFocusedTrack( t );
else if( t== panel->GetFocusedTrack() )
panel->SetFocusedTrack( nullptr );
}
if( pt && bHasSolo )
pt->SetSolo(bSolo);