Audacity  3.0.3
BatchProcessDialog.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ApplyMacroDialog.cpp
6 
7  Dominic Mazzoni
8  James Crook
9 
10 *******************************************************************//*******************************************************************/
16 
17 
18 #include "BatchProcessDialog.h"
19 
20 #include <wx/setup.h> // for wxUSE_* macros
21 
22 #ifdef __WXMSW__
23  #include <wx/ownerdrw.h>
24 #endif
25 
26 #include <wx/defs.h>
27 #include <wx/checkbox.h>
28 #include <wx/choice.h>
29 #include <wx/intl.h>
30 #include <wx/log.h>
31 #include <wx/sizer.h>
32 #include <wx/statbox.h>
33 #include <wx/stattext.h>
34 #include <wx/textctrl.h>
35 #include <wx/listctrl.h>
36 #include <wx/radiobut.h>
37 #include <wx/button.h>
38 #include <wx/imaglist.h>
39 #include <wx/settings.h>
40 
41 #include "Clipboard.h"
42 #include "ShuttleGui.h"
43 #include "Menus.h"
44 #include "Prefs.h"
45 #include "Project.h"
46 #include "ProjectFileManager.h"
47 #include "ProjectHistory.h"
48 #include "ProjectManager.h"
49 #include "ProjectWindow.h"
50 #include "SelectUtilities.h"
52 #include "effects/Effect.h"
53 #include "../images/Arrow.xpm"
54 #include "../images/Empty9x16.xpm"
55 #include "UndoManager.h"
56 
57 #include "AllThemeResources.h"
58 
60 #include "FileNames.h"
61 #include "import/Import.h"
64 #include "widgets/HelpSystem.h"
65 
66 #if wxUSE_ACCESSIBILITY
68 #endif
69 
70 #define MacrosPaletteTitle XO("Macros Palette")
71 #define ManageMacrosTitle XO("Manage Macros")
72 
73 
74 // Separate numerical range from the additional buttons
75 // in the expanded view (which start at 10,000).
76 #define MacrosListID 7001
77 #define CommandsListID 7002
78 #define ApplyToProjectID 7003
79 #define ApplyToFilesID 7004
80 #define ExpandID 7005
81 #define ShrinkID 7006
82 
83 BEGIN_EVENT_TABLE(ApplyMacroDialog, wxDialogWrapper)
90 
92  wxWindow * parent, AudacityProject &project, bool bInherited):
93  wxDialogWrapper(parent, wxID_ANY, MacrosPaletteTitle,
94  wxDefaultPosition, wxDefaultSize,
95  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
96  , mMacroCommands{ project }
97  , mProject{ project }
98  , mCatalog( &project )
99 {
100  mAbort = false;
101  mbExpanded = false;
102  if( bInherited )
103  return;
104  SetLabel(MacrosPaletteTitle); // Provide visual label
105  SetName(MacrosPaletteTitle); // Provide audible label
106  Populate();
107 
108 }
109 
111 {
112 }
113 
115 {
116  //------------------------- Main section --------------------
117  ShuttleGui S(this, eIsCreating);
119  // ----------------------- End of main section --------------
120  // Get and validate the currently active macro
121  mActiveMacro = gPrefs->Read(wxT("/Batch/ActiveMacro"), wxT(""));
122  // Go populate the macros list.
123  PopulateMacros();
124 
125  Layout();
126  Fit();
127  wxSize sz = GetSize();
128  SetSizeHints( sz );
129 
130  // Size and place window
131  SetSize(std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4, sz.GetWidth()),
132  std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5, 400));
133 
134  Center();
135 
136  // Set the column size for the macros list.
137  sz = mMacros->GetClientSize();
138  mMacros->SetColumnWidth(0, sz.x);
139 }
140 
143 {
144  /*i18n-hint: A macro is a sequence of commands that can be applied
145  * to one or more audio files.*/
146  S.StartStatic(XO("Select Macro"), 1);
147  {
148  mMacros = S.Id(MacrosListID).Prop(1)
149  .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
150  wxLC_SINGLE_SEL)
151  // i18n-hint: This is the heading for a column in the edit macros dialog
152  .AddListControlReportMode( { XO("Macro") } );
153  }
154  S.EndStatic();
155 
156  S.StartHorizontalLay(wxEXPAND, 0);
157  {
158  S.AddPrompt( XXO("Apply Macro to:") );
159  wxButton* btn = S.Id(ApplyToProjectID)
160  .Name(XO("Apply macro to project"))
161  .AddButton(XXO("&Project"));
162 #if wxUSE_ACCESSIBILITY
163  // so that name can be set on a standard control
164  btn->SetAccessible(safenew WindowAccessible(btn));
165 #endif
166 
167  btn = S.Id(ApplyToFilesID)
168  .Name(XO("Apply macro to files..."))
169  .AddButton(XXO("&Files..."));
170 #if wxUSE_ACCESSIBILITY
171  // so that name can be set on a standard control
172  btn->SetAccessible(safenew WindowAccessible(btn));
173 #endif
174  }
175  S.EndHorizontalLay();
176 
177  S.StartHorizontalLay(wxEXPAND, 0);
178  {
179  /* i18n-hint: The Expand button makes the dialog bigger, with more in it */
180  mResize = S.Id(ExpandID).AddButton(XXO("&Expand"));
181  S.AddSpace( 10,10,1 );
183  }
184  S.EndHorizontalLay();
185 }
186 
191 {
192  auto names = mMacroCommands.GetNames();
193  int i;
194 
195  int topItem = mMacros->GetTopItem();
196  mMacros->DeleteAllItems();
197  for (i = 0; i < (int)names.size(); i++) {
198  mMacros->InsertItem(i, names[i]);
199  }
200 
201  int item = mMacros->FindItem(-1, mActiveMacro);
202  bool bFound = item >=0;
203  if (item == -1) {
204  item = 0;
205  mActiveMacro = mMacros->GetItemText(0);
206  }
207 
208  // Select the name in the list...this will fire an event.
209  mMacros->SetItemState(item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
210  wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
211 
212  if( 0 <= topItem && topItem < (int)mMacros->GetItemCount())
213  {
214  // Workaround for scrolling being windows only.
215  // Try to scroll back to where we once were...
216  mMacros->EnsureVisible( (int)mMacros->GetItemCount() -1 );
217  mMacros->EnsureVisible( topItem );
218  // And then make sure whatever is selected is still visible...
219  if( bFound )
220  mMacros->EnsureVisible( item );
221  }
222 }
223 
224 void ApplyMacroDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
225 {
226  const auto &page = GetHelpPageName();
227  HelpSystem::ShowHelp(this, page, true);
228 }
229 
230 void ApplyMacroDialog::OnApplyToProject(wxCommandEvent & WXUNUSED(event))
231 {
232  long item = mMacros->GetNextItem(-1,
233  wxLIST_NEXT_ALL,
234  wxLIST_STATE_SELECTED);
235 
236  if (item == -1) {
237  AudacityMessageBox(XO("No macro selected"));
238  return;
239  }
240  ApplyMacroToProject( item );
241 }
242 
243 CommandID ApplyMacroDialog::MacroIdOfName( const wxString & MacroName )
244 {
245  wxString Temp = MacroName;
246  Temp.Replace(" ","");
247  Temp = wxString( "Macro_" ) + Temp;
248  return Temp;
249 }
250 
251 // Apply macro, given its ID.
252 // Does nothing if not found, rather than returning an error.
253 void ApplyMacroDialog::ApplyMacroToProject( const CommandID & MacroID, bool bHasGui )
254 {
255  for( int i=0;i<mMacros->GetItemCount();i++){
256  wxString name = mMacros->GetItemText(i);
257  if( MacroIdOfName( name ) == MacroID ){
258  ApplyMacroToProject( i, bHasGui );
259  return;
260  }
261  }
262 }
263 
264 // Apply macro, given its number in the list.
265 void ApplyMacroDialog::ApplyMacroToProject( int iMacro, bool bHasGui )
266 {
267  wxString name = mMacros->GetItemText(iMacro);
268  if( name.empty() )
269  return;
270 
271 #ifdef OPTIONAL_ACTIVITY_WINDOW
272  wxDialogWrapper activityWin( this, wxID_ANY, GetTitle());
273  activityWin.SetName();
274  ShuttleGui S(&activityWin, eIsCreating);
275 
276  S.StartHorizontalLay(wxCENTER, false);
277  {
278  S.StartStatic( {}, false); // deliberately not translated (!)
279  {
280  S.SetBorder(20);
281  S.AddFixedText(XO("Applying '%s' to current project")
282  .Format( name ) );
283  }
284  S.EndStatic();
285  }
286  S.EndHorizontalLay();
287 
288  activityWin.Layout();
289  activityWin.Fit();
290  activityWin.CenterOnScreen();
291  // Avoid overlap with progress.
292  int x,y;
293  activityWin.GetPosition( &x, &y );
294  activityWin.Move(wxMax(0,x-300), 0);
295  activityWin.Show();
296 
297  // Without this the newly created dialog may not show completely.
298  wxYield();
299 #endif
300 
301  //Since we intend to keep this dialog open, there is no reason to hide it
302  //and then show it again.
303  //if( bHasGui )
304  // Hide();
305 
306  gPrefs->Write(wxT("/Batch/ActiveMacro"), name);
307  gPrefs->Flush();
308 
310 
311  // The disabler must get deleted before the EndModal() call. Otherwise,
312  // the menus on OSX will remain disabled.
313  bool success;
314  {
315 #ifdef OPTIONAL_ACTIVITY_WINDOW
316  wxWindowDisabler wd(&activityWin);
317 #endif
318  success = GuardedCall< bool >(
319  [this]{ return mMacroCommands.ApplyMacro(mCatalog); } );
320  }
321 
322  if( !bHasGui )
323  return;
324 
325  Show();
326  Raise();
327 }
328 
329 void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
330 {
331  long item = mMacros->GetNextItem(-1,
332  wxLIST_NEXT_ALL,
333  wxLIST_STATE_SELECTED);
334  if (item == -1) {
335  AudacityMessageBox( XO("No macro selected") );
336  return;
337  }
338 
339  wxString name = mMacros->GetItemText(item);
340  gPrefs->Write(wxT("/Batch/ActiveMacro"), name);
341  gPrefs->Flush();
342 
343  AudacityProject *project = &mProject;
344  if (!TrackList::Get( *project ).empty()) {
346  XO("Please save and close the current project first.") );
347  return;
348  }
349 
350  // This insures that we start with an empty and temporary project
353 
354  auto prompt = XO("Select file(s) for batch processing...");
355 
356  const auto fileTypes = Importer::Get().GetFileTypes();
357 
358  auto path = FileNames::FindDefaultPath(FileNames::Operation::Open);
359  FileDialogWrapper dlog(this,
360  prompt,
361  path,
362  wxT(""),
363  fileTypes,
364  wxFD_OPEN | wxFD_MULTIPLE | wxRESIZE_BORDER);
365 
366  dlog.SetFilterIndex( Importer::SelectDefaultOpenType( fileTypes ) );
367  if (dlog.ShowModal() != wxID_OK) {
368  Raise();
369  return;
370  }
371  Raise();
372 
373  wxArrayString files;
374  dlog.GetPaths(files);
375 
376  files.Sort();
377 
378  wxDialogWrapper activityWin(this, wxID_ANY, Verbatim( GetTitle() ),
379  wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
380  );
381  activityWin.SetName();
382  ShuttleGui S(&activityWin, eIsCreating);
383 
384  wxListCtrl * fileList = NULL;
385 
386  S.StartVerticalLay(1);
387  {
388  S.StartStatic(XO("Applying..."), 1);
389  {
390  auto imageList = std::make_unique<wxImageList>(9, 16);
391  imageList->Add(wxIcon(empty9x16_xpm));
392  imageList->Add(wxIcon(arrow_xpm));
393 
394  fileList = S.Id(CommandsListID)
395  .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
396  wxLC_SINGLE_SEL)
397  .AddListControlReportMode( { XO("File") } );
398  // AssignImageList takes ownership
399  fileList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL);
400  }
401  S.EndStatic();
402 
403  S.StartHorizontalLay(wxCENTER, 0);
404  {
405  S.Id(wxID_CANCEL).AddButton(XXO("&Cancel"));
406  }
407  S.EndHorizontalLay();
408  }
409  S.EndVerticalLay();
410 
411  int i;
412  for (i = 0; i < (int)files.size(); i++ ) {
413  fileList->InsertItem(i, files[i], i == 0);
414  }
415 
416  // Set the column size for the files list.
417  fileList->SetColumnWidth(0, wxLIST_AUTOSIZE);
418 
419  int width = wxMin( fileList->GetColumnWidth(0), 1000);
420  wxSize sz = fileList->GetClientSize();
421  if (sz.GetWidth() < width ) {
422  sz.SetWidth(width);
423  if (sz.GetHeight() < width *0.7)
424  sz.SetHeight(width * 0.7);
425  fileList->SetInitialSize(sz);
426  }
427 
428  activityWin.Layout();
429  activityWin.Fit();
430  activityWin.CenterOnScreen();
431  // Avoid overlap with progress.
432  int x,y;
433  activityWin.GetPosition( &x, &y );
434  activityWin.Move(wxMax(0,x-300), 0);
435  activityWin.Show();
436 
437  // Without this the newly created dialog may not show completely.
438  wxYield();
439  // We could avoid hiding, but there are many dialogs on screen,
440  // and hiding this one temporarily has some advantages.
441  Hide();
442 
444  {
445  // Move global clipboard contents aside temporarily
446  Clipboard tempClipboard;
447  auto &globalClipboard = Clipboard::Get();
448  globalClipboard.Swap(tempClipboard);
449  auto cleanup = finally([&]{
450  globalClipboard.Swap(tempClipboard);
451  });
452 
453  wxWindowDisabler wd(&activityWin);
454  for (i = 0; i < (int)files.size(); i++) {
455  if (i > 0) {
456  //Clear the arrow in previous item.
457  fileList->SetItemImage(i - 1, 0, 0);
458  }
459  fileList->SetItemImage(i, 1, 1);
460  fileList->EnsureVisible(i);
461 
462  auto success = GuardedCall< bool >([&] {
463  ProjectFileManager::Get(*project).Import(files[i]);
464  ProjectWindow::Get(*project).ZoomAfterImport(nullptr);
467  return false;
468 
469  if (!activityWin.IsShown() || mAbort)
470  return false;
471 
472  return true;
473  });
474 
475  // Ensure project is completely reset
477  // Bug2567:
478  // Must also destroy the clipboard, to be sure sample blocks are
479  // all freed and their ids can be reused safely in the next pass
480  globalClipboard.Clear();
481 
482  if (!success)
483  break;
484  }
485  }
486 
487  Show();
488  Raise();
489 }
490 
491 void ApplyMacroDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
492 {
493  Hide();
494 }
495 
497 #include <wx/textdlg.h>
498 #include "BatchCommandDialog.h"
499 
500 enum {
501  AddButtonID = 10000,
508 
510 
516 
517 // MacrosListID 7005
518 // CommandsListID, 7002
519 // Re-Use IDs from ApplyMacroDialog.
522 };
523 
524 BEGIN_EVENT_TABLE(MacrosWindow, ApplyMacroDialog)
527  EVT_LIST_BEGIN_LABEL_EDIT(MacrosListID, MacrosWindow::OnMacrosBeginEdit)
528  EVT_LIST_END_LABEL_EDIT(MacrosListID, MacrosWindow::OnMacrosEndEdit)
536 
539  EVT_SIZE(MacrosWindow::OnSize)
540 
547 
549  EVT_BUTTON(wxID_CANCEL, MacrosWindow::OnCancel)
551 
552  EVT_KEY_DOWN(MacrosWindow::OnKeyDown)
554 
555 enum {
559 };
560 
563  wxWindow * parent, AudacityProject &project, bool bExpanded):
564  ApplyMacroDialog(parent, project, true)
565  , mProject{ project }
566 {
567  mbExpanded = bExpanded;
568  auto Title = WindowTitle();
569  SetLabel( Title ); // Provide visual label
570  SetName( Title ); // Provide audible label
571  SetTitle( Title );
572 
573  mChanged = false;
574  mSelectedCommand = 0;
575 
576  if( mbExpanded )
577  Populate();
578  else
580 }
581 
583 {
584 }
585 
588 {
589  //------------------------- Main section --------------------
590  ShuttleGui S(this, eIsCreating);
592  // ----------------------- End of main section --------------
593 
594  // Get and validate the currently active macro
595  mActiveMacro = gPrefs->Read(wxT("/Batch/ActiveMacro"), wxT(""));
596  // Go populate the macros list.
597  PopulateMacros();
598 
599  // We have a bare list. We need to add columns and content.
600  PopulateList();
601 
602  // Layout and set minimum size of window
603  Layout();
604  Fit();
605  SetSizeHints(GetSize());
606 
607  // Size and place window
608  SetSize(std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4, 800),
609  std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5, 400));
610  Center();
611 
612  // Set the column size for the macros list.
613  wxSize sz = mMacros->GetClientSize();
614  mMacros->SetColumnWidth(0, sz.x);
615 
616  // Size columns properly
617  FitColumns();
618 }
619 
622 {
623  S.StartHorizontalLay(wxEXPAND, 1);
624  {
625  S.StartStatic(XO("Select Macro"),0);
626  {
627  S.StartHorizontalLay(wxEXPAND,1);
628  {
629  mMacros = S.Id(MacrosListID).Prop(1)
630  .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES
631  | wxLC_SINGLE_SEL | wxLC_EDIT_LABELS)
632  // i18n-hint: This is the heading for a column in the edit macros dialog
633  .AddListControlReportMode( { XO("Macro") } );
634  S.StartVerticalLay(wxALIGN_TOP, 0);
635  {
636  S.Id(AddButtonID).AddButton(XXO("&New"), wxALIGN_LEFT);
637  mRemove = S.Id(RemoveButtonID).AddButton(XXO("Remo&ve"), wxALIGN_LEFT);
638  mRename = S.Id(RenameButtonID).AddButton(XXO("&Rename..."), wxALIGN_LEFT);
639  mRestore = S.Id(RestoreButtonID).AddButton(XXO("Re&store"), wxALIGN_LEFT);
640  mImport = S.Id(ImportButtonID).AddButton(XO("I&mport..."), wxALIGN_LEFT);
641  mExport = S.Id(ExportButtonID).AddButton(XO("E&xport..."), wxALIGN_LEFT);
642  }
643  S.EndVerticalLay();
644  }
645  S.EndHorizontalLay();
646  }
647  S.EndStatic();
648 
649  S.StartStatic(XO("Edit Steps"), true);
650  {
651  S.StartHorizontalLay(wxEXPAND,1);
652  {
653  mList = S.Id(CommandsListID)
654  .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
655  wxLC_SINGLE_SEL)
657  /* i18n-hint: This is the number of the command in the list */
658  { XO("Num"), wxLIST_FORMAT_RIGHT },
659  { XO("Command "), wxLIST_FORMAT_RIGHT },
660  { XO("Parameters"), wxLIST_FORMAT_LEFT }
661  });
662 
663  S.StartVerticalLay(wxALIGN_TOP, 0);
664  {
665  S.Id(InsertButtonID).AddButton(XXO("&Insert"), wxALIGN_LEFT);
666  S.Id(EditButtonID).AddButton(XXO("&Edit..."), wxALIGN_LEFT);
667  S.Id(DeleteButtonID).AddButton(XXO("De&lete"), wxALIGN_LEFT);
668  S.Id(UpButtonID).AddButton(XXO("Move &Up"), wxALIGN_LEFT);
669  S.Id(DownButtonID).AddButton(XXO("Move &Down"), wxALIGN_LEFT);
670  mSave = S.Id(SaveButtonID).AddButton(XO("&Save"), wxALIGN_LEFT);
671  mSave->Enable( mChanged );
672  }
673  S.EndVerticalLay();
674  }
675  S.EndHorizontalLay();
676  }
677  S.EndStatic();
678  }
679  S.EndHorizontalLay();
680 
681  S.StartHorizontalLay(wxEXPAND, 0);
682  {
683  /* i18n-hint: The Shrink button makes the dialog smaller, with less in it */
684  mResize = S.Id(ShrinkID).AddButton(XXO("Shrin&k"));
685  // Using variable text just to get the positioning options.
686  S.Prop(0).AddVariableText(
687  XO("Apply Macro to:"), false, wxALL | wxALIGN_CENTRE_VERTICAL );
688  wxButton* btn = S.Id(ApplyToProjectID)
689  .Name(XO("Apply macro to project"))
690  .AddButton(XXO("&Project"));
691 #if wxUSE_ACCESSIBILITY
692  // so that name can be set on a standard control
693  btn->SetAccessible(safenew WindowAccessible(btn));
694 #endif
695 
696  btn = S.Id(ApplyToFilesID)
697  .Name(XO("Apply macro to files..."))
698  .AddButton(XXO("&Files..."));
699 #if wxUSE_ACCESSIBILITY
700  // so that name can be set on a standard control
701  btn->SetAccessible(safenew WindowAccessible(btn));
702 #endif
703  S.AddSpace( 10,10,1 );
704  // Bug 2524 OK button does much the same as cancel, so remove it.
705  // OnCancel prompts you if there has been a change.
706  // OnOK saves without prompting.
707  // That difference is too slight to merit a button, and with the OK
708  // button, people might expect the dialog to apply the macro too.
709  S.AddStandardButtons( /*eOkButton |*/ eCloseButton | eHelpButton);
710  }
711 
712  S.EndHorizontalLay();
713 
714 
715  return;
716 }
717 
720 {
721  int topItem = mList->GetTopItem();
722  mList->DeleteAllItems();
723 
724  for (int i = 0; i < mMacroCommands.GetCount(); i++) {
727  }
728  /*i18n-hint: This is the last item in a list.*/
729  AddItem(_("- END -"), wxT(""));
730 
731  // Select the name in the list...this will fire an event.
732  if (mSelectedCommand >= (int)mList->GetItemCount()) {
733  mSelectedCommand = 0;
734  }
735  mList->SetItemState(mSelectedCommand,
736  wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
737  wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
738  if( 0 <= topItem && topItem < (int)mList->GetItemCount())
739  {
740  // Workaround for scrolling being windows only.
741  // Try to scroll back to where we once were...
742  mList->EnsureVisible( (int)mList->GetItemCount() -1 );
743  mList->EnsureVisible( topItem );
744  // And then make sure whatever is selected is still visible...
745  if (mSelectedCommand >= 0) {
746  mList->EnsureVisible( mSelectedCommand );
747  }
748  }
749 }
750 
752 void MacrosWindow::AddItem(const CommandID &Action, const wxString &Params)
753 {
755  auto friendlyName = entry != mCatalog.end()
756  ? entry->name.StrippedTranslation()
757  :
758  // uh oh, using GET to expose an internal name to the user!
759  // in default of any better friendly name
760  Action.GET();
761 
762  int i = mList->GetItemCount();
763 
764  mList->InsertItem(i, wxString::Format(wxT(" %02i"), i + 1));
765  mList->SetItem(i, ActionColumn, friendlyName );
766  mList->SetItem(i, ParamsColumn, Params );
767 }
768 
770 {
771  // OK even on mac, as dialog is modal.
772  auto p = &mProject;
774 }
775 
776 void MacrosWindow::UpdateDisplay( bool bExpanded )
777 {
778  // If we failed to save changes, we abandon the attempt to
779  // change the expand/shrink state of the GUI.
780  if( !SaveChanges() )
781  return;
782 
783  mbExpanded = bExpanded;
784 
785  mChanged = false;
786  // if we try to access the about to be destroyed mSave button
787  // inappropriately, we need to crash rather than (sometimes) silently
788  // succeed.
789  mSave = nullptr;
790 
791  DestroyChildren();
792  SetSizer( nullptr );
793 
794  mSelectedCommand = 0;
795  SetMinSize( wxSize( 200,200 ));
796 
797  // Get and set position for optical stability.
798  // Expanded and shrunk dialogs 'stay where they were'.
799  // That's OK , and what we want, even if we exapnd off-screen.
800  // We won't shrink to being off-screen, since the shrink button
801  // was clicked, so must have been on screen.
802  wxPoint p = GetPosition( );
803  if( mbExpanded )
804  Populate();
805  else
807  SetPosition( p );
808  mResize->SetFocus();
809 
810  auto Title = WindowTitle();
811  SetLabel( Title ); // Provide visual label
812  SetName( Title ); // Provide audible label
813  SetTitle( Title );
814 }
815 
816 void MacrosWindow::OnExpand(wxCommandEvent &WXUNUSED(event))
817 { UpdateDisplay( true );}
818 
819 void MacrosWindow::OnShrink(wxCommandEvent &WXUNUSED(event))
820 {
821  if( ChangeOK() )
822  UpdateDisplay( false );
823 }
824 
825 
827 {
828  if (mChanged) {
829  int id;
830 
831  auto title = XO("%s changed").Format( mActiveMacro );
832  auto msg = XO("Do you want to save the changes?");
833 
834  id = AudacityMessageBox(
835  msg,
836  title,
837  wxYES_NO | wxCANCEL);
838  if (id == wxCANCEL) {
839  return false;
840  }
841 
842  if (id == wxYES) {
844  return false;
845  }
846  }
847 
848  mChanged = false;
849  mSave->Enable( mChanged );
850  }
851 
852  return true;
853 }
855 void MacrosWindow::OnMacroSelected(wxListEvent & event)
856 {
857  if (!ChangeOK()) {
858  event.Veto();
859  return;
860  }
861 
862  int item = event.GetIndex();
863 
864  mActiveMacro = mMacros->GetItemText(item);
865  ShowActiveMacro();
866 }
867 
869 {
871  if( !mbExpanded )
872  return;
873 
875  mRemove->Disable();
876  mRename->Disable();
877  mRestore->Enable();
878  }
879  else {
880  mRemove->Enable();
881  mRename->Enable();
882  mRestore->Disable();
883  }
884 
885  PopulateList();
886 }
887 
889 void MacrosWindow::OnListSelected(wxListEvent & WXUNUSED(event))
890 {
891  FitColumns();
892 }
893 
895 void MacrosWindow::OnSize(wxSizeEvent & WXUNUSED(event))
896 {
897  // Refresh the layout and re-fit the columns.
898  Layout();
899  if( !mbExpanded )
900  return;
901  FitColumns();
902 }
903 
905 {
906 
907 #if defined(__WXMAC__)
908  // wxMac uses a hard coded width of 150 when wxLIST_AUTOSIZE_USEHEADER
909  // is specified, so we calculate the width ourselves. This method may
910  // work equally well on other platforms.
911  for (size_t c = 0; c < mList->GetColumnCount(); c++) {
912  wxListItem info;
913  int width;
914 
915  mList->SetColumnWidth(c, wxLIST_AUTOSIZE);
916  info.Clear();
917  info.SetId(c);
918  info.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH);
919  mList->GetColumn(c, info);
920 
921  mList->GetTextExtent(info.GetText(), &width, NULL);
922  width += 2 * 4; // 2 * kItemPadding - see listctrl_mac.cpp
923  width += 16; // kIconWidth - see listctrl_mac.cpp
924 
925  mList->SetColumnWidth(c, wxMax(width, mList->GetColumnWidth(c)));
926  }
927 
928  // Looks strange, but it forces the horizontal scrollbar to get
929  // drawn. If not done, strange column sizing can occur if the
930  // user attempts to resize the columns.
931  mList->SetClientSize(mList->GetClientSize());
932 #else
933  mList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
934  mList->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER);
935  mList->SetColumnWidth(2, wxLIST_AUTOSIZE);
936 #endif
937 
938  int bestfit = mList->GetColumnWidth(2);
939  int clientsize = mList->GetClientSize().GetWidth();
940  int col0 = mList->GetColumnWidth(0);
941  int col1 = mList->GetColumnWidth(1);
942  bestfit = (bestfit > clientsize-col0-col1)? bestfit : clientsize-col0-col1;
943  mList->SetColumnWidth(2, bestfit);
944 
945 }
946 
948 void MacrosWindow::OnMacrosBeginEdit(wxListEvent &event)
949 {
950  int itemNo = event.GetIndex();
951 
952  wxString macro = mMacros->GetItemText(itemNo);
953 
954  if (mMacroCommands.IsFixed(macro)) {
955  wxBell();
956  event.Veto();
957  }
958  if( mMacroBeingRenamed.IsEmpty())
959  mMacroBeingRenamed = macro;
960 }
961 
963 void MacrosWindow::OnMacrosEndEdit(wxListEvent &event)
964 {
965  if (event.IsEditCancelled()) {
966  mMacroBeingRenamed = "";
967  return;
968  }
969 
970  if( mMacroBeingRenamed.IsEmpty())
971  return;
972 
973  wxString newname = event.GetLabel();
974 
977  mActiveMacro = newname;
979  PopulateMacros();
980  UpdateMenus();
981  event.Veto();
982 }
983 
985 void MacrosWindow::OnAdd(wxCommandEvent & WXUNUSED(event))
986 {
987  // Similar to Bug 2284 we may need to save a changed macro.
988  if (!ChangeOK()) {
989  return;
990  }
991 
992  while (true) {
994  XO("Enter name of new macro"),
995  XO("Name of new macro"));
996  d.SetName(d.GetTitle());
997  wxString name;
998 
999  if (d.ShowModal() == wxID_CANCEL) {
1000  Raise();
1001  return;
1002  }
1003  Raise();
1004 
1005  name = d.GetValue().Strip(wxString::both);
1006 
1007  if (name.length() == 0) {
1009  XO("Name must not be blank"),
1010  WindowTitle(),
1011  wxOK | wxICON_ERROR,
1012  this);
1013  continue;
1014  }
1015 
1016  if (name.Contains(wxFILE_SEP_PATH) ||
1017  name.Contains(wxFILE_SEP_PATH_UNIX)) {
1019  /*i18n-hint: The %c will be replaced with 'forbidden characters', like '/' and '\'.*/
1020  XO("Names may not contain '%c' and '%c'")
1021  .Format(wxFILE_SEP_PATH, wxFILE_SEP_PATH_UNIX),
1022  WindowTitle(),
1023  wxOK | wxICON_ERROR,
1024  this);
1025  continue;
1026  }
1027 
1029 
1030  mActiveMacro = name;
1031 
1032  PopulateMacros();
1033  UpdateMenus();
1034 
1035  break;
1036  }
1037 }
1038 
1040 void MacrosWindow::OnRemove(wxCommandEvent & WXUNUSED(event))
1041 {
1042  long item = mMacros->GetNextItem(-1,
1043  wxLIST_NEXT_ALL,
1044  wxLIST_STATE_SELECTED);
1045  if (item == -1) {
1046  return;
1047  }
1048 
1049  wxString name = mMacros->GetItemText(item);
1051  this,
1052  /*i18n-hint: %s will be replaced by the name of a file.*/
1053  XO("Are you sure you want to delete %s?").Format( name ),
1054  Verbatim( GetTitle() ),
1055  wxYES_NO | wxICON_QUESTION );
1056  if (m.ShowModal() == wxID_NO) {
1057  Raise();
1058  return;
1059  }
1060  Raise();
1061 
1063 
1064  item++;
1065  if (item >= (mMacros->GetItemCount() - 1) && item >= 0) {
1066  item--;
1067  }
1068 
1069  // Bug 2284. The macro we have just removed might have been
1070  // changed. Since we've just deleted the macro, we should
1071  // forget about that change.
1072  mChanged = false;
1073  mSave->Enable( mChanged );
1074  mActiveMacro = mMacros->GetItemText(item);
1075 
1076  PopulateMacros();
1077  UpdateMenus();
1078 }
1079 
1081 void MacrosWindow::OnRename(wxCommandEvent & WXUNUSED(event))
1082 {
1083  long item = mMacros->GetNextItem(-1,
1084  wxLIST_NEXT_ALL,
1085  wxLIST_STATE_SELECTED);
1086  if (item == -1) {
1087  return;
1088  }
1089 
1090  mMacros->EditLabel(item);
1091  UpdateMenus();
1092 }
1093 
1095 void MacrosWindow::OnRestore(wxCommandEvent & WXUNUSED(event))
1096 {
1098 
1099  mChanged = true;
1100  mSave->Enable( mChanged );
1101 
1102  PopulateList();
1103 }
1104 
1106 void MacrosWindow::OnImport(wxCommandEvent & WXUNUSED(event))
1107 {
1108  if (!ChangeOK()) {
1109  return;
1110  }
1111 
1112  long item = mMacros->GetNextItem(-1,
1113  wxLIST_NEXT_ALL,
1114  wxLIST_STATE_SELECTED);
1115  if (item == -1) {
1116  return;
1117  }
1118 
1119  wxString name = mMacros->GetItemText(item);
1120 
1121  name = mMacroCommands.ReadMacro({}, this);
1122  if (name == wxEmptyString) {
1123  return;
1124  }
1125 
1126  mActiveMacro = name;
1127 
1128  PopulateMacros();
1129  UpdateMenus();
1130 }
1131 
1133 void MacrosWindow::OnExport(wxCommandEvent & WXUNUSED(event))
1134 {
1135  long item = mMacros->GetNextItem(-1,
1136  wxLIST_NEXT_ALL,
1137  wxLIST_STATE_SELECTED);
1138  if (item == -1) {
1139  return;
1140  }
1141 
1142  mMacroCommands.WriteMacro(mMacros->GetItemText(item), this);
1143 }
1144 
1145 void MacrosWindow::OnSave(wxCommandEvent & WXUNUSED(event))
1146 {
1147  SaveChanges();
1148 }
1149 
1150 
1153 void MacrosWindow::OnCommandActivated(wxListEvent & WXUNUSED(event))
1154 {
1155  wxCommandEvent dummy;
1156  OnEditCommandParams( dummy );
1157 }
1158 
1160 void MacrosWindow::OnInsert(wxCommandEvent & WXUNUSED(event))
1161 {
1162  long item = mList->GetNextItem(-1,
1163  wxLIST_NEXT_ALL,
1164  wxLIST_STATE_SELECTED);
1165  if (item == -1) {
1166  item = mList->GetItemCount()-1;
1167  }
1168  InsertCommandAt( item );
1169 }
1170 
1172 {
1173  if (item == -1) {
1174  return;
1175  }
1176 
1177  MacroCommandDialog d(this, wxID_ANY, mProject);
1178 
1179  if (!d.ShowModal()) {
1180  Raise();
1181  return;
1182  }
1183  Raise();
1184 
1185  if(!d.mSelectedCommand.empty())
1186  {
1189  item);
1190  mChanged = true;
1191  mSave->Enable( mChanged );
1192 
1193  mSelectedCommand = item + 1;
1194  PopulateList();
1195  }
1196 
1197 }
1198 
1199 void MacrosWindow::OnEditCommandParams(wxCommandEvent & WXUNUSED(event))
1200 {
1201  int item = mList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
1202 
1203  // LAST command in list is END.
1204  // If nothing selected, add at END.
1205  // If END selected, add at END.
1206  // When adding at end we use InsertCommandAt, so that a new command
1207  // can be chosen.
1208  int lastItem = mList->GetItemCount()-1;
1209  if( (item<0) || (item+1) == mList->GetItemCount() )
1210  {
1211  InsertCommandAt( lastItem );
1212  return;
1213  }
1214 
1215  // Just edit the parameters, and not the command.
1216  auto command = mMacroCommands.GetCommand(item);
1217  wxString params = mMacroCommands.GetParams(item);
1218  wxString oldParams = params;
1219 
1220  params = MacroCommands::PromptForParamsFor(command, params, *this).Trim();
1221  Raise();
1222 
1223  if (oldParams == params)
1224  return; // They did not actually make any changes..
1225 
1227  mMacroCommands.AddToMacro(command,
1228  params,
1229  item);
1230 
1231  mChanged = true;
1232  mSave->Enable( mChanged );
1233 
1234  mSelectedCommand = item;
1235  PopulateList();
1236 }
1237 
1239 void MacrosWindow::OnDelete(wxCommandEvent & WXUNUSED(event))
1240 {
1241  long item = mList->GetNextItem(-1,
1242  wxLIST_NEXT_ALL,
1243  wxLIST_STATE_SELECTED);
1244  if (item == -1 || item + 1 == mList->GetItemCount()) {
1245  return;
1246  }
1247 
1249 
1250  mChanged = true;
1251  mSave->Enable( mChanged );
1252 
1253  if (item >= (mList->GetItemCount() - 2) && item >= 0) {
1254  item--;
1255  }
1256  mSelectedCommand = item;
1257  PopulateList();
1258 }
1259 
1261 void MacrosWindow::OnUp(wxCommandEvent & WXUNUSED(event))
1262 {
1263  long item = mList->GetNextItem(-1,
1264  wxLIST_NEXT_ALL,
1265  wxLIST_STATE_SELECTED);
1266  if (item == -1 || item == 0 || item + 1 == mList->GetItemCount()) {
1267  return;
1268  }
1269 
1271  mMacroCommands.GetParams(item),
1272  item - 1);
1273  mMacroCommands.DeleteFromMacro(item + 1);
1274 
1275  mChanged = true;
1276  mSave->Enable( mChanged );
1277 
1278  mSelectedCommand = item - 1;
1279  PopulateList();
1280 }
1281 
1283 void MacrosWindow::OnDown(wxCommandEvent & WXUNUSED(event))
1284 {
1285  long item = mList->GetNextItem(-1,
1286  wxLIST_NEXT_ALL,
1287  wxLIST_STATE_SELECTED);
1288  if (item == -1 || item + 2 >= mList->GetItemCount()) {
1289  return;
1290  }
1291 
1293  mMacroCommands.GetParams(item),
1294  item + 2);
1296 
1297  mChanged = true;
1298  mSave->Enable( mChanged );
1299 
1300  mSelectedCommand = item + 1;
1301  PopulateList();
1302 }
1303 
1304 void MacrosWindow::OnApplyToProject(wxCommandEvent & event)
1305 {
1306  if( !SaveChanges() )
1307  return;
1309 }
1310 
1311 void MacrosWindow::OnApplyToFiles(wxCommandEvent & event)
1312 {
1313  if( !SaveChanges() )
1314  return;
1316 }
1317 
1319  gPrefs->Write(wxT("/Batch/ActiveMacro"), mActiveMacro);
1320  gPrefs->Flush();
1321 
1322  if (mChanged) {
1324  return false;
1325  }
1326  }
1327 
1328  mChanged = false;
1329  if( mSave )
1330  mSave->Enable( mChanged );
1331 
1332  return true;
1333 }
1334 
1336 void MacrosWindow::OnOK(wxCommandEvent & WXUNUSED(event))
1337 {
1338  if( !SaveChanges() )
1339  return;
1340  Hide();
1341  //EndModal(true);
1342 }
1343 
1345 void MacrosWindow::OnCancel(wxCommandEvent &WXUNUSED(event))
1346 {
1347  bool bWasChanged = mChanged;
1348  if (!ChangeOK()) {
1349  return;
1350  }
1351  // If we've rejected a change, we need to restore the display
1352  // of the active macro.
1353  // That's because next time we open this dialog we want to see the
1354  // unedited macro.
1355  if( bWasChanged )
1356  ShowActiveMacro();
1357  Hide();
1358 }
1359 
1361 void MacrosWindow::OnKeyDown(wxKeyEvent &event)
1362 {
1363  if (event.GetKeyCode() == WXK_DELETE) {
1364  wxLogDebug(wxT("wxKeyEvent"));
1365  }
1366 
1367  event.Skip();
1368 }
1369 
1371 {
1373 }
1374 
1375 // PrefsListener implementation
1377 {
1379 }
ProjectFileManager::OpenProject
bool OpenProject()
Definition: ProjectFileManager.cpp:764
MacrosWindow::mSelectedCommand
int mSelectedCommand
Definition: BatchProcessDialog.h:143
EVT_BUTTON
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
MacrosWindow::UpdateMenus
void UpdateMenus()
Definition: BatchProcessDialog.cpp:769
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
MacrosWindow::FitColumns
void FitColumns()
Definition: BatchProcessDialog.cpp:904
MacrosWindow::OnListSelected
void OnListSelected(wxListEvent &event)
An item in the macros list has been selected.
Definition: BatchProcessDialog.cpp:889
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:38
MacroCommands::RestoreMacro
void RestoreMacro(const wxString &name)
Definition: BatchCommands.cpp:84
ApplyMacroDialog::~ApplyMacroDialog
virtual ~ApplyMacroDialog()
Definition: BatchProcessDialog.cpp:110
ApplyMacroDialog::OnApplyToProject
virtual void OnApplyToProject(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:230
TranslatableString::empty
bool empty() const
Definition: TranslatableString.h:72
EditButtonID
@ EditButtonID
Definition: BatchProcessDialog.cpp:512
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1184
MacrosPaletteTitle
#define MacrosPaletteTitle
Definition: BatchProcessDialog.cpp:70
MacrosWindow::OnOK
void OnOK(wxCommandEvent &event)
Send changed values back to Prefs, and update Audacity.
Definition: BatchProcessDialog.cpp:1336
ApplyToProjectID
#define ApplyToProjectID
Definition: BatchProcessDialog.cpp:78
ExpandID
#define ExpandID
Definition: BatchProcessDialog.cpp:80
MacrosWindow::mSave
wxButton * mSave
Definition: BatchProcessDialog.h:141
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
FileNames::FindDefaultPath
FILES_API FilePath FindDefaultPath(Operation op)
HelpSystem.h
Effect.h
MacrosWindow::ChangeOK
bool ChangeOK()
Definition: BatchProcessDialog.cpp:826
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
AllThemeResources.h
MacrosWindow::OnCommandActivated
void OnCommandActivated(wxListEvent &event)
Definition: BatchProcessDialog.cpp:1153
eHelpButton
@ eHelpButton
Definition: ShuttleGui.h:604
Project.h
Import.h
Importer::Get
static Importer & Get()
Definition: Import.cpp:71
ApplyMacroDialog::mAbort
bool mAbort
Definition: BatchProcessDialog.h:60
MacrosWindow::OnMacrosBeginEdit
void OnMacrosBeginEdit(wxListEvent &event)
Definition: BatchProcessDialog.cpp:948
EVT_LIST_ITEM_SELECTED
EVT_LIST_ITEM_SELECTED(CurvesListID, EditCurvesDialog::OnListSelectionChange) EVT_LIST_ITEM_DESELECTED(CurvesListID
Constructor.
MacroCommandsCatalog::end
Entries::const_iterator end() const
Definition: BatchCommands.h:48
Clipboard.h
AudacityTextEntryDialog
Wrap wxTextEntryDialog so that caption IS translatable.
Definition: AudacityTextEntryDialog.h:23
Format
Abstract base class used in importing a file.
ApplyMacroDialog::OnApplyToFiles
virtual void OnApplyToFiles(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:329
entry
static ProjectFileIORegistry::WriterEntry entry
Definition: ProjectSettings.cpp:197
MacrosWindow::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S)
Defines the dialog and does data exchange with it.
Definition: BatchProcessDialog.cpp:621
DownButtonID
@ DownButtonID
Definition: BatchProcessDialog.cpp:515
MacroCommands::ReadMacro
wxString ReadMacro(const wxString &macro, wxWindow *parent=nullptr)
Definition: BatchCommands.cpp:124
CommandManager.h
ApplyMacroDialog::mProject
AudacityProject & mProject
Definition: BatchProcessDialog.h:66
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2459
MacrosWindow::OnDown
void OnDown(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:1283
MacrosListID
#define MacrosListID
Definition: BatchProcessDialog.cpp:76
MacroCommands::ApplyMacro
bool ApplyMacro(const MacroCommandsCatalog &catalog, const wxString &filename={})
Definition: BatchCommands.cpp:688
MacrosWindow::OnImport
void OnImport(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:1106
MacrosWindow::OnCancel
void OnCancel(wxCommandEvent &event) override
Definition: BatchProcessDialog.cpp:1345
MacrosWindow::mRemove
wxButton * mRemove
Definition: BatchProcessDialog.h:136
XO
#define XO(s)
Definition: Internat.h:31
MacroCommandsCatalog::ByCommandId
Entries::const_iterator ByCommandId(const CommandID &commandId) const
Definition: BatchCommands.cpp:426
MacrosWindow::OnSize
void OnSize(wxSizeEvent &event)
The window has been resized.
Definition: BatchProcessDialog.cpp:895
MacroCommands::RenameMacro
bool RenameMacro(const wxString &oldmacro, const wxString &newmacro)
Definition: BatchCommands.cpp:292
CommandsListID
#define CommandsListID
Definition: BatchProcessDialog.cpp:77
BatchCommandDialog.h
ApplyMacroDialog::mActiveMacro
wxString mActiveMacro
Definition: BatchProcessDialog.h:62
ProjectWindow::Get
static ProjectWindow & Get(AudacityProject &project)
Definition: ProjectWindow.cpp:535
wxDialogWrapper::SetLabel
void SetLabel(const TranslatableString &title)
Definition: wxPanelWrapper.cpp:71
MacrosWindow::mChanged
bool mChanged
Definition: BatchProcessDialog.h:144
BasicUI::Action
std::function< void()> Action
Definition: BasicUI.h:24
MacrosWindow::UpdatePrefs
void UpdatePrefs() override
Definition: BatchProcessDialog.cpp:1376
MacrosWindow::OnExport
void OnExport(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:1133
MacroCommands::AddToMacro
void AddToMacro(const CommandID &command, int before=-1)
Definition: BatchCommands.cpp:820
ExportButtonID
@ ExportButtonID
Definition: BatchProcessDialog.cpp:506
ProjectManager::ResetProjectToEmpty
void ResetProjectToEmpty()
Definition: ProjectManager.cpp:972
HelpSystem::ShowHelp
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:237
AudacityMessageDialog
Wrap wxMessageDialog so that caption IS translatable.
Definition: wxPanelWrapper.h:215
MacrosWindow::PopulateList
void PopulateList()
This clears and updates the contents of mList, the commands for the current macro.
Definition: BatchProcessDialog.cpp:719
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
ApplyToProjectButtonID
@ ApplyToProjectButtonID
Definition: BatchProcessDialog.cpp:520
MacrosWindow::OnShrink
void OnShrink(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:819
ApplyToFilesButtonID
@ ApplyToFilesButtonID
Definition: BatchProcessDialog.cpp:521
ApplyMacroDialog::mbExpanded
bool mbExpanded
Definition: BatchProcessDialog.h:61
AudacityTextEntryDialog.h
MacrosWindow::OnMacrosEndEdit
void OnMacrosEndEdit(wxListEvent &event)
Definition: BatchProcessDialog.cpp:963
ShuttleGui::Style
ShuttleGui & Style(long iStyle)
Definition: ShuttleGui.h:727
MacroCommands::GetCount
int GetCount()
Definition: BatchCommands.cpp:119
ApplyMacroDialog::ApplyMacroToProject
void ApplyMacroToProject(int iMacro, bool bHasGui=true)
Definition: BatchProcessDialog.cpp:265
ProjectManager::Get
static ProjectManager & Get(AudacityProject &project)
Definition: ProjectManager.cpp:70
AddButtonID
@ AddButtonID
Definition: BatchProcessDialog.cpp:501
MacrosWindow::mRestore
wxButton * mRestore
Definition: BatchProcessDialog.h:138
ApplyToFilesID
#define ApplyToFilesID
Definition: BatchProcessDialog.cpp:79
XXO
#define XXO(s)
Definition: Internat.h:44
ApplyMacroDialog::OnHelp
virtual void OnHelp(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:224
ApplyMacroDialog
Shows progress in executing commands in MacroCommands.
Definition: BatchProcessDialog.h:29
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1177
ApplyMacroDialog::PopulateMacros
void PopulateMacros()
Definition: BatchProcessDialog.cpp:190
MacrosWindow::InsertCommandAt
void InsertCommandAt(int item)
Definition: BatchProcessDialog.cpp:1171
MacrosWindow::MacrosWindow
MacrosWindow(wxWindow *parent, AudacityProject &project, bool bExpanded=true)
Constructor.
Definition: BatchProcessDialog.cpp:562
ShrinkID
#define ShrinkID
Definition: BatchProcessDialog.cpp:81
MacroCommandDialog::mSelectedCommand
CommandID mSelectedCommand
Definition: BatchCommandDialog.h:33
ApplyMacroDialog::mMacroCommands
MacroCommands mMacroCommands
Definition: BatchProcessDialog.h:54
ProjectFileManager::Get
static ProjectFileManager & Get(AudacityProject &project)
Definition: ProjectFileManager.cpp:66
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1167
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1203
ImportButtonID
@ ImportButtonID
Definition: BatchProcessDialog.cpp:505
ApplyMacroDialog::OnCancel
virtual void OnCancel(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:491
MacroCommands::GetCommand
CommandID GetCommand(int index)
Definition: BatchCommands.cpp:101
InsertButtonID
@ InsertButtonID
Definition: BatchProcessDialog.cpp:511
FileDialog::SetFilterIndex
virtual void SetFilterIndex(int filterIndex)
Definition: gtk/FileDialogPrivate.cpp:599
ShuttleGuiBase::AddFixedText
void AddFixedText(const TranslatableString &Str, bool bCenter=false, int wrapWidth=0)
Definition: ShuttleGui.cpp:440
RenameButtonID
@ RenameButtonID
Definition: BatchProcessDialog.cpp:503
FileDialog.h
name
const TranslatableString name
Definition: Distortion.cpp:98
MenuCreator::RebuildMenuBar
void RebuildMenuBar(AudacityProject &project)
Definition: Menus.cpp:486
RemoveButtonID
@ RemoveButtonID
Definition: BatchProcessDialog.cpp:502
MacrosWindow
Definition: BatchProcessDialog.h:74
MacrosWindow::mProject
AudacityProject & mProject
Definition: BatchProcessDialog.h:134
MacroCommands::DeleteFromMacro
void DeleteFromMacro(int index)
Definition: BatchCommands.cpp:835
UndoManager.h
ProjectFileManager.h
MacrosWindow::OnExpand
void OnExpand(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:816
WindowAccessible
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
MacroCommandDialog::mSelectedParameters
wxString mSelectedParameters
Definition: BatchCommandDialog.h:34
ApplyMacroDialog::Populate
void Populate()
Definition: BatchProcessDialog.cpp:114
MacrosWindow::OnRemove
void OnRemove(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:1040
MacrosWindow::mRename
wxButton * mRename
Definition: BatchProcessDialog.h:137
wxDialogWrapper::SetName
void SetName(const TranslatableString &title)
Definition: wxPanelWrapper.cpp:76
MacroCommands::GetParams
wxString GetParams(int index)
Definition: BatchCommands.cpp:110
MacrosWindow::ShowActiveMacro
void ShowActiveMacro()
Definition: BatchProcessDialog.cpp:868
ShuttleGui.h
Importer::SelectDefaultOpenType
static size_t SelectDefaultOpenType(const FileNames::FileTypes &fileTypes)
Definition: Import.cpp:244
MacroCommands::GetNames
static wxArrayString GetNames()
Definition: BatchCommands.cpp:911
MacrosWindow::OnApplyToProject
void OnApplyToProject(wxCommandEvent &event) override
Definition: BatchProcessDialog.cpp:1304
ProjectManager.h
MacroCommands::DeleteMacro
bool DeleteMacro(const wxString &name)
Definition: BatchCommands.cpp:277
ApplyMacroDialog::mMacros
wxListCtrl * mMacros
Definition: BatchProcessDialog.h:53
DeleteButtonID
@ DeleteButtonID
Definition: BatchProcessDialog.cpp:513
ShuttleGui::Prop
ShuttleGui & Prop(int iProp)
Definition: ShuttleGui.h:725
Menus.h
MacrosWindow::mExport
wxButton * mExport
Definition: BatchProcessDialog.h:140
ApplyMacroDialog::mMacroBeingRenamed
wxString mMacroBeingRenamed
Definition: BatchProcessDialog.h:63
ProjectFileManager::CloseProject
void CloseProject()
Definition: ProjectFileManager.cpp:788
ApplyMacroDialog::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S)
Defines the dialog and does data exchange with it.
Definition: BatchProcessDialog.cpp:142
MacroCommands::WriteMacro
wxString WriteMacro(const wxString &macro, wxWindow *parent=nullptr)
Definition: BatchCommands.cpp:206
SaveButtonID
@ SaveButtonID
Definition: BatchProcessDialog.cpp:507
ShuttleGuiBase::AddButton
wxButton * AddButton(const TranslatableString &Text, int PositionFlags=wxALIGN_CENTRE, bool setDefault=false)
Definition: ShuttleGui.cpp:360
Importer::GetFileTypes
FileNames::FileTypes GetFileTypes(const FileNames::FileType &extraType={})
Definition: Import.cpp:179
MacroCommands::AddMacro
bool AddMacro(const wxString &macro)
Definition: BatchCommands.cpp:265
MacrosWindow::OnUp
void OnUp(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:1261
MacrosWindow::OnRestore
void OnRestore(wxCommandEvent &event)
Reset a built in macro.
Definition: BatchProcessDialog.cpp:1095
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
id
int id
Definition: WaveTrackControls.cpp:577
MacrosWindow::AddItem
void AddItem(const CommandID &command, wxString const &params)
Add one item into mList.
Definition: BatchProcessDialog.cpp:752
ParamsColumn
@ ParamsColumn
Definition: BatchProcessDialog.cpp:558
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:663
wxDialogWrapper
Definition: wxPanelWrapper.h:81
Clipboard::Get
static Clipboard & Get()
Definition: Clipboard.cpp:29
Clipboard
Definition: Clipboard.h:28
WindowAccessible.h
ApplyMacroDialog::mCatalog
const MacroCommandsCatalog mCatalog
Definition: BatchProcessDialog.h:67
title
static const auto title
Definition: NoUpdatesAvailableDialog.cpp:22
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
ItemNumberColumn
@ ItemNumberColumn
Definition: BatchProcessDialog.cpp:556
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
ProjectWindow::ZoomAfterImport
void ZoomAfterImport(Track *pTrack)
Definition: ProjectWindow.cpp:1551
FileDialogWrapper
Definition: wxPanelWrapper.h:165
TaggedIdentifier< CommandIdTag, false >
names
static TranslatableStrings names
Definition: Tags.cpp:744
MacroCommands::PromptForParamsFor
static wxString PromptForParamsFor(const CommandID &command, const wxString &params, wxWindow &parent)
Definition: BatchCommands.cpp:447
_
#define _(s)
Definition: Internat.h:75
ShuttleGuiBase::AddListControlReportMode
wxListCtrl * AddListControlReportMode(std::initializer_list< const ListControlColumn > columns={}, long listControlStyles=0)
Definition: ShuttleGui.cpp:802
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
eCloseButton
@ eCloseButton
Definition: ShuttleGui.h:610
FileNames.h
AudacityMessageBox.h
MenuManager::Get
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:70
ProjectHistory.h
Verbatim
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Definition: TranslatableString.h:321
MacrosWindow::OnAdd
void OnAdd(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:985
MacrosWindow::Populate
void Populate()
Creates the dialog and its contents.
Definition: BatchProcessDialog.cpp:587
MacrosWindow::OnDelete
void OnDelete(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:1239
ProjectFileManager::Import
bool Import(const FilePath &fileName, bool addToHistory=true)
Definition: ProjectFileManager.cpp:1207
RestoreButtonID
@ RestoreButtonID
Definition: BatchProcessDialog.cpp:504
EVT_LIST_ITEM_ACTIVATED
EVT_LIST_ITEM_ACTIVATED(wxID_ANY, SuccessDialog::OnItemActivated) ExportMultipleDialog
Definition: ExportMultiple.cpp:123
wxDialogWrapper::SetTitle
void SetTitle(const TranslatableString &title)
Definition: wxPanelWrapper.cpp:66
MacrosWindow::SaveChanges
bool SaveChanges()
Definition: BatchProcessDialog.cpp:1318
MacrosWindow::OnMacroSelected
void OnMacroSelected(wxListEvent &event)
An item in the macros list has been selected.
Definition: BatchProcessDialog.cpp:855
MacrosWindow::OnKeyDown
void OnKeyDown(wxKeyEvent &event)
Definition: BatchProcessDialog.cpp:1361
ShuttleGui::AddStandardButtons
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxWindow *extra=NULL)
Definition: ShuttleGui.cpp:2444
SelectUtilities::DoSelectAll
void DoSelectAll(AudacityProject &project)
Definition: SelectUtilities.cpp:139
MacrosWindow::~MacrosWindow
~MacrosWindow()
Definition: BatchProcessDialog.cpp:582
ApplyMacroDialog::mResize
wxButton * mResize
Provides list of available commands.
Definition: BatchProcessDialog.h:56
ActionColumn
@ ActionColumn
Definition: BatchProcessDialog.cpp:557
Prefs.h
params
EffectDistortion::Params params
Definition: Distortion.cpp:99
ShuttleGuiBase::AddPrompt
void AddPrompt(const TranslatableString &Prompt, int wrapWidth=0)
Right aligned text string.
Definition: ShuttleGui.cpp:238
ProjectWindow.h
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
wxDialogWrapper::SetName
void SetName()
Definition: wxPanelWrapper.cpp:81
MacrosWindow::OnSave
void OnSave(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:1145
ShuttleGuiBase::AddVariableText
wxStaticText * AddVariableText(const TranslatableString &Str, bool bCenter=false, int PositionFlags=0, int wrapWidth=0)
Definition: ShuttleGui.cpp:463
ApplyMacroDialog::GetHelpPageName
virtual ManualPageID GetHelpPageName()
Definition: BatchProcessDialog.h:44
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
ApplyMacroDialog::mList
wxListCtrl * mList
Definition: BatchProcessDialog.h:52
safenew
#define safenew
Definition: MemoryX.h:10
MacrosWindow::mImport
wxButton * mImport
Definition: BatchProcessDialog.h:139
MacrosWindow::UpdateDisplay
void UpdateDisplay(bool bExpanded)
Definition: BatchProcessDialog.cpp:776
BatchProcessDialog.h
DefaultsButtonID
@ DefaultsButtonID
Definition: BatchProcessDialog.cpp:509
FileDialog::ShowModal
virtual int ShowModal()
Definition: gtk/FileDialogPrivate.cpp:445
MacrosWindow::OnInsert
void OnInsert(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:1160
SelectUtilities.h
MacrosWindow::OnRename
void OnRename(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:1081
END_EVENT_TABLE
END_EVENT_TABLE()
MacrosWindow::OnEditCommandParams
void OnEditCommandParams(wxCommandEvent &event)
Definition: BatchProcessDialog.cpp:1199
TrackList::empty
bool empty() const
Definition: Track.cpp:995
Identifier::empty
bool empty() const
Definition: Identifier.h:61
MacrosWindow::WindowTitle
TranslatableString WindowTitle() const
Definition: BatchProcessDialog.cpp:1370
FileDialog::GetPaths
virtual void GetPaths(wxArrayString &paths) const
Definition: gtk/FileDialogPrivate.cpp:524
MacrosWindow::OnApplyToFiles
void OnApplyToFiles(wxCommandEvent &event) override
Definition: BatchProcessDialog.cpp:1311
MacroCommandDialog
Provides a list of configurable commands for use with MacroCommands.
Definition: BatchCommandDialog.h:27
ApplyMacroDialog::MacroIdOfName
static CommandID MacroIdOfName(const wxString &MacroName)
Definition: BatchProcessDialog.cpp:243
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
ManageMacrosTitle
#define ManageMacrosTitle
Definition: BatchProcessDialog.cpp:71
MacroCommands::IsFixed
bool IsFixed(const wxString &name)
Definition: BatchCommands.cpp:931
UpButtonID
@ UpButtonID
Definition: BatchProcessDialog.cpp:514