23 #include <wx/ownerdrw.h>
27#include <wx/checkbox.h>
30#include <wx/statbox.h>
31#include <wx/stattext.h>
32#include <wx/textctrl.h>
33#include <wx/listctrl.h>
35#include <wx/imaglist.h>
36#include <wx/settings.h>
52#include "../images/Arrow.xpm"
53#include "../images/Empty9x16.xpm"
65#if wxUSE_ACCESSIBILITY
69#define MacrosPaletteTitle XO("Macros Palette")
70#define ManageMacrosTitle XO("Manage Macros")
75#define MacrosListID 7001
76#define CommandsListID 7002
77#define ApplyToProjectID 7003
78#define ApplyToFilesID 7004
93 wxDefaultPosition, wxDefaultSize,
94 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
126 wxSize sz = GetSize();
130 SetSize(
std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4, sz.GetWidth()),
131 std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5, 400));
137 mMacros->SetColumnWidth(0, sz.x);
145 S.StartStatic(
XO(
"Select Macro"), 1);
148 .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
151 .AddListControlReportMode( {
XO(
"Macro") } );
155 S.StartHorizontalLay(wxEXPAND, 0);
157 S.AddPrompt(
XXO(
"Apply Macro to:") );
159 .Name(
XO(
"Apply macro to project"))
160 .AddButton(
XXO(
"&Project"));
161#if wxUSE_ACCESSIBILITY
167 .Name(
XO(
"Apply macro to files..."))
168 .AddButton(
XXO(
"&Files..."));
169#if wxUSE_ACCESSIBILITY
174 S.EndHorizontalLay();
176 S.StartHorizontalLay(wxEXPAND, 0);
180 S.AddSpace( 10,10,1 );
183 S.EndHorizontalLay();
194 int topItem =
mMacros->GetTopItem();
196 for (i = 0; i < (int)
names.size(); i++) {
201 bool bFound = item >=0;
208 mMacros->SetItemState(item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
209 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
211 if( 0 <= topItem && topItem < (
int)
mMacros->GetItemCount())
216 mMacros->EnsureVisible( topItem );
219 mMacros->EnsureVisible( item );
231 long item =
mMacros->GetNextItem(-1,
233 wxLIST_STATE_SELECTED);
244 wxString Temp = MacroName;
245 Temp.Replace(
" ",
"");
246 Temp = wxString(
"Macro_" ) + Temp;
254 for(
int i=0;i<
mMacros->GetItemCount();i++){
270#ifdef OPTIONAL_ACTIVITY_WINDOW
275 S.StartHorizontalLay(wxCENTER,
false);
277 S.StartStatic( {},
false);
280 S.AddFixedText(
XO(
"Applying '%s' to current project")
285 S.EndHorizontalLay();
287 activityWin.Layout();
289 activityWin.CenterOnScreen();
292 activityWin.GetPosition( &x, &y );
293 activityWin.Move(wxMax(0,x-300), 0);
314#ifdef OPTIONAL_ACTIVITY_WINDOW
315 wxWindowDisabler wd(&activityWin);
317 success = GuardedCall< bool >(
330 long item =
mMacros->GetNextItem(-1,
332 wxLIST_STATE_SELECTED);
345 XO(
"Please save and close the current project first.") );
353 auto prompt =
XO(
"Select file(s) for batch processing...");
363 wxFD_OPEN | wxFD_MULTIPLE | wxRESIZE_BORDER);
378 wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
383 wxListCtrl * fileList = NULL;
385 S.StartVerticalLay(1);
387 S.StartStatic(
XO(
"Applying..."), 1);
389 auto imageList = std::make_unique<wxImageList>(9, 16);
390 imageList->Add(wxIcon(empty9x16_xpm));
391 imageList->Add(wxIcon(arrow_xpm));
394 .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
396 .AddListControlReportMode( {
XO(
"File") } );
398 fileList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL);
402 S.StartHorizontalLay(wxCENTER, 0);
404 S.Id(wxID_CANCEL).AddButton(
XXO(
"&Cancel"));
406 S.EndHorizontalLay();
411 for (i = 0; i < (int)files.size(); i++ ) {
412 fileList->InsertItem(i, files[i], i == 0);
416 fileList->SetColumnWidth(0, wxLIST_AUTOSIZE);
418 int width = wxMin( fileList->GetColumnWidth(0), 1000);
419 wxSize sz = fileList->GetClientSize();
420 if (sz.GetWidth() < width ) {
422 if (sz.GetHeight() < width *0.7)
423 sz.SetHeight(width * 0.7);
424 fileList->SetInitialSize(sz);
427 activityWin.Layout();
429 activityWin.CenterOnScreen();
432 activityWin.GetPosition( &x, &y );
433 activityWin.Move(wxMax(0,x-300), 0);
449 if (globalClipboard.Project().lock().get() ==
project)
450 globalClipboard.Clear();
455 wxWindowDisabler wd(&activityWin);
456 for (i = 0; i < (int)files.size(); i++) {
459 fileList->SetItemImage(i - 1, 0, 0);
461 fileList->SetItemImage(i, 1, 1);
462 fileList->EnsureVisible(i);
464 auto success = GuardedCall< bool >([&] {
471 if (!activityWin.IsShown() ||
mAbort)
482 globalClipboard.Clear();
499#include <wx/textdlg.h>
607 SetSizeHints(GetSize());
610 SetSize(
std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4, 800),
611 std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5, 400));
615 wxSize sz =
mMacros->GetClientSize();
616 mMacros->SetColumnWidth(0, sz.x);
625 S.StartHorizontalLay(wxEXPAND, 1);
627 S.StartStatic(
XO(
"Select Macro"),0);
629 S.StartHorizontalLay(wxEXPAND,1);
632 .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES
633 | wxLC_SINGLE_SEL | wxLC_EDIT_LABELS)
635 .AddListControlReportMode( {
XO(
"Macro") } );
636 S.StartVerticalLay(wxALIGN_TOP, 0);
647 S.EndHorizontalLay();
651 S.StartStatic(
XO(
"Edit Steps"),
true);
653 S.StartHorizontalLay(wxEXPAND,1);
656 .Style(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
658 .AddListControlReportMode({
660 {
XO(
"Num"), wxLIST_FORMAT_RIGHT },
661 {
XO(
"Command "), wxLIST_FORMAT_RIGHT },
662 {
XO(
"Parameters"), wxLIST_FORMAT_LEFT }
665 S.StartVerticalLay(wxALIGN_TOP, 0);
677 S.EndHorizontalLay();
681 S.EndHorizontalLay();
683 S.StartHorizontalLay(wxEXPAND, 0);
688 S.Prop(0).AddVariableText(
689 XO(
"Apply Macro to:"),
false, wxALL | wxALIGN_CENTRE_VERTICAL );
691 .Name(
XO(
"Apply macro to project"))
692 .AddButton(
XXO(
"&Project"));
693#if wxUSE_ACCESSIBILITY
699 .Name(
XO(
"Apply macro to files..."))
700 .AddButton(
XXO(
"&Files..."));
701#if wxUSE_ACCESSIBILITY
705 S.AddSpace( 10,10,1 );
714 S.EndHorizontalLay();
723 int topItem =
mList->GetTopItem();
724 mList->DeleteAllItems();
738 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
739 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
740 if( 0 <= topItem && topItem < (
int)
mList->GetItemCount())
744 mList->EnsureVisible( (
int)
mList->GetItemCount() -1 );
745 mList->EnsureVisible( topItem );
758 ?
entry->name.StrippedTranslation()
764 int i =
mList->GetItemCount();
766 mList->InsertItem(i, wxString::Format(
wxT(
" %02i"), i + 1));
797 SetMinSize( wxSize( 200,200 ));
804 wxPoint p = GetPosition( );
834 auto msg =
XO(
"Do you want to save the changes?");
839 wxYES_NO | wxCANCEL);
840 if (
id == wxCANCEL) {
864 int item =
event.GetIndex();
909#if defined(__WXMAC__)
913 for (
size_t c = 0; c <
mList->GetColumnCount(); c++) {
917 mList->SetColumnWidth(c, wxLIST_AUTOSIZE);
920 info.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH);
921 mList->GetColumn(c, info);
923 mList->GetTextExtent(info.GetText(), &width, NULL);
927 mList->SetColumnWidth(c, wxMax(width,
mList->GetColumnWidth(c)));
935 mList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
936 mList->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER);
937 mList->SetColumnWidth(2, wxLIST_AUTOSIZE);
940 int bestfit =
mList->GetColumnWidth(2);
941 int clientsize =
mList->GetClientSize().GetWidth();
942 int col0 =
mList->GetColumnWidth(0);
943 int col1 =
mList->GetColumnWidth(1);
944 bestfit = (bestfit > clientsize-col0-col1)? bestfit : clientsize-col0-col1;
945 mList->SetColumnWidth(2, bestfit);
952 int itemNo =
event.GetIndex();
954 wxString macro =
mMacros->GetItemText(itemNo);
967 if (event.IsEditCancelled()) {
975 wxString newname =
event.GetLabel();
996 XO(
"Enter name of new macro"),
997 XO(
"Name of new macro"));
998 d.SetName(d.GetTitle());
1001 if (d.ShowModal() == wxID_CANCEL) {
1007 name = d.GetValue().Strip(wxString::both);
1009 if (
name.length() == 0) {
1011 XO(
"Name must not be blank"),
1013 wxOK | wxICON_ERROR,
1018 if (
name.Contains(wxFILE_SEP_PATH) ||
1019 name.Contains(wxFILE_SEP_PATH_UNIX)) {
1022 XO(
"Names may not contain '%c' and '%c'")
1023 .
Format(wxFILE_SEP_PATH, wxFILE_SEP_PATH_UNIX),
1025 wxOK | wxICON_ERROR,
1044 long item =
mMacros->GetNextItem(-1,
1046 wxLIST_STATE_SELECTED);
1055 XO(
"Are you sure you want to delete %s?").
Format(
name ),
1057 wxYES_NO | wxICON_QUESTION );
1058 if (m.ShowModal() == wxID_NO) {
1067 if (item >= (
mMacros->GetItemCount() - 1) && item >= 0) {
1085 long item =
mMacros->GetNextItem(-1,
1087 wxLIST_STATE_SELECTED);
1114 long item =
mMacros->GetNextItem(-1,
1116 wxLIST_STATE_SELECTED);
1124 if (
name == wxEmptyString) {
1137 long item =
mMacros->GetNextItem(-1,
1139 wxLIST_STATE_SELECTED);
1157 wxCommandEvent dummy;
1164 long item =
mList->GetNextItem(-1,
1166 wxLIST_STATE_SELECTED);
1168 item =
mList->GetItemCount()-1;
1181 if (!d.ShowModal()) {
1203 int item =
mList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
1210 int lastItem =
mList->GetItemCount()-1;
1211 if( (item<0) || (item+1) ==
mList->GetItemCount() )
1220 wxString oldParams =
params;
1243 long item =
mList->GetNextItem(-1,
1245 wxLIST_STATE_SELECTED);
1246 if (item == -1 || item + 1 ==
mList->GetItemCount()) {
1255 if (item >= (
mList->GetItemCount() - 2) && item >= 0) {
1265 long item =
mList->GetNextItem(-1,
1267 wxLIST_STATE_SELECTED);
1268 if (item == -1 || item == 0 || item + 1 ==
mList->GetItemCount()) {
1287 long item =
mList->GetNextItem(-1,
1289 wxLIST_STATE_SELECTED);
1290 if (item == -1 || item + 2 >=
mList->GetItemCount()) {
1365 if (event.GetKeyCode() == WXK_DELETE) {
1366 wxLogDebug(
wxT(
"wxKeyEvent"));
1395 &window, parent,
true
1406 switch (menuManager.mLastToolRegistration) {
1409 auto lastEffect = menuManager.mLastTool;
1410 if (!lastEffect.empty())
1413 lastEffect, context, menuManager.mRepeatToolFlags);
1419 menuManager.mLastToolRegisteredId);
1434 macrosWindow->Show();
1435 macrosWindow->Raise();
1447 macrosWindow->Show();
1448 macrosWindow->Raise();
1470#ifdef MACROS_BY_NUMBERS
1473 Name.Mid( Name.length() - 3 ).ToLong( &item, 10 );
1487 int cur = undoManager.GetCurrentState();
1488 if (undoManager.UndoAvailable()) {
1489 undoManager.GetShortDescription(cur, &
desc);
1490 commandManager.Modify(
wxT(
"RepeatLastTool"),
XXO(
"&Repeat %s")
1493 menuManager.mLastTool = Name;
1518 return !menuManager.mLastTool.empty();
1537 if (!lastTool.empty())
1538 buildMenuLabel =
XO(
"Repeat %s")
1541 buildMenuLabel =
XO(
"Repeat Last Tool");
1543 return Command(
wxT(
"RepeatLastTool"), buildMenuLabel,
1565 auto result =
Items(
"");
1576 wxT(
"Tools/Manage"),
1585 Menu(
wxT(
"Scriptables1"),
XXO(
"Script&ables I") )
1591 wxT(
"Optional/Extra/Part2"),
1600 Menu(
wxT(
"Scriptables2"),
XXO(
"Scripta&bles II") )
1606 wxT(
"Optional/Extra/Part2"),
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static AudioUnitEffectsModule::Factory::SubstituteInUnique< AudioUnitEffect > scope
BaseItemSharedPtr ExtraScriptablesIIMenu()
AttachedItem sAttachment1
BaseItemSharedPtr ExtraScriptablesIMenu()
AttachedItem sAttachment3
AttachedItem sAttachment2
BaseItemSharedPtr PluginMenuItems()
#define MacrosPaletteTitle
#define ManageMacrosTitle
std::bitset< NCommandFlags > CommandFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
EffectDistortionSettings params
const TranslatableString name
EVT_LIST_ITEM_SELECTED(CurvesListID, EqualizationCurvesDialog::OnListSelectionChange) EVT_LIST_ITEM_DESELECTED(CurvesListID
XXO("&Cut/Copy/Paste Toolbar")
audacity::BasicSettings * gPrefs
AUDACITY_DLL_API AttachedWindows & GetAttachedWindows(AudacityProject &project)
accessors for certain important windows associated with each project
declares abstract base class Track, TrackList, and iterators over TrackList
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
Shows progress in executing commands in MacroCommands.
wxButton * mResize
Provides list of available commands.
virtual void OnApplyToFiles(wxCommandEvent &event)
MacroCommands mMacroCommands
virtual ~ApplyMacroDialog()
AudacityProject & mProject
void ApplyMacroToProject(int iMacro, bool bHasGui=true)
wxString mMacroBeingRenamed
virtual void OnCancel(wxCommandEvent &event)
virtual void OnApplyToProject(wxCommandEvent &event)
const MacroCommandsCatalog mCatalog
virtual void OnHelp(wxCommandEvent &event)
void PopulateOrExchange(ShuttleGui &S)
Defines the dialog and does data exchange with it.
virtual ManualPageID GetHelpPageName()
static CommandID MacroIdOfName(const wxString &MacroName)
Wrap wxMessageDialog so that caption IS translatable.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Wrap wxTextEntryDialog so that caption IS translatable.
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
CommandParameter parameter
AudacityProject & project
void RegisterLastTool(const CommandContext &context)
void DoRepeatProcess(const CommandContext &context, int)
static CommandManager & Get(AudacityProject &project)
EffectManager is the class that handles effects and effect categories.
static EffectManager & Get()
TranslatableString GetCommandName(const PluginID &ID)
virtual void GetPaths(wxArrayString &paths) const
virtual void SetFilterIndex(int filterIndex)
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
FileNames::FileTypes GetFileTypes(const FileNames::FileType &extraType={})
static size_t SelectDefaultOpenType(const FileNames::FileTypes &fileTypes)
Provides a list of configurable commands for use with MacroCommands.
CommandID mSelectedCommand
wxString mSelectedParameters
Entries::const_iterator ByCommandId(const CommandID &commandId) const
Entries::const_iterator end() const
bool IsFixed(const wxString &name)
void AddToMacro(const CommandID &command, int before=-1)
wxString GetParams(int index)
void DeleteFromMacro(int index)
bool RenameMacro(const wxString &oldmacro, const wxString &newmacro)
CommandID GetCommand(int index)
static wxArrayString GetNames()
bool DeleteMacro(const wxString &name)
wxString WriteMacro(const wxString ¯o, wxWindow *parent=nullptr)
bool ApplyMacro(const MacroCommandsCatalog &catalog, const wxString &filename={})
static wxString PromptForParamsFor(const CommandID &command, const wxString ¶ms, wxWindow &parent)
bool AddMacro(const wxString ¯o)
wxString ReadMacro(const wxString ¯o, wxWindow *parent=nullptr)
void RestoreMacro(const wxString &name)
void PopulateList()
This clears and updates the contents of mList, the commands for the current macro.
TranslatableString WindowTitle() const
void OnDelete(wxCommandEvent &event)
void OnListSelected(wxListEvent &event)
An item in the macros list has been selected.
void OnShrink(wxCommandEvent &event)
void OnExport(wxCommandEvent &event)
void PopulateOrExchange(ShuttleGui &S)
Defines the dialog and does data exchange with it.
void OnRestore(wxCommandEvent &event)
Reset a built in macro.
void OnCommandActivated(wxListEvent &event)
AudacityProject & mProject
void OnAdd(wxCommandEvent &event)
void OnUp(wxCommandEvent &event)
void OnCancel(wxCommandEvent &event) override
void OnApplyToProject(wxCommandEvent &event) override
void OnMacroSelected(wxListEvent &event)
An item in the macros list has been selected.
void OnExpand(wxCommandEvent &event)
void OnSave(wxCommandEvent &event)
void OnApplyToFiles(wxCommandEvent &event) override
void UpdateDisplay(bool bExpanded)
void UpdatePrefs() override
void OnMacrosBeginEdit(wxListEvent &event)
void OnSize(wxSizeEvent &event)
The window has been resized.
void OnMacrosEndEdit(wxListEvent &event)
void OnImport(wxCommandEvent &event)
MacrosWindow(wxWindow *parent, AudacityProject &project, bool bExpanded=true)
Constructor.
void OnDown(wxCommandEvent &event)
void OnEditCommandParams(wxCommandEvent &event)
void OnInsert(wxCommandEvent &event)
void OnRemove(wxCommandEvent &event)
void InsertCommandAt(int item)
void Populate()
Creates the dialog and its contents.
void AddItem(const CommandID &command, wxString const ¶ms)
Add one item into mList.
void OnKeyDown(wxKeyEvent &event)
void OnOK(wxCommandEvent &event)
Send changed values back to Prefs, and update Audacity.
void OnRename(wxCommandEvent &event)
bool Import(const FilePath &fileName, bool addToHistory=true)
static ProjectFileManager & Get(AudacityProject &project)
static ProjectManager & Get(AudacityProject &project)
void ResetProjectToEmpty()
void ZoomAfterImport(Track *pTrack)
static ProjectWindow & Get(AudacityProject &project)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
static TrackList & Get(AudacityProject &project)
Holds a msgid for the translation catalog; may also bind format arguments.
static UndoManager & Get(AudacityProject &project)
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
void SetTitle(const TranslatableString &title)
void SetLabel(const TranslatableString &title)
void SetName(const TranslatableString &title)
std::function< void()> Action
AUDACITY_DLL_API bool DoEffect(const PluginID &ID, const CommandContext &context, unsigned flags)
'Repeat Last Effect'.
ExportResult Show(ExportTask exportTask)
FILES_API FilePath FindDefaultPath(Operation op)
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
std::shared_ptr< BaseItem > BaseItemSharedPtr
void DoSelectAll(AudacityProject &project)
CommandManager::Options Options
void OnRepeatLastTool(const CommandContext &context)
void OnApplyMacroDirectlyByName(const CommandContext &context, const MacroID &Name)
void OnApplyMacrosPalette(const CommandContext &context)
void OnManageMacros(const CommandContext &context)
void OnApplyMacroDirectly(const CommandContext &context)
void PopulateMacrosMenu(MenuTable::MenuItems &items, CommandFlag flags)
AttachedWindows::RegisteredFactory sMacrosWindowKey
const ReservedCommandFlag & HasLastToolFlag()
const TranslatableString desc
Empty the clipboard at start of scope; restore its contents after.
Options && AllowInMacros(int value=1) &&
auto push_back(Arg &&arg) -> std::enable_if_t< Traits< Base, Derived > ::template enables_item_type_v< Arg >, void >