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 38 of file AudacityCommand.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : long
Enumerator
DefaultMessageBoxStyle 

Definition at line 80 of file AudacityCommand.h.

80: long { DefaultMessageBoxStyle = wxOK | wxCENTRE };

Constructor & Destructor Documentation

◆ AudacityCommand()

AudacityCommand::AudacityCommand ( )

Definition at line 45 of file AudacityCommand.cpp.

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

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

◆ ~AudacityCommand()

AudacityCommand::~AudacityCommand ( )
virtual

Definition at line 54 of file AudacityCommand.cpp.

55{
56 if (mUIDialog)
57 mUIDialog->Close();
58}

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 109 of file AudacityCommand.h.

109{ return false; }

Referenced by DoAudacityCommand().

Here is the caller graph for this function:

◆ CreateUI()

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

Definition at line 98 of file AudacityCommand.cpp.

99{
101 parent, GetName(), this}};
102
103 if (dlg->Init())
104 {
105 // release() is safe because parent will own it
106 return dlg.release();
107 }
108 return NULL;
109}
#define safenew
Definition: MemoryX.h:9
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:163
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 154 of file AudacityCommand.cpp.

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

114{;};

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 EffectManager::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 61 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 62 of file AudacityCommand.cpp.

62{ return XO("Audacity");}

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString AudacityCommand::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 63 of file AudacityCommand.cpp.

63{ return AUDACITY_VERSION_STRING;}

◆ Init()

bool AudacityCommand::Init ( )
virtual

Definition at line 66 of file AudacityCommand.cpp.

66 {
67 if( !mNeedsInit )
68 return true;
69 mNeedsInit = false;
70 ShuttleDefaults DefaultSettingShuttle;
71 return VisitSettings( DefaultSettingShuttle );
72}
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 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 129 of file AudacityCommand.cpp.

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

226{
227 auto title = titleStr.empty()
228 ? GetName()
229 : XO("%s: %s").Format( GetName(), titleStr );
230 return AudacityMessageBox(message, title, style, mUIParent);
231}
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 115 of file AudacityCommand.h.

115{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 194 of file AudacityCommand.cpp.

195{
196 return ShowInterface(parent, IsBatchProcessing());
197}
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 111 of file AudacityCommand.cpp.

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

64{ mIsBatch = start; }

◆ ShowInterface()

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

Definition at line 74 of file AudacityCommand.cpp.

75{
76 if (mUIDialog)
77 {
78 if ( mUIDialog->Close(true) )
79 mUIDialog = nullptr;
80 return false;
81 }
82
83 // mUIDialog is null
84 auto cleanup = valueRestorer( mUIDialog );
85
86 mUIDialog = CreateUI(parent, this);
87 if (!mUIDialog)
88 return false;
89
90 mUIDialog->Layout();
91 mUIDialog->Fit();
92 mUIDialog->SetMinSize(mUIDialog->GetSize());
93
94 bool res = mUIDialog->ShowModal() != 0;
95 return res;
96}
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 206 of file AudacityCommand.cpp.

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

References mUIParent.

Referenced by SaveSettingsAsString().

Here is the caller graph for this function:

◆ TransferDataToWindow()

bool AudacityCommand::TransferDataToWindow ( )
virtual

Definition at line 199 of file AudacityCommand.cpp.

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

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

214{
215 return false;
216}

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

Here is the caller graph for this function:

Member Data Documentation

◆ mIsBatch

bool AudacityCommand::mIsBatch
private

Definition at line 134 of file AudacityCommand.h.

Referenced by AudacityCommand().

◆ mNeedsInit

bool AudacityCommand::mNeedsInit
private

Definition at line 135 of file AudacityCommand.h.

Referenced by AudacityCommand(), and Init().

◆ mProgress

ProgressDialog* AudacityCommand::mProgress
protected

Definition at line 128 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: