22 #include <wx/ownerdrw.h>
26#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>
54#include "../images/Arrow.xpm"
55#include "../images/Empty9x16.xpm"
68#if wxUSE_ACCESSIBILITY
72#define MacrosPaletteTitle XO("Macros Palette")
73#define ManageMacrosTitle XO("Manage Macros")
78#define MacrosListID 7001
79#define CommandsListID 7002
80#define ApplyToProjectID 7003
81#define ApplyToFilesID 7004
96 wxDefaultPosition, wxDefaultSize,
97 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
129 wxSize sz = GetSize();
133 SetSize(
std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4, sz.GetWidth()),
134 std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5, 400));
140 mMacros->SetColumnWidth(0, sz.x);
148 S.StartStatic(
XO(
"Select Macro"), 1);
151 .Style( wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
154 .AddListControlReportMode( {
XO(
"Macro") } );
158 S.StartHorizontalLay(wxEXPAND, 0);
160 S.AddPrompt(
XXO(
"Apply Macro to:") );
162 .Name(
XO(
"Apply macro to project"))
163 .AddButton(
XXO(
"&Project"));
164#if wxUSE_ACCESSIBILITY
170 .Name(
XO(
"Apply macro to files..."))
171 .AddButton(
XXO(
"&Files..."));
172#if wxUSE_ACCESSIBILITY
177 S.EndHorizontalLay();
179 S.StartHorizontalLay(wxEXPAND, 0);
183 S.AddSpace( 10,10,1 );
186 S.EndHorizontalLay();
197 int topItem =
mMacros->GetTopItem();
199 for (i = 0; i < (int)
names.size(); i++) {
204 bool bFound = item >=0;
211 mMacros->SetItemState(item, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
212 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
214 if( 0 <= topItem && topItem < (
int)
mMacros->GetItemCount())
219 mMacros->EnsureVisible( topItem );
222 mMacros->EnsureVisible( item );
234 long item =
mMacros->GetNextItem(-1,
236 wxLIST_STATE_SELECTED);
247 wxString Temp = MacroName;
248 Temp.Replace(
" ",
"");
249 Temp = wxString(
"Macro_" ) + Temp;
257 for(
int i=0;i<
mMacros->GetItemCount();i++){
273#ifdef OPTIONAL_ACTIVITY_WINDOW
278 S.StartHorizontalLay(wxCENTER,
false);
280 S.StartStatic( {},
false);
283 S.AddFixedText(
XO(
"Applying '%s' to current project")
288 S.EndHorizontalLay();
290 activityWin.Layout();
292 activityWin.CenterOnScreen();
295 activityWin.GetPosition( &x, &y );
296 activityWin.Move(wxMax(0,x-300), 0);
317#ifdef OPTIONAL_ACTIVITY_WINDOW
318 wxWindowDisabler wd(&activityWin);
320 success = GuardedCall< bool >(
333 long item =
mMacros->GetNextItem(-1,
335 wxLIST_STATE_SELECTED);
348 XO(
"Please save and close the current project first.") );
356 auto prompt =
XO(
"Select file(s) for batch processing...");
366 wxFD_OPEN | wxFD_MULTIPLE | wxRESIZE_BORDER);
381 wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER
386 wxListCtrl * fileList = NULL;
388 S.StartVerticalLay(1);
390 S.StartStatic(
XO(
"Applying..."), 1);
392 auto imageList = std::make_unique<wxImageList>(9, 16);
393 imageList->Add(wxIcon(empty9x16_xpm));
394 imageList->Add(wxIcon(arrow_xpm));
397 .Style( wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
399 .AddListControlReportMode( {
XO(
"File") } );
401 fileList->AssignImageList(imageList.release(), wxIMAGE_LIST_SMALL);
405 S.StartHorizontalLay(wxCENTER, 0);
407 S.Id(wxID_CANCEL).AddButton(
XXO(
"&Cancel"));
409 S.EndHorizontalLay();
414 for (i = 0; i < (int)files.size(); i++ ) {
415 fileList->InsertItem(i, files[i], i == 0);
419 fileList->SetColumnWidth(0, wxLIST_AUTOSIZE);
421 int width = wxMin( fileList->GetColumnWidth(0), 1000);
422 wxSize sz = fileList->GetClientSize();
423 if (sz.GetWidth() < width ) {
425 if (sz.GetHeight() < width *0.7)
426 sz.SetHeight(width * 0.7);
427 fileList->SetInitialSize(sz);
430 activityWin.Layout();
432 activityWin.CenterOnScreen();
435 activityWin.GetPosition( &x, &y );
436 activityWin.Move(wxMax(0,x-300), 0);
452 if (globalClipboard.Project().lock().get() ==
project)
453 globalClipboard.Clear();
458 wxWindowDisabler wd(&activityWin);
459 for (i = 0; i < (int)files.size(); i++) {
462 fileList->SetItemImage(i - 1, 0, 0);
464 fileList->SetItemImage(i, 1, 1);
465 fileList->EnsureVisible(i);
467 auto success = GuardedCall<bool>([&] {
474 if (!activityWin.IsShown() ||
mAbort)
485 globalClipboard.Clear();
502#include <wx/textdlg.h>
610 SetSizeHints(GetSize());
613 SetSize(
std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_X) * 3 / 4, 800),
614 std::min(wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) * 4 / 5, 400));
618 wxSize sz =
mMacros->GetClientSize();
619 mMacros->SetColumnWidth(0, sz.x);
628 S.StartHorizontalLay(wxEXPAND, 1);
630 S.StartStatic(
XO(
"Select Macro"),0);
632 S.StartHorizontalLay(wxEXPAND,1);
635 .Style( wxLC_REPORT | wxLC_HRULES
636 | wxLC_SINGLE_SEL | wxLC_EDIT_LABELS)
638 .AddListControlReportMode( {
XO(
"Macro") } );
639 S.StartVerticalLay(wxALIGN_TOP, 0);
650 S.EndHorizontalLay();
654 S.StartStatic(
XO(
"Edit Steps"),
true);
656 S.StartHorizontalLay(wxEXPAND,1);
659 .Style( wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
661 .AddListControlReportMode({
663 {
XO(
"Num"), wxLIST_FORMAT_RIGHT },
664 {
XO(
"Command "), wxLIST_FORMAT_RIGHT },
665 {
XO(
"Parameters"), wxLIST_FORMAT_LEFT }
668 S.StartVerticalLay(wxALIGN_TOP, 0);
680 S.EndHorizontalLay();
684 S.EndHorizontalLay();
686 S.StartHorizontalLay(wxEXPAND, 0);
691 S.Prop(0).AddVariableText(
692 XO(
"Apply Macro to:"),
false, wxALL | wxALIGN_CENTRE_VERTICAL );
694 .Name(
XO(
"Apply macro to project"))
695 .AddButton(
XXO(
"&Project"));
696#if wxUSE_ACCESSIBILITY
702 .Name(
XO(
"Apply macro to files..."))
703 .AddButton(
XXO(
"&Files..."));
704#if wxUSE_ACCESSIBILITY
708 S.AddSpace( 10,10,1 );
717 S.EndHorizontalLay();
726 int topItem =
mList->GetTopItem();
727 mList->DeleteAllItems();
741 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
742 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
743 if( 0 <= topItem && topItem < (
int)
mList->GetItemCount())
747 mList->EnsureVisible( (
int)
mList->GetItemCount() -1 );
748 mList->EnsureVisible( topItem );
761 ?
entry->name.StrippedTranslation()
767 int i =
mList->GetItemCount();
769 mList->InsertItem(i, wxString::Format(
wxT(
" %02i"), i + 1));
800 SetMinSize( wxSize( 200,200 ));
807 wxPoint p = GetPosition( );
837 auto msg =
XO(
"Do you want to save the changes?");
842 wxYES_NO | wxCANCEL);
843 if (
id == wxCANCEL) {
867 int item =
event.GetIndex();
903 mEdit->Enable(!ID.empty());
923#if defined(__WXMAC__)
927 for (
size_t c = 0; c <
mList->GetColumnCount(); c++) {
931 mList->SetColumnWidth(c, wxLIST_AUTOSIZE);
934 info.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH);
935 mList->GetColumn(c, info);
937 mList->GetTextExtent(info.GetText(), &width, NULL);
941 mList->SetColumnWidth(c, wxMax(width,
mList->GetColumnWidth(c)));
949 mList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
950 mList->SetColumnWidth(1, wxLIST_AUTOSIZE_USEHEADER);
951 mList->SetColumnWidth(2, wxLIST_AUTOSIZE);
954 int bestfit =
mList->GetColumnWidth(2);
955 int clientsize =
mList->GetClientSize().GetWidth();
956 int col0 =
mList->GetColumnWidth(0);
957 int col1 =
mList->GetColumnWidth(1);
958 bestfit = (bestfit > clientsize-col0-col1)? bestfit : clientsize-col0-col1;
959 mList->SetColumnWidth(2, bestfit);
966 int itemNo =
event.GetIndex();
968 wxString macro =
mMacros->GetItemText(itemNo);
981 if (event.IsEditCancelled()) {
989 wxString newname =
event.GetLabel();
1010 XO(
"Enter name of new macro"),
1011 XO(
"Name of new macro"));
1012 d.SetName(d.GetTitle());
1015 if (d.ShowModal() == wxID_CANCEL) {
1021 name = d.GetValue().Strip(wxString::both);
1023 if (
name.length() == 0) {
1025 XO(
"Name must not be blank"),
1027 wxOK | wxICON_ERROR,
1032 if (
name.Contains(wxFILE_SEP_PATH) ||
1033 name.Contains(wxFILE_SEP_PATH_UNIX)) {
1036 XO(
"Names may not contain '%c' and '%c'")
1037 .
Format(wxFILE_SEP_PATH, wxFILE_SEP_PATH_UNIX),
1039 wxOK | wxICON_ERROR,
1058 long item =
mMacros->GetNextItem(-1,
1060 wxLIST_STATE_SELECTED);
1069 XO(
"Are you sure you want to delete %s?").
Format(
name ),
1071 wxYES_NO | wxICON_QUESTION );
1072 if (m.ShowModal() == wxID_NO) {
1081 if (item >= (
mMacros->GetItemCount() - 1) && item >= 0) {
1099 long item =
mMacros->GetNextItem(-1,
1101 wxLIST_STATE_SELECTED);
1128 long item =
mMacros->GetNextItem(-1,
1130 wxLIST_STATE_SELECTED);
1138 if (
name == wxEmptyString) {
1151 long item =
mMacros->GetNextItem(-1,
1153 wxLIST_STATE_SELECTED);
1171 wxCommandEvent dummy;
1178 long item =
mList->GetNextItem(-1,
1180 wxLIST_STATE_SELECTED);
1182 item =
mList->GetItemCount()-1;
1195 if (!d.ShowModal()) {
1217 int item =
mList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
1224 int lastItem =
mList->GetItemCount()-1;
1225 if( (item<0) || (item+1) ==
mList->GetItemCount() )
1234 wxString oldParams =
params;
1257 long item =
mList->GetNextItem(-1,
1259 wxLIST_STATE_SELECTED);
1260 if (item == -1 || item + 1 ==
mList->GetItemCount()) {
1269 if (item >= (
mList->GetItemCount() - 2) && item >= 0) {
1279 long item =
mList->GetNextItem(-1,
1281 wxLIST_STATE_SELECTED);
1282 if (item == -1 || item == 0 || item + 1 ==
mList->GetItemCount()) {
1301 long item =
mList->GetNextItem(-1,
1303 wxLIST_STATE_SELECTED);
1304 if (item == -1 || item + 2 >=
mList->GetItemCount()) {
1379 if (event.GetKeyCode() == WXK_DELETE) {
1380 wxLogDebug(
wxT(
"wxKeyEvent"));
1407 &window, parent,
true
1420 switch (commandManager.mLastToolRegistration) {
1423 auto lastEffect = commandManager.mLastTool;
1424 if (!lastEffect.empty())
1426 lastEffect, context.
project, commandManager.mRepeatToolFlags);
1431 commandManager.mLastToolRegisteredId);
1446 macrosWindow->Show();
1447 macrosWindow->Raise();
1459 macrosWindow->Show();
1460 macrosWindow->Raise();
1482#ifdef MACROS_BY_NUMBERS
1485 Name.Mid( Name.length() - 3 ).ToLong( &item, 10 );
1498 int cur = undoManager.GetCurrentState();
1499 if (undoManager.UndoAvailable()) {
1500 undoManager.GetShortDescription(cur, &
desc);
1501 commandManager.Modify(
wxT(
"RepeatLastTool"),
XXO(
"&Repeat %s")
1504 commandManager.mLastTool = Name;
1505 commandManager.mLastToolRegistration =
1530 if (commandManager.mLastToolRegistration ==
1533 return !commandManager.mLastTool.empty();
1543 static auto items = std::shared_ptr{
1551 if (!lastTool.empty())
1556 buildMenuLabel =
XO(
"Repeat Last Tool");
1558 return Command(
wxT(
"RepeatLastTool"), buildMenuLabel,
1580 auto result =
Items(
"");
1595 static auto menu = std::shared_ptr{
1597 Menu(
wxT(
"Scriptables1"),
XXO(
"Script&ables I") )
1603 wxT(
"Optional/Extra/Part2")
1609 static auto menu = std::shared_ptr{
1611 Menu(
wxT(
"Scriptables2"),
XXO(
"Scripta&bles II") )
1617 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
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()
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
static wxString PromptForParamsFor(const CommandID &command, const wxString ¶ms, AudacityProject &project)
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={})
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)
TranslatableString GetName(const PluginID &ID) const
const PluginID & GetByCommandIdentifier(const CommandID &strTarget)
static PluginManager & Get()
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
bool DoEffect(const PluginID &ID, AudacityProject &project, unsigned flags)
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 >