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 (const CommandContext &context, bool shouldPrompt=true)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
virtual bool Init ()
 
virtual bool PromptUser (AudacityProject &)
 
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 37 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 47 of file AudacityCommand.cpp.

48{
49 mProgress = NULL;
50 mUIParent = NULL;
51 mUIDialog = NULL;
52 mIsBatch = false;
53 mNeedsInit = true;
54}
wxDialog * mUIDialog
wxWindow * mUIParent
ProgressDialog * mProgress

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

◆ ~AudacityCommand()

AudacityCommand::~AudacityCommand ( )
virtual

Definition at line 56 of file AudacityCommand.cpp.

57{
58 if (mUIDialog)
59 mUIDialog->Close();
60}

References mUIDialog.

Member Function Documentation

◆ Apply()

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

Definition at line 66 of file AudacityCommand.h.

66{ 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 100 of file AudacityCommand.cpp.

101{
103 parent, GetName(), this}};
104
105 if (dlg->Init())
106 {
107 // release() is safe because parent will own it
108 return dlg.release();
109 }
110 return NULL;
111}
#define safenew
Definition: MemoryX.h:10
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:164
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 ( const CommandContext context,
bool  shouldPrompt = true 
)

Definition at line 156 of file AudacityCommand.cpp.

158{
159 // Note: Init may read parameters from preferences
160 if (!Init())
161 {
162 return false;
163 }
164
165 // Prompting will be bypassed when applying a command that has already
166 // been configured, e.g. repeating the last effect on a different selection.
167 // Prompting may call AudacityCommand::Preview
168 if (shouldPrompt && /*IsInteractive() && */!PromptUser(context.project))
169 {
170 return false;
171 }
172
173 auto cleanup = finally( [&] {
174 End();
175 } );
176
177 bool returnVal = true;
178 bool skipFlag = CheckWhetherSkipAudacityCommand();
179 if (skipFlag == false)
180 {
181 auto name = GetName();
182 ProgressDialog progress{
183 name,
184 XO("Applying %s...").Format( name ),
186 };
187 auto vr = valueRestorer( mProgress, &progress );
188
189 returnVal = Apply(context);
190 }
191 return returnVal;
192}
XO("Cut/Copy/Paste")
ValueRestorer< T > valueRestorer(T &var)
inline functions provide convenient parameter type deduction
Definition: MemoryX.h:253
@ pdlgHideStopButton
wxString name
Definition: TagsEditor.cpp:166
virtual bool Init()
virtual bool Apply(const CommandContext &WXUNUSED(context))
virtual void End()
virtual bool PromptUser(AudacityProject &)
virtual bool CheckWhetherSkipAudacityCommand()
AudacityProject & project
ProgressDialog Class.

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

Referenced by EffectAndCommandPluginManager::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, SelectTimeCommand, SelectFrequenciesCommand, SelectTracksCommand, SelectCommand, SetClipCommand, SetEnvelopeCommand, SetLabelCommand, SetProjectCommand, SetTrackStatusCommand, SetTrackAudioCommand, SetTrackVisualsCommand, and SetTrackCommand.

Definition at line 58 of file AudacityCommand.h.

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

References XO().

Referenced by EffectAndCommandPluginManager::GetCommandTip().

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

◆ GetPath()

PluginPath AudacityCommand::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 63 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 64 of file AudacityCommand.cpp.

64{ return XO("Audacity");}

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString AudacityCommand::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 65 of file AudacityCommand.cpp.

65{ return AUDACITY_VERSION_STRING;}

◆ Init()

bool AudacityCommand::Init ( )
virtual

Definition at line 68 of file AudacityCommand.cpp.

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

References mNeedsInit, and VisitSettings().

Referenced by DoAudacityCommand(), EffectAndCommandPluginManager::GetAudacityCommand(), and EffectAndCommandPluginManager::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 63 of file AudacityCommand.h.

63{ return mIsBatch; }

Referenced by PromptUser().

Here is the caller graph for this function:

◆ LoadSettingsFromString()

bool AudacityCommand::LoadSettingsFromString ( const wxString &  parms)

Definition at line 131 of file AudacityCommand.cpp.

132{
133 wxString preset = parms;
134
135 CommandParameters eap(parms);
137
138 S.SetForWriting( &eap );
139 bool bResult = VisitSettings( S );
140 wxASSERT_MSG( bResult, "You did not define DefineParameters() for this command" );
141 static_cast<void>(bResult); // fix unused variable warning in release mode
142 if (!S.bOK)
143 {
145 XO(
146"%s: Could not load settings below. Default settings will be used.\n\n%s")
147 .Format( GetName(), preset ) );
148
149 // fror now always succeed, so that we can prompt the user.
150 return true;
151 }
152
153 return TransferDataToWindow();
154}
ReverbSettings preset
Definition: ReverbBase.cpp:25
#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 EffectAndCommandPluginManager::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 224 of file AudacityCommand.cpp.

227{
228 auto title = titleStr.empty()
229 ? GetName()
230 : XO("%s: %s").Format( GetName(), titleStr );
231 return AudacityMessageBox(message, title, style, mUIParent);
232}
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, anonymous_namespace{AudacityDontAskAgainMessageDialog.cpp}::style, 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 ( AudacityProject project)
virtual

Reimplemented in ClearLogCommand.

Definition at line 195 of file AudacityCommand.cpp.

196{
198}
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 ...
const auto project
virtual bool IsBatchProcessing() const
bool ShowInterface(wxWindow *parent, bool forceModal=false)

References GetProjectFrame(), IsBatchProcessing(), project, and ShowInterface().

Referenced by DoAudacityCommand(), and EffectAndCommandPluginManager::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 113 of file AudacityCommand.cpp.

114{
116
118 {
119 return false;
120 }
121
123 S.mpEap = &eap;
124 bool bResult = VisitSettings( S );
125 wxASSERT_MSG( bResult, "You did not define DefineParameters() for this command" );
126 static_cast<void>(bResult); // fix unused variable warning in release mode
127
128 return eap.GetParameters(parms);
129}
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 EffectAndCommandPluginManager::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 64 of file AudacityCommand.h.

64{ mIsBatch = start; }

◆ ShowInterface()

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

Definition at line 76 of file AudacityCommand.cpp.

77{
78 if (mUIDialog)
79 {
80 if ( mUIDialog->Close(true) )
81 mUIDialog = nullptr;
82 return false;
83 }
84
85 // mUIDialog is null
86 auto cleanup = valueRestorer( mUIDialog );
87
88 mUIDialog = CreateUI(parent, this);
89 if (!mUIDialog)
90 return false;
91
92 mUIDialog->Layout();
93 mUIDialog->Fit();
94 mUIDialog->SetMinSize(mUIDialog->GetSize());
95
96 bool res = mUIDialog->ShowModal() != 0;
97 return res;
98}
wxDialog * CreateUI(wxWindow *parent, AudacityCommand *client)

References 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 207 of file AudacityCommand.cpp.

208{
209 if (mUIParent && (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow()))
210 return false;
211 return true;
212}

References mUIParent.

Referenced by SaveSettingsAsString().

Here is the caller graph for this function:

◆ TransferDataToWindow()

bool AudacityCommand::TransferDataToWindow ( )
virtual

Definition at line 200 of file AudacityCommand.cpp.

201{
202 if (mUIParent && !mUIParent->TransferDataToWindow())
203 return false;
204 return true;
205}

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

Visit settings, if defined. false means no defined settings. Default implementation returns false

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

Definition at line 214 of file AudacityCommand.cpp.

215{
216 return false;
217}

Referenced by EffectAndCommandPluginManager::GetCommandDefinition(), Init(), LoadSettingsFromString(), and SaveSettingsAsString().

Here is the caller graph for this function:

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: