Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MacrosWindow Class Referencefinal

#include <BatchProcessDialog.h>

Inheritance diagram for MacrosWindow:
[legend]
Collaboration diagram for MacrosWindow:
[legend]

Public Member Functions

 MacrosWindow (wxWindow *parent, AudacityProject &project, bool bExpanded=true)
 Constructor. More...
 
 ~MacrosWindow ()
 
void UpdateDisplay (bool bExpanded)
 
- Public Member Functions inherited from ApplyMacroDialog
 ApplyMacroDialog (wxWindow *parent, AudacityProject &project, bool bInherited=false)
 
virtual ~ApplyMacroDialog ()
 
void Populate ()
 
void PopulateOrExchange (ShuttleGui &S)
 Defines the dialog and does data exchange with it. More...
 
virtual void OnApplyToProject (wxCommandEvent &event)
 
virtual void OnApplyToFiles (wxCommandEvent &event)
 
virtual void OnCancel (wxCommandEvent &event)
 
virtual void OnHelp (wxCommandEvent &event)
 
virtual ManualPageID GetHelpPageName ()
 
void PopulateMacros ()
 
void ApplyMacroToProject (int iMacro, bool bHasGui=true)
 
void ApplyMacroToProject (const CommandID &MacroID, bool bHasGui=true)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 
- Public Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 

Private Member Functions

TranslatableString WindowTitle () const
 
void Populate ()
 Creates the dialog and its contents. More...
 
void PopulateOrExchange (ShuttleGui &S)
 Defines the dialog and does data exchange with it. More...
 
void OnApplyToProject (wxCommandEvent &event) override
 
void OnApplyToFiles (wxCommandEvent &event) override
 
void OnCancel (wxCommandEvent &event) override
 
virtual ManualPageID GetHelpPageName () override
 
void PopulateList ()
 This clears and updates the contents of mList, the commands for the current macro. More...
 
void AddItem (const CommandID &command, wxString const &params)
 Add one item into mList. More...
 
bool ChangeOK ()
 
void UpdateMenus ()
 
void ShowActiveMacro ()
 
void OnMacroSelected (wxListEvent &event)
 An item in the macros list has been selected. More...
 
void OnListSelected (wxListEvent &event)
 An item in the macros list has been selected. More...
 
void OnMacrosBeginEdit (wxListEvent &event)
 
void OnMacrosEndEdit (wxListEvent &event)
 
void OnAdd (wxCommandEvent &event)
 
void OnRemove (wxCommandEvent &event)
 
void OnRename (wxCommandEvent &event)
 
void OnRestore (wxCommandEvent &event)
 Reset a built in macro. More...
 
void OnImport (wxCommandEvent &event)
 
void OnExport (wxCommandEvent &event)
 
void OnSave (wxCommandEvent &event)
 
void OnExpand (wxCommandEvent &event)
 
void OnShrink (wxCommandEvent &event)
 
void OnSize (wxSizeEvent &event)
 The window has been resized. More...
 
void OnCommandActivated (wxListEvent &event)
 
void OnInsert (wxCommandEvent &event)
 
void OnEditCommandParams (wxCommandEvent &event)
 
void OnDelete (wxCommandEvent &event)
 
void OnUp (wxCommandEvent &event)
 
void OnDown (wxCommandEvent &event)
 
void OnOK (wxCommandEvent &event)
 Send changed values back to Prefs, and update Audacity. More...
 
void OnKeyDown (wxKeyEvent &event)
 
void FitColumns ()
 
void InsertCommandAt (int item)
 
bool SaveChanges ()
 
void UpdatePrefs () override
 

Private Attributes

AudacityProjectmProject
 
wxButton * mRemove
 
wxButton * mRename
 
wxButton * mRestore
 
wxButton * mImport
 
wxButton * mExport
 
wxButton * mSave
 
int mSelectedCommand
 
bool mChanged
 

Additional Inherited Members

- Static Public Member Functions inherited from ApplyMacroDialog
static CommandID MacroIdOfName (const wxString &MacroName)
 
- Static Public Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Public Attributes inherited from ApplyMacroDialog
wxListCtrl * mList
 
wxListCtrl * mMacros
 
MacroCommands mMacroCommands
 
wxButton * mResize
 Provides list of available commands. More...
 
wxButton * mOK
 
wxButton * mCancel
 
wxTextCtrl * mResults
 
bool mAbort
 
bool mbExpanded
 
wxString mActiveMacro
 
wxString mMacroBeingRenamed
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
- Protected Attributes inherited from ApplyMacroDialog
AudacityProjectmProject
 
const MacroCommandsCatalog mCatalog
 

Detailed Description

Definition at line 72 of file BatchProcessDialog.h.

Constructor & Destructor Documentation

◆ MacrosWindow()

MacrosWindow::MacrosWindow ( wxWindow *  parent,
AudacityProject project,
bool  bExpanded = true 
)

Constructor.

Definition at line 570 of file BatchProcessDialog.cpp.

571 :
572 ApplyMacroDialog(parent, project, true)
573 , mProject{ project }
574{
575 mbExpanded = bExpanded;
576 auto Title = WindowTitle();
577 SetLabel( Title ); // Provide visual label
578 SetName( Title ); // Provide audible label
579 SetTitle( Title );
580
581 mChanged = false;
583
584 if( mbExpanded )
585 Populate();
586 else
588}
ApplyMacroDialog(wxWindow *parent, AudacityProject &project, bool bInherited=false)
TranslatableString WindowTitle() const
AudacityProject & mProject
void Populate()
Creates the dialog and its contents.
void SetTitle(const TranslatableString &title)
void SetLabel(const TranslatableString &title)

References ApplyMacroDialog::mbExpanded, mChanged, mSelectedCommand, ApplyMacroDialog::Populate(), Populate(), wxDialogWrapper::SetLabel(), wxDialogWrapper::SetName(), wxDialogWrapper::SetTitle(), and WindowTitle().

Here is the call graph for this function:

◆ ~MacrosWindow()

MacrosWindow::~MacrosWindow ( )

Definition at line 590 of file BatchProcessDialog.cpp.

591{
592}

Member Function Documentation

◆ AddItem()

void MacrosWindow::AddItem ( const CommandID command,
wxString const &  params 
)
private

Add one item into mList.

Definition at line 760 of file BatchProcessDialog.cpp.

761{
763 auto friendlyName = entry != mCatalog.end()
764 ? entry->name.StrippedTranslation()
765 :
766 // uh oh, using GET to expose an internal name to the user!
767 // in default of any better friendly name
768 Action.GET();
769
770 int i = mList->GetItemCount();
771
772 mList->InsertItem(i, wxString::Format(wxT(" %02i"), i + 1));
773 mList->SetItem(i, ActionColumn, friendlyName );
774 mList->SetItem(i, ParamsColumn, Params );
775}
@ ActionColumn
@ ParamsColumn
static ProjectFileIORegistry::AttributeWriterEntry entry
const MacroCommandsCatalog mCatalog
Entries::const_iterator ByCommandId(const CommandID &commandId) const
Entries::const_iterator end() const
Definition: BatchCommands.h:48
std::function< void()> Action
Definition: BasicUI.h:24

References ActionColumn, MacroCommandsCatalog::ByCommandId(), MacroCommandsCatalog::end(), entry, ApplyMacroDialog::mCatalog, ApplyMacroDialog::mList, and ParamsColumn.

Referenced by PopulateList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ChangeOK()

bool MacrosWindow::ChangeOK ( )
private

Definition at line 834 of file BatchProcessDialog.cpp.

835{
836 if (mChanged) {
837 int id;
838
839 auto title = XO("%s changed").Format( mActiveMacro );
840 auto msg = XO("Do you want to save the changes?");
841
843 msg,
844 title,
845 wxYES_NO | wxCANCEL);
846 if (id == wxCANCEL) {
847 return false;
848 }
849
850 if (id == wxYES) {
852 return false;
853 }
854 }
855
856 mChanged = false;
857 mSave->Enable( mChanged );
858 }
859
860 return true;
861}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
#define XO(s)
Definition: Internat.h:31
static const auto title
int id
MacroCommands mMacroCommands
wxString WriteMacro(const wxString &macro, wxWindow *parent=nullptr)

References AudacityMessageBox(), id, ApplyMacroDialog::mActiveMacro, mChanged, ApplyMacroDialog::mMacroCommands, mSave, title, MacroCommands::WriteMacro(), and XO.

Referenced by OnAdd(), OnCancel(), OnImport(), OnMacroSelected(), and OnShrink().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FitColumns()

void MacrosWindow::FitColumns ( )
private

Definition at line 912 of file BatchProcessDialog.cpp.

913{
914
915#if defined(__WXMAC__)
916 // wxMac uses a hard coded width of 150 when wxLIST_AUTOSIZE_USEHEADER
917 // is specified, so we calculate the width ourselves. This method may
918 // work equally well on other platforms.
919 for (size_t c = 0; c < mList->GetColumnCount(); c++) {
920 wxListItem info;
921 int width;
922
923 mList->SetColumnWidth(c, wxLIST_AUTOSIZE);
924 info.Clear();
925 info.SetId(c);
926 info.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH);
927 mList->GetColumn(c, info);
928
929 mList->GetTextExtent(info.GetText(), &width, NULL);
930 width += 2 * 4; // 2 * kItemPadding - see listctrl_mac.cpp
931 width += 16; // kIconWidth - see listctrl_mac.cpp
932
933 mList->SetColumnWidth(c, wxMax(width, mList->GetColumnWidth(c)));
934 }
935
936 // Looks strange, but it forces the horizontal scrollbar to get
937 // drawn. If not done, strange column sizing can occur if the
938 // user attempts to resize the columns.
939 mList->SetClientSize(mList->GetClientSize());
940#else
941 mList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
942 mList->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER);
943 mList->SetColumnWidth(2, wxLIST_AUTOSIZE);
944#endif
945
946 int bestfit = mList->GetColumnWidth(2);
947 int clientsize = mList->GetClientSize().GetWidth();
948 int col0 = mList->GetColumnWidth(0);
949 int col1 = mList->GetColumnWidth(1);
950 bestfit = (bestfit > clientsize-col0-col1)? bestfit : clientsize-col0-col1;
951 mList->SetColumnWidth(2, bestfit);
952
953}

References ApplyMacroDialog::mList.

Referenced by OnListSelected(), OnSize(), and Populate().

Here is the caller graph for this function:

◆ GetHelpPageName()

virtual ManualPageID MacrosWindow::GetHelpPageName ( )
inlineoverrideprivatevirtual

Reimplemented from ApplyMacroDialog.

Definition at line 90 of file BatchProcessDialog.h.

90 {return
91 mbExpanded ? "Manage_Macros"
92 : "Apply_Macro";}

References ApplyMacroDialog::mbExpanded.

◆ InsertCommandAt()

void MacrosWindow::InsertCommandAt ( int  item)
private

Definition at line 1179 of file BatchProcessDialog.cpp.

1180{
1181 if (item == -1) {
1182 return;
1183 }
1184
1185 MacroCommandDialog d(this, wxID_ANY, mProject);
1186
1187 if (!d.ShowModal()) {
1188 Raise();
1189 return;
1190 }
1191 Raise();
1192
1193 if(!d.mSelectedCommand.empty())
1194 {
1195 mMacroCommands.AddToMacro(d.mSelectedCommand,
1196 d.mSelectedParameters,
1197 item);
1198 mChanged = true;
1199 mSave->Enable( mChanged );
1200
1201 mSelectedCommand = item + 1;
1202 PopulateList();
1203 }
1204
1205}
Provides a list of configurable commands for use with MacroCommands.
void AddToMacro(const CommandID &command, int before=-1)
void PopulateList()
This clears and updates the contents of mList, the commands for the current macro.

References MacroCommands::AddToMacro(), Identifier::empty(), mChanged, ApplyMacroDialog::mMacroCommands, mProject, mSave, MacroCommandDialog::mSelectedCommand, mSelectedCommand, MacroCommandDialog::mSelectedParameters, and PopulateList().

Referenced by OnEditCommandParams(), and OnInsert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnAdd()

void MacrosWindow::OnAdd ( wxCommandEvent &  event)
private

Definition at line 993 of file BatchProcessDialog.cpp.

994{
995 // Similar to Bug 2284 we may need to save a changed macro.
996 if (!ChangeOK()) {
997 return;
998 }
999
1000 while (true) {
1002 XO("Enter name of new macro"),
1003 XO("Name of new macro"));
1004 d.SetName(d.GetTitle());
1005 wxString name;
1006
1007 if (d.ShowModal() == wxID_CANCEL) {
1008 Raise();
1009 return;
1010 }
1011 Raise();
1012
1013 name = d.GetValue().Strip(wxString::both);
1014
1015 if (name.length() == 0) {
1017 XO("Name must not be blank"),
1018 WindowTitle(),
1019 wxOK | wxICON_ERROR,
1020 this);
1021 continue;
1022 }
1023
1024 if (name.Contains(wxFILE_SEP_PATH) ||
1025 name.Contains(wxFILE_SEP_PATH_UNIX)) {
1027 /*i18n-hint: The %c will be replaced with 'forbidden characters', like '/' and '\'.*/
1028 XO("Names may not contain '%c' and '%c'")
1029 .Format(wxFILE_SEP_PATH, wxFILE_SEP_PATH_UNIX),
1030 WindowTitle(),
1031 wxOK | wxICON_ERROR,
1032 this);
1033 continue;
1034 }
1035
1037
1039
1041 UpdateMenus();
1042
1043 break;
1044 }
1045}
const TranslatableString name
Definition: Distortion.cpp:82
Wrap wxTextEntryDialog so that caption IS translatable.
Abstract base class used in importing a file.
bool AddMacro(const wxString &macro)
TranslatableString & Strip(unsigned options=MenuCodes) &

References MacroCommands::AddMacro(), AudacityMessageBox(), ChangeOK(), ApplyMacroDialog::mActiveMacro, ApplyMacroDialog::mMacroCommands, name, ApplyMacroDialog::PopulateMacros(), UpdateMenus(), WindowTitle(), and XO.

Here is the call graph for this function:

◆ OnApplyToFiles()

void MacrosWindow::OnApplyToFiles ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from ApplyMacroDialog.

Definition at line 1319 of file BatchProcessDialog.cpp.

1320{
1321 if( !SaveChanges() )
1322 return;
1324}
virtual void OnApplyToFiles(wxCommandEvent &event)

References ApplyMacroDialog::OnApplyToFiles(), and SaveChanges().

Here is the call graph for this function:

◆ OnApplyToProject()

void MacrosWindow::OnApplyToProject ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from ApplyMacroDialog.

Definition at line 1312 of file BatchProcessDialog.cpp.

1313{
1314 if( !SaveChanges() )
1315 return;
1317}
virtual void OnApplyToProject(wxCommandEvent &event)

References ApplyMacroDialog::OnApplyToProject(), and SaveChanges().

Here is the call graph for this function:

◆ OnCancel()

void MacrosWindow::OnCancel ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from ApplyMacroDialog.

Definition at line 1353 of file BatchProcessDialog.cpp.

1354{
1355 bool bWasChanged = mChanged;
1356 if (!ChangeOK()) {
1357 return;
1358 }
1359 // If we've rejected a change, we need to restore the display
1360 // of the active macro.
1361 // That's because next time we open this dialog we want to see the
1362 // unedited macro.
1363 if( bWasChanged )
1365 Hide();
1366}

References ChangeOK(), mChanged, and ShowActiveMacro().

Here is the call graph for this function:

◆ OnCommandActivated()

void MacrosWindow::OnCommandActivated ( wxListEvent &  event)
private

An item in the list has been selected. Bring up a dialog to allow its parameters to be edited.

Definition at line 1161 of file BatchProcessDialog.cpp.

1162{
1163 wxCommandEvent dummy;
1164 OnEditCommandParams( dummy );
1165}
void OnEditCommandParams(wxCommandEvent &event)

References OnEditCommandParams().

Here is the call graph for this function:

◆ OnDelete()

void MacrosWindow::OnDelete ( wxCommandEvent &  event)
private

Definition at line 1247 of file BatchProcessDialog.cpp.

1248{
1249 long item = mList->GetNextItem(-1,
1250 wxLIST_NEXT_ALL,
1251 wxLIST_STATE_SELECTED);
1252 if (item == -1 || item + 1 == mList->GetItemCount()) {
1253 return;
1254 }
1255
1257
1258 mChanged = true;
1259 mSave->Enable( mChanged );
1260
1261 if (item >= (mList->GetItemCount() - 2) && item >= 0) {
1262 item--;
1263 }
1264 mSelectedCommand = item;
1265 PopulateList();
1266}
void DeleteFromMacro(int index)

References MacroCommands::DeleteFromMacro(), mChanged, ApplyMacroDialog::mList, ApplyMacroDialog::mMacroCommands, mSave, mSelectedCommand, and PopulateList().

Here is the call graph for this function:

◆ OnDown()

void MacrosWindow::OnDown ( wxCommandEvent &  event)
private

Definition at line 1291 of file BatchProcessDialog.cpp.

1292{
1293 long item = mList->GetNextItem(-1,
1294 wxLIST_NEXT_ALL,
1295 wxLIST_STATE_SELECTED);
1296 if (item == -1 || item + 2 >= mList->GetItemCount()) {
1297 return;
1298 }
1299
1302 item + 2);
1304
1305 mChanged = true;
1306 mSave->Enable( mChanged );
1307
1308 mSelectedCommand = item + 1;
1309 PopulateList();
1310}
wxString GetParams(int index)
CommandID GetCommand(int index)

References MacroCommands::AddToMacro(), MacroCommands::DeleteFromMacro(), MacroCommands::GetCommand(), MacroCommands::GetParams(), mChanged, ApplyMacroDialog::mList, ApplyMacroDialog::mMacroCommands, mSave, mSelectedCommand, and PopulateList().

Here is the call graph for this function:

◆ OnEditCommandParams()

void MacrosWindow::OnEditCommandParams ( wxCommandEvent &  event)
private

Definition at line 1207 of file BatchProcessDialog.cpp.

1208{
1209 int item = mList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
1210
1211 // LAST command in list is END.
1212 // If nothing selected, add at END.
1213 // If END selected, add at END.
1214 // When adding at end we use InsertCommandAt, so that a new command
1215 // can be chosen.
1216 int lastItem = mList->GetItemCount()-1;
1217 if( (item<0) || (item+1) == mList->GetItemCount() )
1218 {
1219 InsertCommandAt( lastItem );
1220 return;
1221 }
1222
1223 // Just edit the parameters, and not the command.
1224 auto command = mMacroCommands.GetCommand(item);
1225 wxString params = mMacroCommands.GetParams(item);
1226 wxString oldParams = params;
1227
1228 params = MacroCommands::PromptForParamsFor(command, params, *this).Trim();
1229 Raise();
1230
1231 if (oldParams == params)
1232 return; // They did not actually make any changes..
1233
1235 mMacroCommands.AddToMacro(command,
1236 params,
1237 item);
1238
1239 mChanged = true;
1240 mSave->Enable( mChanged );
1241
1242 mSelectedCommand = item;
1243 PopulateList();
1244}
EffectDistortion::Params params
Definition: Distortion.cpp:83
static wxString PromptForParamsFor(const CommandID &command, const wxString &params, wxWindow &parent)
void InsertCommandAt(int item)

References MacroCommands::AddToMacro(), MacroCommands::DeleteFromMacro(), MacroCommands::GetCommand(), MacroCommands::GetParams(), InsertCommandAt(), mChanged, ApplyMacroDialog::mList, ApplyMacroDialog::mMacroCommands, mSave, mSelectedCommand, params, PopulateList(), and MacroCommands::PromptForParamsFor().

Referenced by OnCommandActivated().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnExpand()

void MacrosWindow::OnExpand ( wxCommandEvent &  event)
private

Definition at line 824 of file BatchProcessDialog.cpp.

825{ UpdateDisplay( true );}
void UpdateDisplay(bool bExpanded)

References UpdateDisplay().

Here is the call graph for this function:

◆ OnExport()

void MacrosWindow::OnExport ( wxCommandEvent &  event)
private

Definition at line 1141 of file BatchProcessDialog.cpp.

1142{
1143 long item = mMacros->GetNextItem(-1,
1144 wxLIST_NEXT_ALL,
1145 wxLIST_STATE_SELECTED);
1146 if (item == -1) {
1147 return;
1148 }
1149
1150 mMacroCommands.WriteMacro(mMacros->GetItemText(item), this);
1151}
wxListCtrl * mMacros

References ApplyMacroDialog::mMacroCommands, ApplyMacroDialog::mMacros, and MacroCommands::WriteMacro().

Here is the call graph for this function:

◆ OnImport()

void MacrosWindow::OnImport ( wxCommandEvent &  event)
private

Definition at line 1114 of file BatchProcessDialog.cpp.

1115{
1116 if (!ChangeOK()) {
1117 return;
1118 }
1119
1120 long item = mMacros->GetNextItem(-1,
1121 wxLIST_NEXT_ALL,
1122 wxLIST_STATE_SELECTED);
1123 if (item == -1) {
1124 return;
1125 }
1126
1127 wxString name = mMacros->GetItemText(item);
1128
1129 name = mMacroCommands.ReadMacro({}, this);
1130 if (name == wxEmptyString) {
1131 return;
1132 }
1133
1135
1137 UpdateMenus();
1138}
wxString ReadMacro(const wxString &macro, wxWindow *parent=nullptr)

References ChangeOK(), ApplyMacroDialog::mActiveMacro, ApplyMacroDialog::mMacroCommands, ApplyMacroDialog::mMacros, name, ApplyMacroDialog::PopulateMacros(), MacroCommands::ReadMacro(), and UpdateMenus().

Here is the call graph for this function:

◆ OnInsert()

void MacrosWindow::OnInsert ( wxCommandEvent &  event)
private

Definition at line 1168 of file BatchProcessDialog.cpp.

1169{
1170 long item = mList->GetNextItem(-1,
1171 wxLIST_NEXT_ALL,
1172 wxLIST_STATE_SELECTED);
1173 if (item == -1) {
1174 item = mList->GetItemCount()-1;
1175 }
1176 InsertCommandAt( item );
1177}

References InsertCommandAt(), and ApplyMacroDialog::mList.

Here is the call graph for this function:

◆ OnKeyDown()

void MacrosWindow::OnKeyDown ( wxKeyEvent &  event)
private

Definition at line 1369 of file BatchProcessDialog.cpp.

1370{
1371 if (event.GetKeyCode() == WXK_DELETE) {
1372 wxLogDebug(wxT("wxKeyEvent"));
1373 }
1374
1375 event.Skip();
1376}

◆ OnListSelected()

void MacrosWindow::OnListSelected ( wxListEvent &  event)
private

An item in the macros list has been selected.

Definition at line 897 of file BatchProcessDialog.cpp.

898{
899 FitColumns();
900}

References FitColumns().

Here is the call graph for this function:

◆ OnMacrosBeginEdit()

void MacrosWindow::OnMacrosBeginEdit ( wxListEvent &  event)
private

Definition at line 956 of file BatchProcessDialog.cpp.

957{
958 int itemNo = event.GetIndex();
959
960 wxString macro = mMacros->GetItemText(itemNo);
961
962 if (mMacroCommands.IsFixed(macro)) {
963 wxBell();
964 event.Veto();
965 }
966 if( mMacroBeingRenamed.IsEmpty())
967 mMacroBeingRenamed = macro;
968}
bool IsFixed(const wxString &name)

References MacroCommands::IsFixed(), ApplyMacroDialog::mMacroBeingRenamed, ApplyMacroDialog::mMacroCommands, and ApplyMacroDialog::mMacros.

Here is the call graph for this function:

◆ OnMacroSelected()

void MacrosWindow::OnMacroSelected ( wxListEvent &  event)
private

An item in the macros list has been selected.

Definition at line 863 of file BatchProcessDialog.cpp.

864{
865 if (!ChangeOK()) {
866 event.Veto();
867 return;
868 }
869
870 int item = event.GetIndex();
871
872 mActiveMacro = mMacros->GetItemText(item);
874}

References ChangeOK(), ApplyMacroDialog::mActiveMacro, ApplyMacroDialog::mMacros, and ShowActiveMacro().

Here is the call graph for this function:

◆ OnMacrosEndEdit()

void MacrosWindow::OnMacrosEndEdit ( wxListEvent &  event)
private

Definition at line 971 of file BatchProcessDialog.cpp.

972{
973 if (event.IsEditCancelled()) {
975 return;
976 }
977
978 if( mMacroBeingRenamed.IsEmpty())
979 return;
980
981 wxString newname = event.GetLabel();
982
985 mActiveMacro = newname;
988 UpdateMenus();
989 event.Veto();
990}
bool RenameMacro(const wxString &oldmacro, const wxString &newmacro)

References ApplyMacroDialog::mActiveMacro, ApplyMacroDialog::mMacroBeingRenamed, ApplyMacroDialog::mMacroCommands, ApplyMacroDialog::PopulateMacros(), MacroCommands::RenameMacro(), and UpdateMenus().

Here is the call graph for this function:

◆ OnOK()

void MacrosWindow::OnOK ( wxCommandEvent &  event)
private

Send changed values back to Prefs, and update Audacity.

Definition at line 1344 of file BatchProcessDialog.cpp.

1345{
1346 if( !SaveChanges() )
1347 return;
1348 Hide();
1349 //EndModal(true);
1350}

References SaveChanges().

Here is the call graph for this function:

◆ OnRemove()

void MacrosWindow::OnRemove ( wxCommandEvent &  event)
private

Definition at line 1048 of file BatchProcessDialog.cpp.

1049{
1050 long item = mMacros->GetNextItem(-1,
1051 wxLIST_NEXT_ALL,
1052 wxLIST_STATE_SELECTED);
1053 if (item == -1) {
1054 return;
1055 }
1056
1057 wxString name = mMacros->GetItemText(item);
1059 this,
1060 /*i18n-hint: %s will be replaced by the name of a file.*/
1061 XO("Are you sure you want to delete %s?").Format( name ),
1062 Verbatim( GetTitle() ),
1063 wxYES_NO | wxICON_QUESTION );
1064 if (m.ShowModal() == wxID_NO) {
1065 Raise();
1066 return;
1067 }
1068 Raise();
1069
1071
1072 item++;
1073 if (item >= (mMacros->GetItemCount() - 1) && item >= 0) {
1074 item--;
1075 }
1076
1077 // Bug 2284. The macro we have just removed might have been
1078 // changed. Since we've just deleted the macro, we should
1079 // forget about that change.
1080 mChanged = false;
1081 mSave->Enable( mChanged );
1082 mActiveMacro = mMacros->GetItemText(item);
1083
1085 UpdateMenus();
1086}
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Wrap wxMessageDialog so that caption IS translatable.
bool DeleteMacro(const wxString &name)

References MacroCommands::DeleteMacro(), ApplyMacroDialog::mActiveMacro, mChanged, ApplyMacroDialog::mMacroCommands, ApplyMacroDialog::mMacros, mSave, name, ApplyMacroDialog::PopulateMacros(), UpdateMenus(), Verbatim(), and XO.

Here is the call graph for this function:

◆ OnRename()

void MacrosWindow::OnRename ( wxCommandEvent &  event)
private

Definition at line 1089 of file BatchProcessDialog.cpp.

1090{
1091 long item = mMacros->GetNextItem(-1,
1092 wxLIST_NEXT_ALL,
1093 wxLIST_STATE_SELECTED);
1094 if (item == -1) {
1095 return;
1096 }
1097
1098 mMacros->EditLabel(item);
1099 UpdateMenus();
1100}

References ApplyMacroDialog::mMacros, and UpdateMenus().

Here is the call graph for this function:

◆ OnRestore()

void MacrosWindow::OnRestore ( wxCommandEvent &  event)
private

Reset a built in macro.

Definition at line 1103 of file BatchProcessDialog.cpp.

1104{
1106
1107 mChanged = true;
1108 mSave->Enable( mChanged );
1109
1110 PopulateList();
1111}
void RestoreMacro(const wxString &name)

References ApplyMacroDialog::mActiveMacro, mChanged, ApplyMacroDialog::mMacroCommands, mSave, PopulateList(), and MacroCommands::RestoreMacro().

Here is the call graph for this function:

◆ OnSave()

void MacrosWindow::OnSave ( wxCommandEvent &  event)
private

Definition at line 1153 of file BatchProcessDialog.cpp.

1154{
1155 SaveChanges();
1156}

References SaveChanges().

Here is the call graph for this function:

◆ OnShrink()

void MacrosWindow::OnShrink ( wxCommandEvent &  event)
private

Definition at line 827 of file BatchProcessDialog.cpp.

828{
829 if( ChangeOK() )
830 UpdateDisplay( false );
831}

References ChangeOK(), and UpdateDisplay().

Here is the call graph for this function:

◆ OnSize()

void MacrosWindow::OnSize ( wxSizeEvent &  event)
private

The window has been resized.

Definition at line 903 of file BatchProcessDialog.cpp.

904{
905 // Refresh the layout and re-fit the columns.
906 Layout();
907 if( !mbExpanded )
908 return;
909 FitColumns();
910}

References FitColumns(), and ApplyMacroDialog::mbExpanded.

Here is the call graph for this function:

◆ OnUp()

void MacrosWindow::OnUp ( wxCommandEvent &  event)
private

Definition at line 1269 of file BatchProcessDialog.cpp.

1270{
1271 long item = mList->GetNextItem(-1,
1272 wxLIST_NEXT_ALL,
1273 wxLIST_STATE_SELECTED);
1274 if (item == -1 || item == 0 || item + 1 == mList->GetItemCount()) {
1275 return;
1276 }
1277
1280 item - 1);
1282
1283 mChanged = true;
1284 mSave->Enable( mChanged );
1285
1286 mSelectedCommand = item - 1;
1287 PopulateList();
1288}

References MacroCommands::AddToMacro(), MacroCommands::DeleteFromMacro(), MacroCommands::GetCommand(), MacroCommands::GetParams(), mChanged, ApplyMacroDialog::mList, ApplyMacroDialog::mMacroCommands, mSave, mSelectedCommand, and PopulateList().

Here is the call graph for this function:

◆ Populate()

void MacrosWindow::Populate ( )
private

Creates the dialog and its contents.

Definition at line 595 of file BatchProcessDialog.cpp.

596{
597 //------------------------- Main section --------------------
598 ShuttleGui S(this, eIsCreating);
600 // ----------------------- End of main section --------------
601
602 // Get and validate the currently active macro
603 mActiveMacro = gPrefs->Read(wxT("/Batch/ActiveMacro"), wxT(""));
604 // Go populate the macros list.
606
607 // We have a bare list. We need to add columns and content.
608 PopulateList();
609
610 // Layout and set minimum size of window
611 Layout();
612 Fit();
613 SetSizeHints(GetSize());
614
615 // Size and place window
616 SetSize(std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4, 800),
617 std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5, 400));
618 Center();
619
620 // Set the column size for the macros list.
621 wxSize sz = mMacros->GetClientSize();
622 mMacros->SetColumnWidth(0, sz.x);
623
624 // Size columns properly
625 FitColumns();
626}
int min(int a, int b)
FileConfig * gPrefs
Definition: Prefs.cpp:71
@ eIsCreating
Definition: ShuttleGui.h:39
#define S(N)
Definition: ToChars.cpp:64
void PopulateOrExchange(ShuttleGui &S)
Defines the dialog and does data exchange with it.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628

References eIsCreating, FitColumns(), gPrefs, ApplyMacroDialog::mActiveMacro, min(), ApplyMacroDialog::mMacros, PopulateList(), ApplyMacroDialog::PopulateMacros(), PopulateOrExchange(), and S.

Referenced by MacrosWindow(), and UpdateDisplay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PopulateList()

void MacrosWindow::PopulateList ( )
private

This clears and updates the contents of mList, the commands for the current macro.

Definition at line 727 of file BatchProcessDialog.cpp.

728{
729 int topItem = mList->GetTopItem();
730 mList->DeleteAllItems();
731
732 for (int i = 0; i < mMacroCommands.GetCount(); i++) {
735 }
736 /*i18n-hint: This is the last item in a list.*/
737 AddItem(_("- END -"), wxT(""));
738
739 // Select the name in the list...this will fire an event.
740 if (mSelectedCommand >= (int)mList->GetItemCount()) {
742 }
743 mList->SetItemState(mSelectedCommand,
744 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
745 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
746 if( 0 <= topItem && topItem < (int)mList->GetItemCount())
747 {
748 // Workaround for scrolling being windows only.
749 // Try to scroll back to where we once were...
750 mList->EnsureVisible( (int)mList->GetItemCount() -1 );
751 mList->EnsureVisible( topItem );
752 // And then make sure whatever is selected is still visible...
753 if (mSelectedCommand >= 0) {
754 mList->EnsureVisible( mSelectedCommand );
755 }
756 }
757}
#define _(s)
Definition: Internat.h:75
void AddItem(const CommandID &command, wxString const &params)
Add one item into mList.

References _, AddItem(), MacroCommands::GetCommand(), MacroCommands::GetCount(), MacroCommands::GetParams(), ApplyMacroDialog::mList, ApplyMacroDialog::mMacroCommands, and mSelectedCommand.

Referenced by InsertCommandAt(), OnDelete(), OnDown(), OnEditCommandParams(), OnRestore(), OnUp(), Populate(), and ShowActiveMacro().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PopulateOrExchange()

void MacrosWindow::PopulateOrExchange ( ShuttleGui S)
private

Defines the dialog and does data exchange with it.

Definition at line 629 of file BatchProcessDialog.cpp.

630{
631 S.StartHorizontalLay(wxEXPAND, 1);
632 {
633 S.StartStatic(XO("Select Macro"),0);
634 {
635 S.StartHorizontalLay(wxEXPAND,1);
636 {
637 mMacros = S.Id(MacrosListID).Prop(1)
638 .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES
639 | wxLC_SINGLE_SEL | wxLC_EDIT_LABELS)
640 // i18n-hint: This is the heading for a column in the edit macros dialog
641 .AddListControlReportMode( { XO("Macro") } );
642 S.StartVerticalLay(wxALIGN_TOP, 0);
643 {
644 S.Id(AddButtonID).AddButton(XXO("&New"), wxALIGN_LEFT);
645 mRemove = S.Id(RemoveButtonID).AddButton(XXO("Remo&ve"), wxALIGN_LEFT);
646 mRename = S.Id(RenameButtonID).AddButton(XXO("&Rename..."), wxALIGN_LEFT);
647 mRestore = S.Id(RestoreButtonID).AddButton(XXO("Re&store"), wxALIGN_LEFT);
648 mImport = S.Id(ImportButtonID).AddButton(XO("I&mport..."), wxALIGN_LEFT);
649 mExport = S.Id(ExportButtonID).AddButton(XO("E&xport..."), wxALIGN_LEFT);
650 }
651 S.EndVerticalLay();
652 }
653 S.EndHorizontalLay();
654 }
655 S.EndStatic();
656
657 S.StartStatic(XO("Edit Steps"), true);
658 {
659 S.StartHorizontalLay(wxEXPAND,1);
660 {
662 .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
663 wxLC_SINGLE_SEL)
664 .AddListControlReportMode({
665 /* i18n-hint: This is the number of the command in the list */
666 { XO("Num"), wxLIST_FORMAT_RIGHT },
667 { XO("Command "), wxLIST_FORMAT_RIGHT },
668 { XO("Parameters"), wxLIST_FORMAT_LEFT }
669 });
670
671 S.StartVerticalLay(wxALIGN_TOP, 0);
672 {
673 S.Id(InsertButtonID).AddButton(XXO("&Insert"), wxALIGN_LEFT);
674 S.Id(EditButtonID).AddButton(XXO("&Edit..."), wxALIGN_LEFT);
675 S.Id(DeleteButtonID).AddButton(XXO("De&lete"), wxALIGN_LEFT);
676 S.Id(UpButtonID).AddButton(XXO("Move &Up"), wxALIGN_LEFT);
677 S.Id(DownButtonID).AddButton(XXO("Move &Down"), wxALIGN_LEFT);
678 mSave = S.Id(SaveButtonID).AddButton(XO("&Save"), wxALIGN_LEFT);
679 mSave->Enable( mChanged );
680 }
681 S.EndVerticalLay();
682 }
683 S.EndHorizontalLay();
684 }
685 S.EndStatic();
686 }
687 S.EndHorizontalLay();
688
689 S.StartHorizontalLay(wxEXPAND, 0);
690 {
691 /* i18n-hint: The Shrink button makes the dialog smaller, with less in it */
692 mResize = S.Id(ShrinkID).AddButton(XXO("Shrin&k"));
693 // Using variable text just to get the positioning options.
694 S.Prop(0).AddVariableText(
695 XO("Apply Macro to:"), false, wxALL | wxALIGN_CENTRE_VERTICAL );
696 wxButton* btn = S.Id(ApplyToProjectID)
697 .Name(XO("Apply macro to project"))
698 .AddButton(XXO("&Project"));
699#if wxUSE_ACCESSIBILITY
700 // so that name can be set on a standard control
701 btn->SetAccessible(safenew WindowAccessible(btn));
702#endif
703
704 btn = S.Id(ApplyToFilesID)
705 .Name(XO("Apply macro to files..."))
706 .AddButton(XXO("&Files..."));
707#if wxUSE_ACCESSIBILITY
708 // so that name can be set on a standard control
709 btn->SetAccessible(safenew WindowAccessible(btn));
710#endif
711 S.AddSpace( 10,10,1 );
712 // Bug 2524 OK button does much the same as cancel, so remove it.
713 // OnCancel prompts you if there has been a change.
714 // OnOK saves without prompting.
715 // That difference is too slight to merit a button, and with the OK
716 // button, people might expect the dialog to apply the macro too.
717 S.AddStandardButtons( /*eOkButton |*/ eCloseButton | eHelpButton);
718 }
719
720 S.EndHorizontalLay();
721
722
723 return;
724}
#define ApplyToFilesID
#define MacrosListID
#define CommandsListID
#define ApplyToProjectID
#define ShrinkID
@ SaveButtonID
@ UpButtonID
@ ImportButtonID
@ DownButtonID
@ RestoreButtonID
@ RenameButtonID
@ AddButtonID
@ EditButtonID
@ RemoveButtonID
@ DeleteButtonID
@ InsertButtonID
@ ExportButtonID
#define XXO(s)
Definition: Internat.h:44
#define safenew
Definition: MemoryX.h:10
@ eCloseButton
Definition: ShuttleGui.h:607
@ eHelpButton
Definition: ShuttleGui.h:601
wxButton * mResize
Provides list of available commands.
wxButton * mRemove
wxButton * mRestore
wxButton * mImport
wxButton * mRename
wxButton * mExport
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...

References AddButtonID, ApplyToFilesID, ApplyToProjectID, CommandsListID, DeleteButtonID, DownButtonID, eCloseButton, EditButtonID, eHelpButton, ExportButtonID, ImportButtonID, InsertButtonID, MacrosListID, mChanged, mExport, mImport, ApplyMacroDialog::mList, ApplyMacroDialog::mMacros, mRemove, mRename, ApplyMacroDialog::mResize, mRestore, mSave, RemoveButtonID, RenameButtonID, RestoreButtonID, S, safenew, SaveButtonID, ShrinkID, UpButtonID, XO, and XXO.

Referenced by Populate().

Here is the caller graph for this function:

◆ SaveChanges()

bool MacrosWindow::SaveChanges ( )
private

Definition at line 1326 of file BatchProcessDialog.cpp.

1326 {
1327 gPrefs->Write(wxT("/Batch/ActiveMacro"), mActiveMacro);
1328 gPrefs->Flush();
1329
1330 if (mChanged) {
1332 return false;
1333 }
1334 }
1335
1336 mChanged = false;
1337 if( mSave )
1338 mSave->Enable( mChanged );
1339
1340 return true;
1341}
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143

References FileConfig::Flush(), gPrefs, ApplyMacroDialog::mActiveMacro, mChanged, ApplyMacroDialog::mMacroCommands, mSave, and MacroCommands::WriteMacro().

Referenced by OnApplyToFiles(), OnApplyToProject(), OnOK(), OnSave(), and UpdateDisplay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowActiveMacro()

void MacrosWindow::ShowActiveMacro ( )
private

Definition at line 876 of file BatchProcessDialog.cpp.

877{
879 if( !mbExpanded )
880 return;
881
883 mRemove->Disable();
884 mRename->Disable();
885 mRestore->Enable();
886 }
887 else {
888 mRemove->Enable();
889 mRename->Enable();
890 mRestore->Disable();
891 }
892
893 PopulateList();
894}

References MacroCommands::IsFixed(), ApplyMacroDialog::mActiveMacro, ApplyMacroDialog::mbExpanded, ApplyMacroDialog::mMacroCommands, mRemove, mRename, mRestore, PopulateList(), and MacroCommands::ReadMacro().

Referenced by OnCancel(), and OnMacroSelected().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateDisplay()

void MacrosWindow::UpdateDisplay ( bool  bExpanded)

Definition at line 784 of file BatchProcessDialog.cpp.

785{
786 // If we failed to save changes, we abandon the attempt to
787 // change the expand/shrink state of the GUI.
788 if( !SaveChanges() )
789 return;
790
791 mbExpanded = bExpanded;
792
793 mChanged = false;
794 // if we try to access the about to be destroyed mSave button
795 // inappropriately, we need to crash rather than (sometimes) silently
796 // succeed.
797 mSave = nullptr;
798
799 DestroyChildren();
800 SetSizer( nullptr );
801
803 SetMinSize( wxSize( 200,200 ));
804
805 // Get and set position for optical stability.
806 // Expanded and shrunk dialogs 'stay where they were'.
807 // That's OK , and what we want, even if we exapnd off-screen.
808 // We won't shrink to being off-screen, since the shrink button
809 // was clicked, so must have been on screen.
810 wxPoint p = GetPosition( );
811 if( mbExpanded )
812 Populate();
813 else
815 SetPosition( p );
816 mResize->SetFocus();
817
818 auto Title = WindowTitle();
819 SetLabel( Title ); // Provide visual label
820 SetName( Title ); // Provide audible label
821 SetTitle( Title );
822}

References ApplyMacroDialog::mbExpanded, mChanged, ApplyMacroDialog::mResize, mSave, mSelectedCommand, ApplyMacroDialog::Populate(), Populate(), SaveChanges(), wxDialogWrapper::SetLabel(), wxDialogWrapper::SetName(), wxDialogWrapper::SetTitle(), and WindowTitle().

Referenced by PluginActions::Handler::OnApplyMacrosPalette(), OnExpand(), PluginActions::Handler::OnManageMacros(), OnShrink(), and UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateMenus()

void MacrosWindow::UpdateMenus ( )
private

Definition at line 777 of file BatchProcessDialog.cpp.

778{
779 // OK even on mac, as dialog is modal.
780 auto p = &mProject;
782}
void RebuildMenuBar(AudacityProject &project)
Definition: Menus.cpp:486
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:71

References MenuManager::Get(), mProject, and MenuCreator::RebuildMenuBar().

Referenced by OnAdd(), OnImport(), OnMacrosEndEdit(), OnRemove(), and OnRename().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatePrefs()

void MacrosWindow::UpdatePrefs ( )
overrideprivatevirtual

Implements PrefsListener.

Definition at line 1384 of file BatchProcessDialog.cpp.

1385{
1387}

References ApplyMacroDialog::mbExpanded, and UpdateDisplay().

Here is the call graph for this function:

◆ WindowTitle()

TranslatableString MacrosWindow::WindowTitle ( ) const
private

Definition at line 1378 of file BatchProcessDialog.cpp.

1379{
1381}
#define MacrosPaletteTitle
#define ManageMacrosTitle

References MacrosPaletteTitle, ManageMacrosTitle, and ApplyMacroDialog::mbExpanded.

Referenced by MacrosWindow(), OnAdd(), and UpdateDisplay().

Here is the caller graph for this function:

Member Data Documentation

◆ mChanged

bool MacrosWindow::mChanged
private

◆ mExport

wxButton* MacrosWindow::mExport
private

Definition at line 140 of file BatchProcessDialog.h.

Referenced by PopulateOrExchange().

◆ mImport

wxButton* MacrosWindow::mImport
private

Definition at line 139 of file BatchProcessDialog.h.

Referenced by PopulateOrExchange().

◆ mProject

AudacityProject& MacrosWindow::mProject
private

Definition at line 134 of file BatchProcessDialog.h.

Referenced by InsertCommandAt(), and UpdateMenus().

◆ mRemove

wxButton* MacrosWindow::mRemove
private

Definition at line 136 of file BatchProcessDialog.h.

Referenced by PopulateOrExchange(), and ShowActiveMacro().

◆ mRename

wxButton* MacrosWindow::mRename
private

Definition at line 137 of file BatchProcessDialog.h.

Referenced by PopulateOrExchange(), and ShowActiveMacro().

◆ mRestore

wxButton* MacrosWindow::mRestore
private

Definition at line 138 of file BatchProcessDialog.h.

Referenced by PopulateOrExchange(), and ShowActiveMacro().

◆ mSave

wxButton* MacrosWindow::mSave
private

◆ mSelectedCommand

int MacrosWindow::mSelectedCommand
private

The documentation for this class was generated from the following files: