21 #include <wx/ownerdrw.h>
25#include <wx/checkbox.h>
29#include <wx/statbox.h>
30#include <wx/stattext.h>
31#include <wx/textctrl.h>
32#include <wx/listctrl.h>
34#include <wx/imaglist.h>
35#include <wx/settings.h>
52#include "../images/Arrow.xpm"
53#include "../images/Empty9x16.xpm"
66#if wxUSE_ACCESSIBILITY
70#define MacrosPaletteTitle XO("Macros Palette")
71#define ManageMacrosTitle XO("Manage Macros")
76#define MacrosListID 7001
77#define CommandsListID 7002
78#define ApplyToProjectID 7003
79#define ApplyToFilesID 7004
94 wxDefaultPosition, wxDefaultSize,
95 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
127 wxSize sz = GetSize();
131 SetSize(
std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4, sz.GetWidth()),
132 std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5, 400));
138 mMacros->SetColumnWidth(0, sz.x);
146 S.StartStatic(
XO(
"Select Macro"), 1);
149 .Style( wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
152 .AddListControlReportMode( {
XO(
"Macro") } );
156 S.StartHorizontalLay(wxEXPAND, 0);
158 S.AddPrompt(
XXO(
"Apply Macro to:") );
160 .Name(
XO(
"Apply macro to project"))
161 .AddButton(
XXO(
"&Project"));
162#if wxUSE_ACCESSIBILITY
168 .Name(
XO(
"Apply macro to files..."))
169 .AddButton(
XXO(
"&Files..."));
170#if wxUSE_ACCESSIBILITY
175 S.EndHorizontalLay();
177 S.StartHorizontalLay(wxEXPAND, 0);
181 S.AddSpace( 10,10,1 );
184 S.EndHorizontalLay();
195 int topItem =
mMacros->GetTopItem();
197 for (i = 0; i < (int)
names.size(); i++) {
202 bool bFound = item >=0;
209 mMacros->SetItemState(item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
210 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
212 if( 0 <= topItem && topItem < (
int)
mMacros->GetItemCount())
217 mMacros->EnsureVisible( topItem );
220 mMacros->EnsureVisible( item );
232 long item =
mMacros->GetNextItem(-1,
234 wxLIST_STATE_SELECTED);
245 wxString Temp = MacroName;
246 Temp.Replace(
" ",
"");
247 Temp = wxString(
"Macro_" ) + Temp;
255 for(
int i=0;i<
mMacros->GetItemCount();i++){
271#ifdef OPTIONAL_ACTIVITY_WINDOW
276 S.StartHorizontalLay(wxCENTER,
false);
278 S.StartStatic( {},
false);
281 S.AddFixedText(
XO(
"Applying '%s' to current project")
286 S.EndHorizontalLay();
288 activityWin.Layout();
290 activityWin.CenterOnScreen();
293 activityWin.GetPosition( &x, &y );
294 activityWin.Move(wxMax(0,x-300), 0);
315#ifdef OPTIONAL_ACTIVITY_WINDOW
316 wxWindowDisabler wd(&activityWin);
318 success = GuardedCall< bool >(
331 long item =
mMacros->GetNextItem(-1,
333 wxLIST_STATE_SELECTED);
346 XO(
"Please save and close the current project first.") );
354 auto prompt =
XO(
"Select file(s) for batch processing...");
364 wxFD_OPEN | wxFD_MULTIPLE | wxRESIZE_BORDER);
379 wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
384 wxListCtrl * fileList = NULL;
386 S.StartVerticalLay(1);
388 S.StartStatic(
XO(
"Applying..."), 1);
390 auto imageList = std::make_unique<wxImageList>(9, 16);
391 imageList->Add(wxIcon(empty9x16_xpm));
392 imageList->Add(wxIcon(arrow_xpm));
395 .Style( wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
397 .AddListControlReportMode( {
XO(
"File") } );
399 fileList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL);
403 S.StartHorizontalLay(wxCENTER, 0);
405 S.Id(wxID_CANCEL).AddButton(
XXO(
"&Cancel"));
407 S.EndHorizontalLay();
412 for (i = 0; i < (int)files.size(); i++ ) {
413 fileList->InsertItem(i, files[i], i == 0);
417 fileList->SetColumnWidth(0, wxLIST_AUTOSIZE);
419 int width = wxMin( fileList->GetColumnWidth(0), 1000);
420 wxSize sz = fileList->GetClientSize();
421 if (sz.GetWidth() < width ) {
423 if (sz.GetHeight() < width *0.7)
424 sz.SetHeight(width * 0.7);
425 fileList->SetInitialSize(sz);
428 activityWin.Layout();
430 activityWin.CenterOnScreen();
433 activityWin.GetPosition( &x, &y );
434 activityWin.Move(wxMax(0,x-300), 0);
450 if (globalClipboard.Project().lock().get() ==
project)
451 globalClipboard.Clear();
456 wxWindowDisabler wd(&activityWin);
457 for (i = 0; i < (int)files.size(); i++) {
460 fileList->SetItemImage(i - 1, 0, 0);
462 fileList->SetItemImage(i, 1, 1);
463 fileList->EnsureVisible(i);
465 auto success = GuardedCall<bool>([&] {
472 if (!activityWin.IsShown() ||
mAbort)
483 globalClipboard.Clear();
500#include <wx/textdlg.h>
608 SetSizeHints(GetSize());
611 SetSize(
std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4, 800),
612 std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5, 400));
616 wxSize sz =
mMacros->GetClientSize();
617 mMacros->SetColumnWidth(0, sz.x);
626 S.StartHorizontalLay(wxEXPAND, 1);
628 S.StartStatic(
XO(
"Select Macro"),0);
630 S.StartHorizontalLay(wxEXPAND,1);
633 .Style( wxLC_REPORT | wxLC_HRULES
634 | wxLC_SINGLE_SEL | wxLC_EDIT_LABELS)
636 .AddListControlReportMode( {
XO(
"Macro") } );
637 S.StartVerticalLay(wxALIGN_TOP, 0);
648 S.EndHorizontalLay();
652 S.StartStatic(
XO(
"Edit Steps"),
true);
654 S.StartHorizontalLay(wxEXPAND,1);
657 .Style( wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
659 .AddListControlReportMode({
661 {
XO(
"Num"), wxLIST_FORMAT_RIGHT },
662 {
XO(
"Command "), wxLIST_FORMAT_RIGHT },
663 {
XO(
"Parameters"), wxLIST_FORMAT_LEFT }
666 S.StartVerticalLay(wxALIGN_TOP, 0);
678 S.EndHorizontalLay();
682 S.EndHorizontalLay();
684 S.StartHorizontalLay(wxEXPAND, 0);
689 S.Prop(0).AddVariableText(
690 XO(
"Apply Macro to:"),
false, wxALL | wxALIGN_CENTRE_VERTICAL );
692 .Name(
XO(
"Apply macro to project"))
693 .AddButton(
XXO(
"&Project"));
694#if wxUSE_ACCESSIBILITY
700 .Name(
XO(
"Apply macro to files..."))
701 .AddButton(
XXO(
"&Files..."));
702#if wxUSE_ACCESSIBILITY
706 S.AddSpace( 10,10,1 );
715 S.EndHorizontalLay();
724 int topItem =
mList->GetTopItem();
725 mList->DeleteAllItems();
739 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
740 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
741 if( 0 <= topItem && topItem < (
int)
mList->GetItemCount())
745 mList->EnsureVisible( (
int)
mList->GetItemCount() -1 );
746 mList->EnsureVisible( topItem );
759 ?
entry->name.StrippedTranslation()
765 int i =
mList->GetItemCount();
767 mList->InsertItem(i, wxString::Format(
wxT(
" %02i"), i + 1));
798 SetMinSize( wxSize( 200,200 ));
805 wxPoint p = GetPosition( );
835 auto msg =
XO(
"Do you want to save the changes?");
840 wxYES_NO | wxCANCEL);
841 if (
id == wxCANCEL) {
865 int item =
event.GetIndex();
901 mEdit->Enable(!ID.empty());
921#if defined(__WXMAC__)
925 for (
size_t c = 0; c <
mList->GetColumnCount(); c++) {
929 mList->SetColumnWidth(c, wxLIST_AUTOSIZE);
932 info.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH);
933 mList->GetColumn(c, info);
935 mList->GetTextExtent(info.GetText(), &width, NULL);
939 mList->SetColumnWidth(c, wxMax(width,
mList->GetColumnWidth(c)));
947 mList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
948 mList->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER);
949 mList->SetColumnWidth(2, wxLIST_AUTOSIZE);
952 int bestfit =
mList->GetColumnWidth(2);
953 int clientsize =
mList->GetClientSize().GetWidth();
954 int col0 =
mList->GetColumnWidth(0);
955 int col1 =
mList->GetColumnWidth(1);
956 bestfit = (bestfit > clientsize-col0-col1)? bestfit : clientsize-col0-col1;
957 mList->SetColumnWidth(2, bestfit);
964 int itemNo =
event.GetIndex();
966 wxString macro =
mMacros->GetItemText(itemNo);
979 if (event.IsEditCancelled()) {
987 wxString newname =
event.GetLabel();
1008 XO(
"Enter name of new macro"),
1009 XO(
"Name of new macro"));
1010 d.SetName(d.GetTitle());
1013 if (d.ShowModal() == wxID_CANCEL) {
1019 name = d.GetValue().Strip(wxString::both);
1021 if (
name.length() == 0) {
1023 XO(
"Name must not be blank"),
1025 wxOK | wxICON_ERROR,
1030 if (
name.Contains(wxFILE_SEP_PATH) ||
1031 name.Contains(wxFILE_SEP_PATH_UNIX)) {
1034 XO(
"Names may not contain '%c' and '%c'")
1035 .
Format(wxFILE_SEP_PATH, wxFILE_SEP_PATH_UNIX),
1037 wxOK | wxICON_ERROR,
1056 long item =
mMacros->GetNextItem(-1,
1058 wxLIST_STATE_SELECTED);
1067 XO(
"Are you sure you want to delete %s?").
Format(
name ),
1069 wxYES_NO | wxICON_QUESTION );
1070 if (m.ShowModal() == wxID_NO) {
1079 if (item >= (
mMacros->GetItemCount() - 1) && item >= 0) {
1097 long item =
mMacros->GetNextItem(-1,
1099 wxLIST_STATE_SELECTED);
1126 long item =
mMacros->GetNextItem(-1,
1128 wxLIST_STATE_SELECTED);
1136 if (
name == wxEmptyString) {
1149 long item =
mMacros->GetNextItem(-1,
1151 wxLIST_STATE_SELECTED);
1169 wxCommandEvent dummy;
1176 long item =
mList->GetNextItem(-1,
1178 wxLIST_STATE_SELECTED);
1180 item =
mList->GetItemCount()-1;
1193 if (!d.ShowModal()) {
1215 int item =
mList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
1222 int lastItem =
mList->GetItemCount()-1;
1223 if( (item<0) || (item+1) ==
mList->GetItemCount() )
1232 wxString oldParams =
params;
1255 long item =
mList->GetNextItem(-1,
1257 wxLIST_STATE_SELECTED);
1258 if (item == -1 || item + 1 ==
mList->GetItemCount()) {
1267 if (item >= (
mList->GetItemCount() - 2) && item >= 0) {
1277 long item =
mList->GetNextItem(-1,
1279 wxLIST_STATE_SELECTED);
1280 if (item == -1 || item == 0 || item + 1 ==
mList->GetItemCount()) {
1299 long item =
mList->GetNextItem(-1,
1301 wxLIST_STATE_SELECTED);
1302 if (item == -1 || item + 2 >=
mList->GetItemCount()) {
1377 if (event.GetKeyCode() == WXK_DELETE) {
1378 wxLogDebug(
wxT(
"wxKeyEvent"));
1406 &window, parent,
true
1419 switch (commandManager.mLastToolRegistration) {
1422 auto lastEffect = commandManager.mLastTool;
1423 if (!lastEffect.empty())
1426 lastEffect, context, commandManager.mRepeatToolFlags);
1432 commandManager.mLastToolRegisteredId);
1447 macrosWindow->Show();
1448 macrosWindow->Raise();
1460 macrosWindow->Show();
1461 macrosWindow->Raise();
1483#ifdef MACROS_BY_NUMBERS
1486 Name.Mid( Name.length() - 3 ).ToLong( &item, 10 );
1500 int cur = undoManager.GetCurrentState();
1501 if (undoManager.UndoAvailable()) {
1502 undoManager.GetShortDescription(cur, &
desc);
1503 commandManager.Modify(
wxT(
"RepeatLastTool"),
XXO(
"&Repeat %s")
1506 commandManager.mLastTool = Name;
1507 commandManager.mLastToolRegistration =
1532 if (commandManager.mLastToolRegistration ==
1535 return !commandManager.mLastTool.empty();
1545 static auto items = std::shared_ptr{
1553 if (!lastTool.empty())
1554 buildMenuLabel =
XO(
"Repeat %s")
1557 buildMenuLabel =
XO(
"Repeat Last Tool");
1559 return Command(
wxT(
"RepeatLastTool"), buildMenuLabel,
1581 auto result =
Items(
"");
1596 static auto menu = std::shared_ptr{
1598 Menu(
wxT(
"Scriptables1"),
XXO(
"Script&ables I") )
1604 wxT(
"Optional/Extra/Part2")
1610 static auto menu = std::shared_ptr{
1612 Menu(
wxT(
"Scriptables2"),
XXO(
"Scripta&bles II") )
1618 wxT(
"Optional/Extra/Part2")
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
AttachedItem sAttachment1
auto ExtraScriptablesIMenu()
AttachedItem sAttachment3
AttachedItem sAttachment2
auto ExtraScriptablesIIMenu()
#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")
static ProjectFileIORegistry::AttributeWriterEntry entry
audacity::BasicSettings * gPrefs
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
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)
void ModifyUndoMenuItems()
EffectManager is the class that handles effects and effect categories.
static EffectManager & Get()
TranslatableString GetCommandName(const PluginID &ID)
const PluginID & GetEffectByIdentifier(const CommandID &strTarget)
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
Entries::const_iterator ByTranslation(const wxString &translation) 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()
Generates classes whose instances register items at construction.
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)
void ZoomFitHorizontallyAndShowTrack(Track *pTrack)
static Viewport & 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'.
IMPORT_EXPORT_API 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.
void DoSelectAll(AudacityProject &project)
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)
AttachedWindows::RegisteredFactory sMacrosWindowKey
void PopulateMacrosMenu(MenuRegistry::MenuItems &items, CommandFlag flags)
const ReservedCommandFlag & HasLastToolFlag()
const TranslatableString desc
static CommandContext::TargetFactory::SubstituteInUnique< InteractiveOutputTargets > scope
Empty the clipboard at start of scope; restore its contents after.
auto push_back(Arg &&arg) -> std::enable_if_t< Traits< Base, Derived > ::template enables_item_type_v< Arg >, void >