Audacity 3.2.0
Public Types | Public Member Functions | Protected Attributes | Private Attributes | List of all members
AudacityCommand Class Referenceabstract

Base class for command in Audacity. More...

#include <AudacityCommand.h>

Inheritance diagram for AudacityCommand:
[legend]
Collaboration diagram for AudacityCommand:
[legend]

Public Types

enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 

Public Member Functions

 AudacityCommand ()
 
virtual ~AudacityCommand ()
 
PluginPath GetPath () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
ComponentInterfaceSymbol GetSymbol () const override=0
 
virtual TranslatableString GetDescription () const override
 
virtual ManualPageID ManualPage ()
 
virtual bool IsBatchProcessing () const
 
virtual void SetBatchProcessing (bool start)
 
virtual bool Apply (const CommandContext &WXUNUSED(context))
 
bool ShowInterface (wxWindow *parent, bool forceModal=false)
 
wxDialog * CreateUI (wxWindow *parent, AudacityCommand *client)
 
bool SaveSettingsAsString (wxString &parms)
 
bool LoadSettingsFromString (const wxString &parms)
 
bool DoAudacityCommand (wxWindow *parent, const CommandContext &context, bool shouldPrompt=true)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
virtual bool Init ()
 
virtual bool PromptUser (wxWindow *parent)
 
virtual bool CheckWhetherSkipAudacityCommand ()
 
virtual void End ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual bool TransferDataToWindow ()
 
virtual bool TransferDataFromWindow ()
 
virtual bool VisitSettings (SettingsVisitor &)
 
virtual bool VisitSettings (ConstSettingsVisitor &)
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 

Protected Attributes

ProgressDialogmProgress
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 

Private Attributes

bool mIsBatch
 
bool mNeedsInit
 

Detailed Description

Base class for command in Audacity.

Definition at line 39 of file AudacityCommand.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : long
Enumerator
DefaultMessageBoxStyle 

Definition at line 81 of file AudacityCommand.h.

81: long { DefaultMessageBoxStyle = wxOK | wxCENTRE };

Constructor & Destructor Documentation

◆ AudacityCommand()

AudacityCommand::AudacityCommand ( )

Definition at line 50 of file AudacityCommand.cpp.

51{
52 mProgress = NULL;
53 mUIParent = NULL;
54 mUIDialog = NULL;
55 mIsBatch = false;
56 mNeedsInit = true;
57}
wxDialog * mUIDialog
wxWindow * mUIParent
ProgressDialog * mProgress

References mIsBatch, mNeedsInit, mProgress, mUIDialog, and mUIParent.

◆ ~AudacityCommand()

AudacityCommand::~AudacityCommand ( )
virtual

Definition at line 59 of file AudacityCommand.cpp.

60{
61 if (mUIDialog)
62 mUIDialog->Close();
63}

References mUIDialog.

Member Function Documentation

◆ Apply()

virtual bool AudacityCommand::Apply ( const CommandContext WXUNUSEDcontext)
inlinevirtual

Definition at line 67 of file AudacityCommand.h.

67{ return false; }

Referenced by DoAudacityCommand().

Here is the caller graph for this function:

◆ CheckWhetherSkipAudacityCommand()

virtual bool AudacityCommand::CheckWhetherSkipAudacityCommand ( )
inlinevirtual

Definition at line 110 of file AudacityCommand.h.

110{ return false; }

Referenced by DoAudacityCommand().

Here is the caller graph for this function:

◆ CreateUI()

wxDialog * AudacityCommand::CreateUI ( wxWindow *  parent,
AudacityCommand client 
)

Definition at line 107 of file AudacityCommand.cpp.

108{
110 parent, GetName(), this}};
111
112 if (dlg->Init())
113 {
114 // release() is safe because parent will own it
115 return dlg.release();
116 }
117 return NULL;
118}
#define safenew
Definition: MemoryX.h:10
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:162
Default dialog used for commands. Is populated using ShuttleGui.
TranslatableString GetName() const

References ComponentInterface::GetName(), and safenew.

Referenced by ShowInterface().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoAudacityCommand()

bool AudacityCommand::DoAudacityCommand ( wxWindow *  parent,
const CommandContext context,
bool  shouldPrompt = true 
)

Definition at line 163 of file AudacityCommand.cpp.

166{
167 // Note: Init may read parameters from preferences
168 if (!Init())
169 {
170 return false;
171 }
172
173 // Prompting will be bypassed when applying a command that has already
174 // been configured, e.g. repeating the last effect on a different selection.
175 // Prompting may call AudacityCommand::Preview
176 if (shouldPrompt && /*IsInteractive() && */!PromptUser(parent))
177 {
178 return false;
179 }
180
181 auto cleanup = finally( [&] {
182 End();
183 } );
184
185 bool returnVal = true;
186 bool skipFlag = CheckWhetherSkipAudacityCommand();
187 if (skipFlag == false)
188 {
189 auto name = GetName();
190 ProgressDialog progress{
191 name,
192 XO("Applying %s...").Format( name ),
194 };
195 auto vr = valueRestorer( mProgress, &progress );
196
197 returnVal = Apply(context);
198 }
199 return returnVal;
200}
const TranslatableString name
Definition: Distortion.cpp:82
#define XO(s)
Definition: Internat.h:31
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Definition: MemoryX.h:234
@ pdlgHideStopButton
virtual bool Init()
virtual bool Apply(const CommandContext &WXUNUSED(context))
virtual bool PromptUser(wxWindow *parent)
virtual void End()
virtual bool CheckWhetherSkipAudacityCommand()
ProgressDialog Class.

References Apply(), CheckWhetherSkipAudacityCommand(), End(), ComponentInterface::GetName(), Init(), mProgress, name, pdlgHideStopButton, PromptUser(), valueRestorer(), and XO.

Referenced by EffectManager::DoAudacityCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ End()

virtual void AudacityCommand::End ( )
inlinevirtual

Definition at line 115 of file AudacityCommand.h.

115{;};

Referenced by DoAudacityCommand().

Here is the caller graph for this function:

◆ GetDescription()

virtual TranslatableString AudacityCommand::GetDescription ( ) const
inlineoverridevirtual

Implements ComponentInterface.

Reimplemented in CompareAudioCommand, DemoCommand, DragCommand, GetInfoCommand, GetTrackInfoCommand, HelpCommand, CommentCommand, ImportCommand, ExportCommand, MessageCommand, OpenProjectCommand, SaveProjectCommand, SaveCopyCommand, SaveLogCommand, ClearLogCommand, GetPreferenceCommand, SetPreferenceCommand, ScreenshotCommand, SelectTimeCommand, SelectFrequenciesCommand, SelectTracksCommand, SelectCommand, SetClipCommand, SetEnvelopeCommand, SetLabelCommand, SetProjectCommand, SetTrackStatusCommand, SetTrackAudioCommand, SetTrackVisualsCommand, and SetTrackCommand.

Definition at line 59 of file AudacityCommand.h.

60 {wxFAIL_MSG( "Implement a Description for this command");return XO("FAIL");};

References XO.

Referenced by EffectManager::GetCommandTip().

Here is the caller graph for this function:

◆ GetPath()

PluginPath AudacityCommand::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 66 of file AudacityCommand.cpp.

#define BUILTIN_GENERIC_COMMAND_PREFIX
ComponentInterfaceSymbol GetSymbol() const override=0
const wxString & Internal() const

References BUILTIN_GENERIC_COMMAND_PREFIX, GetSymbol(), and ComponentInterfaceSymbol::Internal().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol AudacityCommand::GetSymbol ( ) const
overridepure virtual

◆ GetVendor()

VendorSymbol AudacityCommand::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 67 of file AudacityCommand.cpp.

67{ return XO("Audacity");}

References XO.

◆ GetVersion()

wxString AudacityCommand::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 68 of file AudacityCommand.cpp.

68{ return AUDACITY_VERSION_STRING;}

◆ Init()

bool AudacityCommand::Init ( )
virtual

Definition at line 71 of file AudacityCommand.cpp.

71 {
72 if( !mNeedsInit )
73 return true;
74 mNeedsInit = false;
75 ShuttleDefaults DefaultSettingShuttle;
76 return VisitSettings( DefaultSettingShuttle );
77}
virtual bool VisitSettings(SettingsVisitor &)
SettingsVisitor that sets parameters to their default values.

References mNeedsInit, and VisitSettings().

Referenced by DoAudacityCommand(), EffectManager::GetAudacityCommand(), and EffectManager::SetEffectParameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsBatchProcessing()

virtual bool AudacityCommand::IsBatchProcessing ( ) const
inlinevirtual

Definition at line 64 of file AudacityCommand.h.

64{ return mIsBatch; }

Referenced by PromptUser().

Here is the caller graph for this function:

◆ LoadSettingsFromString()

bool AudacityCommand::LoadSettingsFromString ( const wxString &  parms)

Definition at line 138 of file AudacityCommand.cpp.

139{
140 wxString preset = parms;
141
142 CommandParameters eap(parms);
144
145 S.SetForWriting( &eap );
146 bool bResult = VisitSettings( S );
147 wxASSERT_MSG( bResult, "You did not define DefineParameters() for this command" );
148 static_cast<void>(bResult); // fix unused variable warning in release mode
149 if (!S.bOK)
150 {
152 XO(
153"%s: Could not load settings below. Default settings will be used.\n\n%s")
154 .Format( GetName(), preset ) );
155
156 // fror now always succeed, so that we can prompt the user.
157 return true;
158 }
159
160 return TransferDataToWindow();
161}
EffectReverbSettings preset
Definition: Reverb.cpp:46
#define S(N)
Definition: ToChars.cpp:64
virtual bool TransferDataToWindow()
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
Abstract base class used in importing a file.
SettingsVisitor that sets parameters to a value (from a string)

References ComponentInterface::GetName(), MessageBox(), preset, S, TransferDataToWindow(), VisitSettings(), and XO.

Referenced by EffectManager::SetEffectParameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ManualPage()

virtual ManualPageID AudacityCommand::ManualPage ( )
inlinevirtual

◆ MessageBox()

int AudacityCommand::MessageBox ( const TranslatableString message,
long  style = DefaultMessageBoxStyle,
const TranslatableString titleStr = {} 
)

Definition at line 232 of file AudacityCommand.cpp.

235{
236 auto title = titleStr.empty()
237 ? GetName()
238 : XO("%s: %s").Format( GetName(), titleStr );
239 return AudacityMessageBox(message, title, style, mUIParent);
240}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
static const auto title

References AudacityMessageBox(), TranslatableString::empty(), ComponentInterface::GetName(), mUIParent, title, and XO.

Referenced by LoadSettingsFromString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PopulateOrExchange()

virtual void AudacityCommand::PopulateOrExchange ( ShuttleGui WXUNUSEDS)
inlinevirtual

Definition at line 116 of file AudacityCommand.h.

116{return;};

Referenced by AudacityCommandDialog::PopulateOrExchange().

Here is the caller graph for this function:

◆ PromptUser()

bool AudacityCommand::PromptUser ( wxWindow *  parent)
virtual

Reimplemented in ClearLogCommand.

Definition at line 203 of file AudacityCommand.cpp.

204{
205 return ShowInterface(parent, IsBatchProcessing());
206}
virtual bool IsBatchProcessing() const
bool ShowInterface(wxWindow *parent, bool forceModal=false)

References IsBatchProcessing(), and ShowInterface().

Referenced by DoAudacityCommand(), and EffectManager::PromptUser().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveSettingsAsString()

bool AudacityCommand::SaveSettingsAsString ( wxString &  parms)

Definition at line 120 of file AudacityCommand.cpp.

121{
123
125 {
126 return false;
127 }
128
130 S.mpEap = &eap;
131 bool bResult = VisitSettings( S );
132 wxASSERT_MSG( bResult, "You did not define DefineParameters() for this command" );
133 static_cast<void>(bResult); // fix unused variable warning in release mode
134
135 return eap.GetParameters(parms);
136}
virtual bool TransferDataFromWindow()
bool GetParameters(wxString &parms)
SettingsVisitor that gets parameter values into a string.

References CommandParameters::GetParameters(), mUIDialog, S, TransferDataFromWindow(), and VisitSettings().

Referenced by EffectManager::GetEffectParameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetBatchProcessing()

virtual void AudacityCommand::SetBatchProcessing ( bool  start)
inlinevirtual

Definition at line 65 of file AudacityCommand.h.

65{ mIsBatch = start; }

◆ ShowInterface()

bool AudacityCommand::ShowInterface ( wxWindow *  parent,
bool  forceModal = false 
)

Definition at line 79 of file AudacityCommand.cpp.

80{
81 if (mUIDialog)
82 {
83 if ( mUIDialog->Close(true) )
84 mUIDialog = nullptr;
85 return false;
86 }
87
88 // mUIDialog is null
89 auto cleanup = valueRestorer( mUIDialog );
90
91 mUIDialog = CreateUI(parent, this);
92 if (!mUIDialog)
93 return false;
94
95 mUIDialog->Layout();
96 mUIDialog->Fit();
97 mUIDialog->SetMinSize(mUIDialog->GetSize());
98
99 // The Screenshot command might be popping this dialog up, just to capture it.
101 return false;
102
103 bool res = mUIDialog->ShowModal() != 0;
104 return res;
105}
wxDialog * CreateUI(wxWindow *parent, AudacityCommand *client)
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.

References GlobalHook< VetoDialogHook, bool(wxDialog *) >::Call(), CreateUI(), mUIDialog, and valueRestorer().

Referenced by PromptUser().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TransferDataFromWindow()

bool AudacityCommand::TransferDataFromWindow ( )
virtual

Definition at line 215 of file AudacityCommand.cpp.

216{
217 if (mUIParent && (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow()))
218 return false;
219 return true;
220}

References mUIParent.

Referenced by SaveSettingsAsString().

Here is the caller graph for this function:

◆ TransferDataToWindow()

bool AudacityCommand::TransferDataToWindow ( )
virtual

Definition at line 208 of file AudacityCommand.cpp.

209{
210 if (mUIParent && !mUIParent->TransferDataToWindow())
211 return false;
212 return true;
213}

References mUIParent.

Referenced by LoadSettingsFromString().

Here is the caller graph for this function:

◆ VisitSettings() [1/2]

bool AudacityCommand::VisitSettings ( ConstSettingsVisitor )
virtual

◆ VisitSettings() [2/2]

bool AudacityCommand::VisitSettings ( SettingsVisitor )
virtual

Member Data Documentation

◆ mIsBatch

bool AudacityCommand::mIsBatch
private

Definition at line 135 of file AudacityCommand.h.

Referenced by AudacityCommand().

◆ mNeedsInit

bool AudacityCommand::mNeedsInit
private

Definition at line 136 of file AudacityCommand.h.

Referenced by AudacityCommand(), and Init().

◆ mProgress

ProgressDialog* AudacityCommand::mProgress
protected

Definition at line 129 of file AudacityCommand.h.

Referenced by AudacityCommand(), and DoAudacityCommand().

◆ mUIDialog

wxDialog* AudacityCommand::mUIDialog
protected

◆ mUIParent

wxWindow* AudacityCommand::mUIParent
protected

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