Move ShuttleGetDefinition to its own files...
... so Shuttle need not include CommandTargets.h
This commit is contained in:
parent
2faa24c96b
commit
78a1263163
123
src/Shuttle.cpp
123
src/Shuttle.cpp
|
@ -523,129 +523,6 @@ void ShuttleSetAutomation::DefineEnum( int &var, const wxChar * key, const int v
|
|||
var = temp;
|
||||
}
|
||||
|
||||
bool ShuttleGetDefinition::IsOptional(){
|
||||
bool result = pOptionalFlag !=NULL;
|
||||
pOptionalFlag = NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Definition distinguishes optional from not.
|
||||
ShuttleParams & ShuttleGetDefinition::Optional( bool & var ){
|
||||
pOptionalFlag = &var;
|
||||
return *this;
|
||||
};
|
||||
|
||||
ShuttleGetDefinition::ShuttleGetDefinition( CommandMessageTarget & target ) : CommandMessageTargetDecorator( target )
|
||||
{
|
||||
}
|
||||
|
||||
// JSON definitions.
|
||||
void ShuttleGetDefinition::Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "bool", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( vdefault ? "True" : "False", "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "int", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( (double)vdefault, "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "size_t", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( (double)vdefault, "default" );
|
||||
EndStruct();
|
||||
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "float", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( (double)vdefault, "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "float", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( (double)vdefault, "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "double", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( (double)vdefault, "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
|
||||
void ShuttleGetDefinition::Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "string", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( vdefault, "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
|
||||
void ShuttleGetDefinition::DefineEnum( int &var,
|
||||
const wxChar * key, const int vdefault,
|
||||
const EnumValueSymbol strings[], size_t nStrings )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "enum", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( strings[vdefault].Internal(), "default" );
|
||||
StartField( "enum" );
|
||||
StartArray();
|
||||
for( size_t i = 0; i < nStrings; i++ )
|
||||
AddItem( strings[i].Internal() );
|
||||
EndArray();
|
||||
EndField();
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// If this is compiled with MSVC (Visual Studio)
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#ifndef __AUDACITY_SHUTTLE__
|
||||
#define __AUDACITY_SHUTTLE__
|
||||
|
||||
#include "commands/CommandTargets.h"
|
||||
#include "../include/audacity/ComponentInterface.h"
|
||||
|
||||
class ComponentInterfaceSymbol;
|
||||
|
@ -123,27 +122,6 @@ public:
|
|||
const EnumValueSymbol strings[], size_t nStrings ) override;
|
||||
};
|
||||
|
||||
/**************************************************************************//**
|
||||
\brief Shuttle that retrieves a JSON format definition of a command's parameters.
|
||||
********************************************************************************/
|
||||
class ShuttleGetDefinition : public ShuttleParams, public CommandMessageTargetDecorator
|
||||
{
|
||||
public:
|
||||
ShuttleGetDefinition( CommandMessageTarget & target );
|
||||
wxString Result;
|
||||
bool IsOptional();
|
||||
ShuttleParams & Optional( bool & var ) override;
|
||||
void Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl ) override;
|
||||
void Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override;
|
||||
void Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override;
|
||||
void Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override;
|
||||
void Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override;
|
||||
void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override;
|
||||
void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override;
|
||||
void DefineEnum( int &var, const wxChar * key, const int vdefault,
|
||||
const EnumValueSymbol strings[], size_t nStrings ) override;
|
||||
};
|
||||
|
||||
|
||||
/**************************************************************************//**
|
||||
\brief Shuttle that sets parameters to their default values.
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
ShuttleGetDefinition.cpp
|
||||
|
||||
Paul Licameli split this out of Shuttle.cpp
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "ShuttleGetDefinition.h"
|
||||
|
||||
bool ShuttleGetDefinition::IsOptional(){
|
||||
bool result = pOptionalFlag !=NULL;
|
||||
pOptionalFlag = NULL;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Definition distinguishes optional from not.
|
||||
ShuttleParams & ShuttleGetDefinition::Optional( bool & var ){
|
||||
pOptionalFlag = &var;
|
||||
return *this;
|
||||
};
|
||||
|
||||
ShuttleGetDefinition::ShuttleGetDefinition( CommandMessageTarget & target ) : CommandMessageTargetDecorator( target )
|
||||
{
|
||||
}
|
||||
|
||||
// JSON definitions.
|
||||
void ShuttleGetDefinition::Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "bool", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( vdefault ? "True" : "False", "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "int", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( (double)vdefault, "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "size_t", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( (double)vdefault, "default" );
|
||||
EndStruct();
|
||||
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "float", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( (double)vdefault, "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "float", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( (double)vdefault, "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
void ShuttleGetDefinition::Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "double", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( (double)vdefault, "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
|
||||
void ShuttleGetDefinition::Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "string", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( vdefault, "default" );
|
||||
EndStruct();
|
||||
}
|
||||
|
||||
|
||||
void ShuttleGetDefinition::DefineEnum( int &var,
|
||||
const wxChar * key, const int vdefault,
|
||||
const EnumValueSymbol strings[], size_t nStrings )
|
||||
{
|
||||
StartStruct();
|
||||
AddItem( wxString(key), "key" );
|
||||
AddItem( "enum", "type" );
|
||||
if( IsOptional() )
|
||||
AddItem( "unchanged", "default" );
|
||||
else
|
||||
AddItem( strings[vdefault].Internal(), "default" );
|
||||
StartField( "enum" );
|
||||
StartArray();
|
||||
for( size_t i = 0; i < nStrings; i++ )
|
||||
AddItem( strings[i].Internal() );
|
||||
EndArray();
|
||||
EndField();
|
||||
EndStruct();
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
ShuttleGetDefinition.h
|
||||
|
||||
Paul Licameli split this out of Shuttle.h
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_SHUTTLE_GET_DEFINITION__
|
||||
#define __AUDACITY_SHUTTLE_GET_DEFINITION__
|
||||
|
||||
#include "Shuttle.h" // to inherit
|
||||
#include "commands/CommandTargets.h" // to inherit
|
||||
|
||||
/**************************************************************************//**
|
||||
\brief Shuttle that retrieves a JSON format definition of a command's parameters.
|
||||
********************************************************************************/
|
||||
class ShuttleGetDefinition : public ShuttleParams, public CommandMessageTargetDecorator
|
||||
{
|
||||
public:
|
||||
ShuttleGetDefinition( CommandMessageTarget & target );
|
||||
wxString Result;
|
||||
bool IsOptional();
|
||||
ShuttleParams & Optional( bool & var ) override;
|
||||
void Define( bool & var, const wxChar * key, const bool vdefault, const bool vmin, const bool vmax, const bool vscl ) override;
|
||||
void Define( int & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override;
|
||||
void Define( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override;
|
||||
void Define( float & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override;
|
||||
void Define( double & var, const wxChar * key, const float vdefault, const float vmin, const float vmax, const float vscl ) override;
|
||||
void Define( double & var, const wxChar * key, const double vdefault, const double vmin, const double vmax, const double vscl ) override;
|
||||
void Define( wxString &var, const wxChar * key, const wxString vdefault, const wxString vmin, const wxString vmax, const wxString vscl ) override;
|
||||
void DefineEnum( int &var, const wxChar * key, const int vdefault,
|
||||
const EnumValueSymbol strings[], size_t nStrings ) override;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -25,10 +25,11 @@ system by constructing BatchCommandEval objects.
|
|||
#include "CommandBuilder.h"
|
||||
|
||||
#include "CommandDirectory.h"
|
||||
#include "../Shuttle.h"
|
||||
#include "BatchEvalCommand.h"
|
||||
#include "ScriptCommandRelay.h"
|
||||
#include "CommandContext.h"
|
||||
#include "CommandTargets.h"
|
||||
#include "Shuttle.h"
|
||||
|
||||
CommandBuilder::CommandBuilder(const wxString &cmdString)
|
||||
: mValid(false)
|
||||
|
|
|
@ -25,6 +25,7 @@ This class now lists
|
|||
|
||||
#include "../Project.h"
|
||||
#include "CommandManager.h"
|
||||
#include "CommandTargets.h"
|
||||
#include "../effects/EffectManager.h"
|
||||
#include "../widgets/Overlay.h"
|
||||
#include "../TrackPanel.h"
|
||||
|
|
|
@ -33,7 +33,7 @@ effects.
|
|||
#include "EffectRack.h"
|
||||
#endif
|
||||
|
||||
#include "../Shuttle.h"
|
||||
#include "../ShuttleGetDefinition.h"
|
||||
#include "../commands/CommandContext.h"
|
||||
#include "../PluginManager.h"
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ effects from this one class.
|
|||
#include "../../TimeTrack.h"
|
||||
#include "../../prefs/SpectrogramSettings.h"
|
||||
#include "../../Project.h"
|
||||
#include "../../Shuttle.h"
|
||||
#include "../../ShuttleGetDefinition.h"
|
||||
#include "../../ShuttleGui.h"
|
||||
#include "../../WaveClip.h"
|
||||
#include "../../WaveTrack.h"
|
||||
|
|
Loading…
Reference in New Issue