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