Audacity  2.3.1
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
MacroCommandDialog Class Referencefinal

Provides a list of configurable commands for use with MacroCommands. More...

#include <BatchCommandDialog.h>

Inheritance diagram for MacroCommandDialog:
wxDialogWrapper wxTabTraversalWrapper< wxDialog >

Public Member Functions

 MacroCommandDialog (wxWindow *parent, wxWindowID id)
 
void SetCommandAndParams (const wxString &Command, const wxString &Params)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=_("Dialog"))
 
- 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 Attributes

wxString mSelectedCommand
 
wxString mSelectedParameters
 

Private Member Functions

void Populate ()
 
void PopulateOrExchange (ShuttleGui &S)
 
void OnEditParams (wxCommandEvent &event)
 
void OnUsePreset (wxCommandEvent &event)
 
void OnChoice (wxCommandEvent &event)
 
void OnOk (wxCommandEvent &event)
 
void OnCancel (wxCommandEvent &event)
 
void OnHelp (wxCommandEvent &event)
 
void OnItemSelected (wxListEvent &event)
 
wxString GetHelpPageName ()
 
void ValidateChoices ()
 
void PopulateCommandList ()
 

Private Attributes

wxButton * mEditParams
 
wxButton * mUsePreset
 
wxListCtrl * mChoices
 
wxTextCtrl * mCommand
 
wxTextCtrl * mParameters
 
wxTextCtrl * mDetails
 
wxString mInternalCommandName
 
const MacroCommandsCatalog mCatalog
 

Detailed Description

Provides a list of configurable commands for use with MacroCommands.

Provides a list of commands, mostly effects, which can be chained together in a simple linear sequence. Can configure parameters on each selected command.

Definition at line 41 of file BatchCommandDialog.h.

Constructor & Destructor Documentation

MacroCommandDialog::MacroCommandDialog ( wxWindow *  parent,
wxWindowID  id 
)

Definition at line 61 of file BatchCommandDialog.cpp.

References _().

61  :
62  wxDialogWrapper(parent, id, _("Select Command"),
63  wxDefaultPosition, wxDefaultSize,
64  wxCAPTION | wxRESIZE_BORDER)
66 {
67  SetLabel(_("Select Command")); // Provide visual label
68  SetName(_("Select Command")); // Provide audible label
69  Populate();
70 }
const MacroCommandsCatalog mCatalog
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:311

Member Function Documentation

wxString MacroCommandDialog::GetHelpPageName ( )
inlineprivate

Definition at line 59 of file BatchCommandDialog.h.

Referenced by OnHelp().

59 { return wxT("Scripting Reference") ; }
void MacroCommandDialog::OnCancel ( wxCommandEvent &  event)
private

Definition at line 157 of file BatchCommandDialog.cpp.

158 {
159  EndModal(false);
160 }
void MacroCommandDialog::OnChoice ( wxCommandEvent &  event)
private

Definition at line 146 of file BatchCommandDialog.cpp.

147 {
148 }
void MacroCommandDialog::OnEditParams ( wxCommandEvent &  event)
private

Definition at line 199 of file BatchCommandDialog.cpp.

References mInternalCommandName, mParameters, params, and MacroCommands::PromptForParamsFor().

200 {
201  wxString command = mInternalCommandName;
202  wxString params = mParameters->GetValue();
203 
204  params = MacroCommands::PromptForParamsFor(command, params, this).Trim();
205 
206  mParameters->SetValue(params);
207  mParameters->Refresh();
208 }
static wxString PromptForParamsFor(const wxString &command, const wxString &params, wxWindow *parent)
wxTextCtrl * mParameters
EffectDistortion::Params params
Definition: Distortion.cpp:95
void MacroCommandDialog::OnHelp ( wxCommandEvent &  event)
private

Definition at line 162 of file BatchCommandDialog.cpp.

References GetHelpPageName(), and HelpSystem::ShowHelp().

163 {
164  wxString page = GetHelpPageName();
165  HelpSystem::ShowHelp(this, page, true);
166 }
static void ShowHelp(wxWindow *parent, const wxString &localFileName, const wxString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:194
void MacroCommandDialog::OnItemSelected ( wxListEvent &  event)
private

Definition at line 168 of file BatchCommandDialog.cpp.

References EffectManager::Get(), MacroCommands::GetCurrentParamsFor(), EffectManager::GetDefaultPreset(), EffectManager::GetEffectByIdentifier(), EffectManager::HasPresets(), mCatalog, mCommand, mDetails, mEditParams, mInternalCommandName, mParameters, mUsePreset, and params.

169 {
170  const auto &command = mCatalog[ event.GetIndex() ];
171 
173  PluginID ID = em.GetEffectByIdentifier( command.name.Internal() );
174 
175  // If ID is empty, then the effect wasn't found, in which case, the user must have
176  // selected one of the "special" commands.
177  mEditParams->Enable(!ID.IsEmpty());
178  mUsePreset->Enable(em.HasPresets(ID));
179 
180  if ( command.name.Translated() == mCommand->GetValue() )
181  // This uses the assumption of uniqueness of translated names!
182  return;
183 
184  mCommand->SetValue(command.name.Translated());
185  mInternalCommandName = command.name.Internal();
186 
188  if (params.IsEmpty())
189  {
190  params = em.GetDefaultPreset(ID);
191  }
192 
193  // Cryptic command and category.
194  // Later we can put help information there, perhaps.
195  mDetails->SetValue( mInternalCommandName + "\r\n" + command.category );
196  mParameters->SetValue(params);
197 }
const MacroCommandsCatalog mCatalog
bool HasPresets(const PluginID &ID)
wxString GetDefaultPreset(const PluginID &ID)
const PluginID & GetEffectByIdentifier(const wxString &strTarget)
wxString PluginID
Definition: Types.h:209
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:45
static EffectManager & Get()
wxTextCtrl * mParameters
EffectDistortion::Params params
Definition: Distortion.cpp:95
static wxString GetCurrentParamsFor(const wxString &command)
void MacroCommandDialog::OnOk ( wxCommandEvent &  event)
private

Definition at line 150 of file BatchCommandDialog.cpp.

References mInternalCommandName, mParameters, mSelectedCommand, and mSelectedParameters.

151 {
152  mSelectedCommand = mInternalCommandName.Strip(wxString::both);
153  mSelectedParameters = mParameters->GetValue().Strip(wxString::trailing);
154  EndModal(true);
155 }
wxTextCtrl * mParameters
void MacroCommandDialog::OnUsePreset ( wxCommandEvent &  event)
private

Definition at line 210 of file BatchCommandDialog.cpp.

References mInternalCommandName, mParameters, params, and MacroCommands::PromptForPresetFor().

211 {
212  wxString command = mInternalCommandName;
213  wxString params = mParameters->GetValue();
214 
215  wxString preset = MacroCommands::PromptForPresetFor(command, params, this).Trim();
216 
217  mParameters->SetValue(preset);
218  mParameters->Refresh();
219 }
static wxString PromptForPresetFor(const wxString &command, const wxString &params, wxWindow *parent)
wxTextCtrl * mParameters
EffectDistortion::Params params
Definition: Distortion.cpp:95
void MacroCommandDialog::Populate ( )
private

Definition at line 72 of file BatchCommandDialog.cpp.

References eIsCreating, and PopulateOrExchange().

73 {
74  //------------------------- Main section --------------------
75  ShuttleGui S(this, eIsCreating);
77  // ----------------------- End of main section --------------
78 }
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
void PopulateOrExchange(ShuttleGui &S)
void MacroCommandDialog::PopulateCommandList ( )
private

Definition at line 133 of file BatchCommandDialog.cpp.

References mCatalog, and mChoices.

Referenced by PopulateOrExchange().

134 {
135  mChoices->DeleteAllItems();
136  long ii = 0;
137  for ( const auto &entry : mCatalog )
138  // insert the user-facing string
139  mChoices->InsertItem( ii++, entry.name.Translated() );
140 }
const MacroCommandsCatalog mCatalog
void MacroCommandDialog::PopulateOrExchange ( ShuttleGui S)
private

Definition at line 80 of file BatchCommandDialog.cpp.

References _(), ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddListControl(), ShuttleGuiBase::AddPrompt(), ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddTextBox(), ShuttleGuiBase::AddTextWindow(), CommandsListID, eCancelButton, EditParamsButtonID, eHelpButton, ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndVerticalLay(), eOkButton, ShuttleGui::Id(), mChoices, mCommand, mDetails, mEditParams, mParameters, mUsePreset, PopulateCommandList(), ShuttleGui::Prop(), ShuttleGuiBase::SetStretchyCol(), ShuttleGuiBase::SetStyle(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::StartVerticalLay(), and UsePresetButtonID.

Referenced by Populate().

81 {
82  S.StartVerticalLay(true);
83  {
84  S.StartMultiColumn(4, wxEXPAND);
85  {
86  S.SetStretchyCol(1);
87  mCommand = S.AddTextBox(_("&Command"), wxT(""), 20);
88  mCommand->SetEditable(false);
89  mEditParams = S.Id(EditParamsButtonID).AddButton(_("&Edit Parameters"));
90  mEditParams->Enable(false); // disable button as box is empty
91  mUsePreset = S.Id(UsePresetButtonID).AddButton(_("&Use Preset"));
92  mUsePreset->Enable(false); // disable button as box is empty
93  }
94  S.EndMultiColumn();
95 
96  S.StartMultiColumn(2, wxEXPAND);
97  {
98  S.SetStretchyCol(1);
99  mParameters = S.AddTextBox(_("&Parameters"), wxT(""), 0);
100  mParameters->SetEditable(false);
101  wxString prompt{_("&Details")};
102  S.Prop(0).AddPrompt(prompt);
103  mDetails = S.AddTextWindow( wxT(""));
104  mDetails->SetEditable(false);
105  mDetails->SetName(wxStripMenuCodes(prompt));
106  }
107  S.EndMultiColumn();
108 
109  S.Prop(10).StartStatic(_("Choose command"), true);
110  {
111  S.SetStyle(wxSUNKEN_BORDER | wxLC_LIST | wxLC_SINGLE_SEL);
113  }
114  S.EndStatic();
115  }
116  S.EndVerticalLay();
117 
119 
121  if (mChoices->GetItemCount() > 0) {
122  // set first item to be selected (and the focus when the
123  // list first becomes the focus)
124  mChoices->SetItemState(0, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
125  wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
126  }
127 
128  SetMinSize(wxSize(780, 560));
129  Fit();
130  Center();
131 }
#define EditParamsButtonID
void EndMultiColumn()
wxListCtrl * AddListControl()
Definition: ShuttleGui.cpp:669
void AddPrompt(const wxString &Prompt)
Right aligned text string.
Definition: ShuttleGui.cpp:239
void EndVerticalLay()
wxTextCtrl * AddTextBox(const wxString &Caption, const wxString &Value, const int nChars)
Definition: ShuttleGui.cpp:548
#define CommandsListID
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
ShuttleGui & Id(int id)
void SetStyle(int Style)
Definition: ShuttleGui.h:287
#define UsePresetButtonID
wxTextCtrl * mParameters
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
wxTextCtrl * AddTextWindow(const wxString &Value)
Multiline text box that grows.
Definition: ShuttleGui.cpp:616
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:771
ShuttleGui & Prop(int iProp)
Definition: ShuttleGui.h:418
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxButton *extra=NULL)
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:349
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:203
void StartVerticalLay(int iProp=1)
void MacroCommandDialog::SetCommandAndParams ( const wxString &  Command,
const wxString &  Params 
)

Definition at line 221 of file BatchCommandDialog.cpp.

References MacroCommandsCatalog::begin(), MacroCommandsCatalog::ByCommandId(), MenuTable::Command(), MacroCommandsCatalog::end(), EffectManager::Get(), EffectManager::GetEffectByIdentifier(), EffectManager::HasPresets(), mCatalog, mChoices, mCommand, mDetails, mEditParams, mInternalCommandName, mParameters, and mUsePreset.

222 {
223  auto iter = mCatalog.ByCommandId( Command );
224 
225  mParameters->SetValue( Params );
226 
228  if (iter == mCatalog.end())
229  // Expose an internal name to the user in default of any friendly name
230  // -- AVOID THIS!
231  mCommand->SetValue( Command );
232  else {
233  mCommand->SetValue( iter->name.Translated() );
234  mDetails->SetValue( iter->name.Internal() + "\r\n" + iter->category );
235  mChoices->SetItemState(iter - mCatalog.begin(),
236  wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
237 
240 
241  // If ID is empty, then the effect wasn't found, in which case, the user must have
242  // selected one of the "special" commands.
243  mEditParams->Enable(!ID.IsEmpty());
244  mUsePreset->Enable(em.HasPresets(ID));
245  }
246 }
const MacroCommandsCatalog mCatalog
bool HasPresets(const PluginID &ID)
Entries::const_iterator begin() const
Definition: BatchCommands.h:43
const PluginID & GetEffectByIdentifier(const wxString &strTarget)
wxString PluginID
Definition: Types.h:209
std::unique_ptr< CommandItem > Command(const wxString &name, const wxString &label_in, bool hasDialog, CommandHandlerFinder finder, CommandFunctorPointer callback, CommandFlag flags, const CommandManager::Options &options={})
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:45
static EffectManager & Get()
wxTextCtrl * mParameters
Entries::const_iterator ByCommandId(const wxString &commandId) const
Entries::const_iterator end() const
Definition: BatchCommands.h:44
void MacroCommandDialog::ValidateChoices ( )
private

Definition at line 142 of file BatchCommandDialog.cpp.

143 {
144 }

Member Data Documentation

const MacroCommandsCatalog MacroCommandDialog::mCatalog
private

Definition at line 74 of file BatchCommandDialog.h.

Referenced by OnItemSelected(), PopulateCommandList(), and SetCommandAndParams().

wxListCtrl* MacroCommandDialog::mChoices
private
wxTextCtrl* MacroCommandDialog::mCommand
private

Definition at line 68 of file BatchCommandDialog.h.

Referenced by OnItemSelected(), PopulateOrExchange(), and SetCommandAndParams().

wxTextCtrl* MacroCommandDialog::mDetails
private

Definition at line 70 of file BatchCommandDialog.h.

Referenced by OnItemSelected(), PopulateOrExchange(), and SetCommandAndParams().

wxButton* MacroCommandDialog::mEditParams
private

Definition at line 65 of file BatchCommandDialog.h.

Referenced by OnItemSelected(), PopulateOrExchange(), and SetCommandAndParams().

wxString MacroCommandDialog::mInternalCommandName
private
wxTextCtrl* MacroCommandDialog::mParameters
private
wxString MacroCommandDialog::mSelectedCommand

Definition at line 47 of file BatchCommandDialog.h.

Referenced by MacrosWindow::InsertCommandAt(), and OnOk().

wxString MacroCommandDialog::mSelectedParameters

Definition at line 48 of file BatchCommandDialog.h.

Referenced by MacrosWindow::InsertCommandAt(), and OnOk().

wxButton* MacroCommandDialog::mUsePreset
private

Definition at line 66 of file BatchCommandDialog.h.

Referenced by OnItemSelected(), PopulateOrExchange(), and SetCommandAndParams().


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