1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Remove Apply-Macro from Tools menu.

Done by giving Macros... dialog an Expand / Shrink button
so that we can use it as just an apply-to-projects dialog, if we want.
The dialog is modal, and can be kept open whilst we work.  So for example
we could put useful presets into it as macros.
This commit is contained in:
James Crook 2018-03-03 22:20:25 +00:00
parent fbef142fa5
commit 6f8d27208f
5 changed files with 89 additions and 37 deletions

View File

@ -59,6 +59,8 @@
#define CommandsListID 7002
#define ApplyToProjectID 7003
#define ApplyToFilesID 7004
#define ExpandID 7005
#define ShrinkID 7006
BEGIN_EVENT_TABLE(ApplyMacroDialog, wxDialogWrapper)
EVT_BUTTON(ApplyToProjectID, ApplyMacroDialog::OnApplyToProject)
@ -74,6 +76,7 @@ ApplyMacroDialog::ApplyMacroDialog(wxWindow * parent, bool bInherited):
{
//AudacityProject * p = GetActiveProject();
mAbort = false;
mbExpanded = false;
if( bInherited )
return;
SetLabel(_("Apply Macro")); // Provide visual label
@ -114,6 +117,13 @@ void ApplyMacroDialog::PopulateOrExchange(ShuttleGui &S)
{
/*i18n-hint: A macro is a sequence of commands that can be applied
* to one or more audio files.*/
S.StartHorizontalLay(wxALIGN_RIGHT, false);
{
S.Id(ExpandID).AddButton(_("&Expand"));
}
S.EndHorizontalLay();
S.StartStatic(_("&Select Macro"), true);
{
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
@ -244,7 +254,10 @@ void ApplyMacroDialog::ApplyMacroToProject( int iMacro, bool bHasGui )
Show();
return;
}
Hide();
if( mbExpanded )
Hide();
else
Show();
}
void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
@ -415,7 +428,10 @@ void ApplyMacroDialog::OnApplyToFiles(wxCommandEvent & WXUNUSED(event))
project->OnRemoveTracks(*project);
}
project->OnRemoveTracks(*project);
Hide();
if( mbExpanded )
Hide();
else
Show();
}
void ApplyMacroDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
@ -454,6 +470,9 @@ BEGIN_EVENT_TABLE(MacrosWindow, ApplyMacroDialog)
EVT_BUTTON(AddButtonID, MacrosWindow::OnAdd)
EVT_BUTTON(RemoveButtonID, MacrosWindow::OnRemove)
EVT_BUTTON(RenameButtonID, MacrosWindow::OnRename)
EVT_BUTTON(ExpandID, MacrosWindow::OnExpand)
EVT_BUTTON(ShrinkID, MacrosWindow::OnShrink)
EVT_SIZE(MacrosWindow::OnSize)
EVT_LIST_ITEM_ACTIVATED(CommandsListID, MacrosWindow::OnCommandActivated)
@ -540,33 +559,31 @@ void MacrosWindow::PopulateOrExchange(ShuttleGui & S)
{
S.StartHorizontalLay(wxEXPAND, 1);
{
S.StartStatic(_("&Macros"));
S.StartVerticalLay( wxEXPAND, 0 );
{
// JKC: Experimenting with an alternative way to get multiline
// translated strings to work correctly without very long lines.
// My appologies Alexandre if this way didn't work either.
//
// With this method:
// 1) it compiles fine under windows unicode and normal mode.
// 2) xgettext source code has handling for the trailing '\'
//
// It remains to see if linux and mac can cope and if xgettext
// actually does do fine with strings presented like this.
// If it doesn't work out, revert to all-on-one-line.
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_SINGLE_SEL |
wxLC_EDIT_LABELS);
mMacros = S.Id(MacrosListID).AddListControlReportMode();
// i18n-hint: This is the heading for a column in the edit macros dialog
mMacros->InsertColumn(0, _("Macro"), wxLIST_FORMAT_LEFT);
S.StartHorizontalLay(wxCENTER, false);
S.Prop(0).StartHorizontalLay(wxALIGN_RIGHT, false);
{
S.Id(AddButtonID).AddButton(_("&Add"));
mRemove = S.Id(RemoveButtonID).AddButton(_("&Remove"));
mRename = S.Id(RenameButtonID).AddButton(_("Re&name"));
S.Id(ShrinkID).AddButton(_("&Shrink"));
}
S.EndHorizontalLay();
S.StartStatic(_("&Macros"),1);
{
S.SetStyle(wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_SINGLE_SEL |
wxLC_EDIT_LABELS);
mMacros = S.Id(MacrosListID).Prop(1).AddListControlReportMode();
// i18n-hint: This is the heading for a column in the edit macros dialog
mMacros->InsertColumn(0, _("Macro"), wxLIST_FORMAT_LEFT);
S.StartHorizontalLay(wxCENTER, false);
{
S.Id(AddButtonID).AddButton(_("&Add"));
mRemove = S.Id(RemoveButtonID).AddButton(_("&Remove"));
mRename = S.Id(RenameButtonID).AddButton(_("Re&name"));
}
S.EndHorizontalLay();
}
S.EndStatic();
}
S.EndStatic();
S.EndVerticalLay();
S.StartVerticalLay( 1 );
{
@ -663,12 +680,31 @@ void MacrosWindow::UpdateMenus()
GetActiveProject()->RebuildMenuBar();
}
void MacrosWindow::UpdateDisplay( bool WXUNUSED(bExpanded) )
void MacrosWindow::UpdateDisplay( bool bExpanded )
{
//if(IsShown())
// DoUpdate();
if( bExpanded == mbExpanded )
return;
mbExpanded = bExpanded;
DestroyChildren();
SetSizer( nullptr );
mChanged = false;
mSelectedCommand = 0;
SetMinSize( wxSize( 200,200 ));
if( mbExpanded )
Populate();
else
ApplyMacroDialog::Populate();
}
void MacrosWindow::OnExpand(wxCommandEvent &WXUNUSED(event))
{ UpdateDisplay( true );}
void MacrosWindow::OnShrink(wxCommandEvent &WXUNUSED(event))
{ UpdateDisplay( false );}
bool MacrosWindow::ChangeOK()
{
if (mChanged) {
@ -1084,7 +1120,7 @@ void MacrosWindow::OnOK(wxCommandEvent & WXUNUSED(event))
}
///
void MacrosWindow::OnCancel(wxCommandEvent & event)
void MacrosWindow::OnCancel(wxCommandEvent &WXUNUSED(event))
{
if (!ChangeOK()) {
return;

View File

@ -53,7 +53,7 @@ class ApplyMacroDialog : public wxDialogWrapper {
virtual void OnCancel(wxCommandEvent & event);
virtual void OnHelp(wxCommandEvent & event);
virtual wxString GetHelpPageName() {return "Tools_Menu#chains_compact_dialog";};
virtual wxString GetHelpPageName() {return "Tools_Menu#macros_compact_dialog";};
void PopulateMacros();
void ApplyMacroToProject( int iMacro, bool bHasGui=true );
@ -68,6 +68,7 @@ class ApplyMacroDialog : public wxDialogWrapper {
wxButton *mCancel;
wxTextCtrl *mResults;
bool mAbort;
bool mbExpanded;
wxString mActiveMacro;
DECLARE_EVENT_TABLE()
@ -87,7 +88,9 @@ private:
void OnApplyToFiles(wxCommandEvent & event) override;
void OnCancel(wxCommandEvent &event) override;
virtual wxString GetHelpPageName() override {return "Tools_Menu#chains_full_dialog";};
virtual wxString GetHelpPageName() override {return
mbExpanded ? "Tools_Menu#macross_full_dialog"
: "Tools_Menu#macros_compact_dialog";};
void PopulateList();
void AddItem(const wxString &command, wxString const &params);
@ -101,6 +104,8 @@ private:
void OnAdd(wxCommandEvent &event);
void OnRemove(wxCommandEvent &event);
void OnRename(wxCommandEvent &event);
void OnExpand(wxCommandEvent &event);
void OnShrink(wxCommandEvent &event);
void OnSize(wxSizeEvent &event);
void OnCommandActivated(wxListEvent &event);
@ -133,7 +138,6 @@ private:
int mSelectedCommand;
bool mChanged;
bool mbExpanded;
using CommandName = std::tuple<wxString, wxString,wxString>;
using CommandNameVector = std::vector<CommandName>;

View File

@ -1189,12 +1189,13 @@ void AudacityProject::CreateMenusAndCommands()
#ifdef EXPERIMENTAL_EFFECT_MANAGEMENT
c->AddItem(wxT("ManageTools"), _("Add / Remove Plug-ins..."), FN(OnManageTools));
c->AddSeparator();
//c->AddSeparator();
#endif
c->AddItem(wxT("ApplyMacro"), _("Appl&y Macro..."), FN(OnApplyMacro),
AudioIONotBusyFlag,
AudioIONotBusyFlag);
//Not needed anymore as ManageMacros does both.
//c->AddItem(wxT("ApplyMacro"), _("Appl&y Macro..."), FN(OnApplyMacro),
// AudioIONotBusyFlag,
// AudioIONotBusyFlag);
c->AddItem(wxT("ManageMacros"), _("&Macros..."), FN(OnManageMacros));
c->AddSeparator();
@ -1713,8 +1714,8 @@ void AudacityProject::PopulateMacrosMenu( CommandManager* c, CommandFlag flags
for (i = 0; i < (int)names.GetCount(); i++) {
c->AddItem(wxString::Format("Macro%03i", i ), names[i], FN(OnApplyMacroDirectly),
AudioIONotBusyFlag,
AudioIONotBusyFlag);
flags,
flags);
}
}

View File

@ -993,6 +993,15 @@ void ShuttleGuiBase::StartVerticalLay(int iProp)
UpdateSizers();
}
void ShuttleGuiBase::StartVerticalLay(int PositionFlags, int iProp)
{
if( mShuttleMode != eIsCreating )
return;
miSizerProp=iProp;
mpSubSizer = std::make_unique<wxBoxSizer>( wxVERTICAL );
UpdateSizersCore( false, PositionFlags | wxALL );
}
void ShuttleGuiBase::EndVerticalLay()
{
if( mShuttleMode != eIsCreating )

View File

@ -119,6 +119,8 @@ public:
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1);
void EndHorizontalLay();
void StartVerticalLay(int iProp=1);
void StartVerticalLay(int PositionFlags, int iProp);
void EndVerticalLay();
wxScrolledWindow * StartScroller(int iStyle=0);
void EndScroller();