Audacity  2.2.2
Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
BatchCommandDialog Class Referencefinal

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

#include <BatchCommandDialog.h>

Inheritance diagram for BatchCommandDialog:
wxDialogWrapper wxTabTraversalWrapper< wxDialog >

Public Member Functions

 BatchCommandDialog (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)
 

Public Attributes

wxString mSelectedCommand
 
wxString mSelectedParameters
 

Private Types

using CommandName = std::tuple< wxString, wxString, wxString >
 
using CommandNameVector = std::vector< CommandName >
 

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 OnItemSelected (wxListEvent &event)
 
void ValidateChoices ()
 
void PopulateCommandList ()
 

Private Attributes

wxButton * mEditParams
 
wxButton * mUsePreset
 
wxListCtrl * mChoices
 
wxTextCtrl * mCommand
 
wxTextCtrl * mParameters
 
wxTextCtrl * mDetails
 
wxString mInternalCommandName
 
CommandNameVector mCommandNames
 

Detailed Description

Provides a list of configurable commands for use with BatchCommands.

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 40 of file BatchCommandDialog.h.

Member Typedef Documentation

using BatchCommandDialog::CommandName = std::tuple<wxString, wxString,wxString>
private

Definition at line 71 of file BatchCommandDialog.h.

using BatchCommandDialog::CommandNameVector = std::vector<CommandName>
private

Definition at line 72 of file BatchCommandDialog.h.

Constructor & Destructor Documentation

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

Definition at line 59 of file BatchCommandDialog.cpp.

References _().

59  :
60  wxDialogWrapper(parent, id, _("Select Command"),
61  wxDefaultPosition, wxDefaultSize,
62  wxCAPTION | wxRESIZE_BORDER)
63 {
64  SetLabel(_("Select Command")); // Provide visual label
65  SetName(_("Select Command")); // Provide audible label
66  Populate();
67 }
_("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) void TrackMenuTable::OnSetName(wxCommandEvent &)

Member Function Documentation

void BatchCommandDialog::OnCancel ( wxCommandEvent &  event)
private

Definition at line 147 of file BatchCommandDialog.cpp.

148 {
149  EndModal(false);
150 }
void BatchCommandDialog::OnChoice ( wxCommandEvent &  event)
private

Definition at line 136 of file BatchCommandDialog.cpp.

137 {
138 }
void BatchCommandDialog::OnEditParams ( wxCommandEvent &  event)
private

Definition at line 182 of file BatchCommandDialog.cpp.

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

183 {
184  wxString command = mInternalCommandName;
185  wxString params = mParameters->GetValue();
186 
187  params = BatchCommands::PromptForParamsFor(command, params, this).Trim();
188 
189  mParameters->SetValue(params);
190  mParameters->Refresh();
191 }
static wxString PromptForParamsFor(const wxString &command, const wxString &params, wxWindow *parent)
wxTextCtrl * mParameters
EffectDistortion::Params params
Definition: Distortion.cpp:95
void BatchCommandDialog::OnItemSelected ( wxListEvent &  event)
private

Definition at line 152 of file BatchCommandDialog.cpp.

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

153 {
154  const auto &command = mCommandNames[ event.GetIndex() ];
155 
157  PluginID ID = em.GetEffectByIdentifier( std::get<1>( command ));
158 
159  // If ID is empty, then the effect wasn't found, in which case, the user must have
160  // selected one of the "special" commands.
161  mEditParams->Enable(!ID.IsEmpty());
162  mUsePreset->Enable(em.HasPresets(ID));
163 
164  if (std::get<0>( command ) == mCommand->GetValue())
165  return;
166 
167  mCommand->SetValue(std::get<0> (command));
168  mInternalCommandName = std::get<1>( command );
169 
171  if (params.IsEmpty())
172  {
173  params = em.GetDefaultPreset(ID);
174  }
175 
176  // Cryptic command and category.
177  // Later we can put help information there, perhaps.
178  mDetails->SetValue( mInternalCommandName + "\r\n" + std::get<2>(command) );
179  mParameters->SetValue(params);
180 }
bool HasPresets(const PluginID &ID)
wxString GetDefaultPreset(const PluginID &ID)
const PluginID & GetEffectByIdentifier(const wxString &strTarget)
wxString PluginID
Definition: Types.h:208
wxTextCtrl * mParameters
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:47
static EffectManager & Get()
CommandNameVector mCommandNames
EffectDistortion::Params params
Definition: Distortion.cpp:95
static wxString GetCurrentParamsFor(const wxString &command)
void BatchCommandDialog::OnOk ( wxCommandEvent &  event)
private

Definition at line 140 of file BatchCommandDialog.cpp.

References mInternalCommandName, mParameters, mSelectedCommand, and mSelectedParameters.

141 {
142  mSelectedCommand = mInternalCommandName.Strip(wxString::both);
143  mSelectedParameters = mParameters->GetValue().Strip(wxString::trailing);
144  EndModal(true);
145 }
wxTextCtrl * mParameters
void BatchCommandDialog::OnUsePreset ( wxCommandEvent &  event)
private

Definition at line 193 of file BatchCommandDialog.cpp.

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

194 {
195  wxString command = mInternalCommandName;
196  wxString params = mParameters->GetValue();
197 
198  wxString preset = BatchCommands::PromptForPresetFor(command, params, this).Trim();
199 
200  mParameters->SetValue(preset);
201  mParameters->Refresh();
202 }
static wxString PromptForPresetFor(const wxString &command, const wxString &params, wxWindow *parent)
wxTextCtrl * mParameters
EffectDistortion::Params params
Definition: Distortion.cpp:95
void BatchCommandDialog::Populate ( )
private

Definition at line 69 of file BatchCommandDialog.cpp.

References eIsCreating, and PopulateOrExchange().

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

Definition at line 122 of file BatchCommandDialog.cpp.

References BatchCommands::GetAllCommands(), mChoices, and mCommandNames.

Referenced by PopulateOrExchange().

123 {
125 
126  mChoices->DeleteAllItems();
127  for (size_t ii = 0, size = mCommandNames.size(); ii < size; ++ii)
128  // insert the user-facing string
129  mChoices->InsertItem( ii, std::get<0>( mCommandNames[ii] ) );
130 }
static CommandNameVector GetAllCommands()
CommandNameVector mCommandNames
void BatchCommandDialog::PopulateOrExchange ( ShuttleGui S)
private

Definition at line 77 of file BatchCommandDialog.cpp.

References _(), ShuttleGuiBase::AddButton(), ShuttleGuiBase::AddListControl(), ShuttleGuiBase::AddPrompt(), ShuttleGui::AddStandardButtons(), ShuttleGuiBase::AddTextBox(), ShuttleGuiBase::AddTextWindow(), CommandsListID, EditParamsButtonID, ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndStatic(), ShuttleGuiBase::EndVerticalLay(), 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().

78 {
79  S.StartVerticalLay(true);
80  {
81  S.StartMultiColumn(4, wxEXPAND);
82  {
83  S.SetStretchyCol(1);
84  mCommand = S.AddTextBox(_("&Command"), wxT(""), 20);
85  mCommand->SetEditable(false);
86  mEditParams = S.Id(EditParamsButtonID).AddButton(_("&Edit Parameters"));
87  mEditParams->Enable(false); // disable button as box is empty
88  mUsePreset = S.Id(UsePresetButtonID).AddButton(_("&Use Preset"));
89  mUsePreset->Enable(false); // disable button as box is empty
90  }
91  S.EndMultiColumn();
92 
93  S.StartMultiColumn(2, wxEXPAND);
94  {
95  S.SetStretchyCol(1);
96  mParameters = S.AddTextBox(_("&Parameters"), wxT(""), 0);
97  mParameters->SetEditable(false);
98  S.Prop(0).AddPrompt( _("&Details" ) );
99  mDetails = S.AddTextWindow( wxT(""));
100  mDetails->SetEditable(false);
101  }
102  S.EndMultiColumn();
103 
104  S.Prop(10).StartStatic(_("C&hoose command"), true);
105  {
106  S.SetStyle(wxSUNKEN_BORDER | wxLC_LIST | wxLC_SINGLE_SEL);
108  }
109  S.EndStatic();
110  }
111  S.EndVerticalLay();
112 
113  S.AddStandardButtons();
114 
116 
117  SetMinSize(wxSize(780, 560));
118  Fit();
119  Center();
120 }
#define EditParamsButtonID
void EndMultiColumn()
wxListCtrl * AddListControl()
Definition: ShuttleGui.cpp:604
wxTextCtrl * mParameters
void AddPrompt(const wxString &Prompt)
Right aligned text string.
Definition: ShuttleGui.cpp:220
void EndVerticalLay()
Definition: ShuttleGui.cpp:996
wxTextCtrl * AddTextBox(const wxString &Caption, const wxString &Value, const int nChars)
Definition: ShuttleGui.cpp:498
#define CommandsListID
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
ShuttleGui & Id(int id)
void SetStyle(int Style)
Definition: ShuttleGui.h:257
#define UsePresetButtonID
wxTextCtrl * AddTextWindow(const wxString &Value)
Multiline text box that grows.
Definition: ShuttleGui.cpp:556
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:706
_("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) void TrackMenuTable::OnSetName(wxCommandEvent &)
ShuttleGui & Prop(int iProp)
Definition: ShuttleGui.h:380
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxButton *extra=NULL)
wxButton * AddButton(const wxString &Text, int PositionFlags=wxALIGN_CENTRE)
Definition: ShuttleGui.cpp:306
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:197
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:987
void BatchCommandDialog::SetCommandAndParams ( const wxString &  Command,
const wxString &  Params 
)

Definition at line 204 of file BatchCommandDialog.cpp.

References EffectManager::Get(), EffectManager::GetEffectByIdentifier(), EffectManager::HasPresets(), make_iterator_range(), mChoices, mCommand, mCommandNames, mDetails, mEditParams, mInternalCommandName, mParameters, mUsePreset, and name.

205 {
206  auto item = make_iterator_range(mCommandNames).index_if(
207  [&](const CommandName &name){ return Command == std::get<1>( name); }
208  );
209 
210  mParameters->SetValue( Params );
211 
212  mInternalCommandName = Command;
213  if (item < 0)
214  mCommand->SetValue( Command );
215  else {
216  mCommand->SetValue( std::get<0>( mCommandNames[item]) );
217  mDetails->SetValue( std::get<1>(mCommandNames[item]) + "\r\n" + std::get<2>(mCommandNames[item]) );
218  mChoices->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
219 
221  PluginID ID = em.GetEffectByIdentifier(Command);
222 
223  // If ID is empty, then the effect wasn't found, in which case, the user must have
224  // selected one of the "special" commands.
225  mEditParams->Enable(!ID.IsEmpty());
226  mUsePreset->Enable(em.HasPresets(ID));
227  }
228 }
bool HasPresets(const PluginID &ID)
const PluginID & GetEffectByIdentifier(const wxString &strTarget)
wxString PluginID
Definition: Types.h:208
wxTextCtrl * mParameters
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:1064
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:47
static EffectManager & Get()
std::tuple< wxString, wxString, wxString > CommandName
const wxChar * name
Definition: Distortion.cpp:94
CommandNameVector mCommandNames
void BatchCommandDialog::ValidateChoices ( )
private

Definition at line 132 of file BatchCommandDialog.cpp.

133 {
134 }

Member Data Documentation

wxListCtrl* BatchCommandDialog::mChoices
private
wxTextCtrl* BatchCommandDialog::mCommand
private

Definition at line 65 of file BatchCommandDialog.h.

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

CommandNameVector BatchCommandDialog::mCommandNames
private

Definition at line 73 of file BatchCommandDialog.h.

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

wxTextCtrl* BatchCommandDialog::mDetails
private

Definition at line 67 of file BatchCommandDialog.h.

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

wxButton* BatchCommandDialog::mEditParams
private

Definition at line 62 of file BatchCommandDialog.h.

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

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

Definition at line 46 of file BatchCommandDialog.h.

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

wxString BatchCommandDialog::mSelectedParameters

Definition at line 47 of file BatchCommandDialog.h.

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

wxButton* BatchCommandDialog::mUsePreset
private

Definition at line 63 of file BatchCommandDialog.h.

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


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