mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-31 07:59:27 +02:00
Fix Automation listing
- Now correctly shows optional fields - Now includes the zero-parameter commands. - Fetches the Short-Names for menu commands.
This commit is contained in:
parent
a0c393a012
commit
500765329f
@ -559,11 +559,17 @@ void ShuttleSetAutomation::DefineEnum( int &var, const wxChar * key, const int v
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ShuttleGetDefinition::IsOptional(){
|
bool ShuttleGetDefinition::IsOptional(){
|
||||||
bool result = pOptionalFlag ? true : false;
|
bool result = pOptionalFlag !=NULL;
|
||||||
pOptionalFlag = NULL;
|
pOptionalFlag = NULL;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Definition distinguishes optional from not.
|
||||||
|
ShuttleParams & ShuttleGetDefinition::Optional( bool & var ){
|
||||||
|
pOptionalFlag = &var;
|
||||||
|
return *this;
|
||||||
|
};
|
||||||
|
|
||||||
ShuttleGetDefinition::ShuttleGetDefinition( CommandMessageTarget & target ) : CommandMessageTargetDecorator( target )
|
ShuttleGetDefinition::ShuttleGetDefinition( CommandMessageTarget & target ) : CommandMessageTargetDecorator( target )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,7 @@ public:
|
|||||||
ShuttleGetDefinition( CommandMessageTarget & target );
|
ShuttleGetDefinition( CommandMessageTarget & target );
|
||||||
wxString Result;
|
wxString Result;
|
||||||
bool IsOptional();
|
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( 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( 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( size_t & var, const wxChar * key, const int vdefault, const int vmin, const int vmax, const int vscl ) override;
|
||||||
|
@ -1665,6 +1665,15 @@ void CommandManager::GetAllCommandData(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString CommandManager::GetNameFromID(int id)
|
||||||
|
{
|
||||||
|
CommandListEntry *entry = mCommandIDHash[id];
|
||||||
|
if (!entry)
|
||||||
|
return wxT("");
|
||||||
|
return entry->name;
|
||||||
|
}
|
||||||
|
|
||||||
wxString CommandManager::GetLabelFromName(const wxString &name)
|
wxString CommandManager::GetLabelFromName(const wxString &name)
|
||||||
{
|
{
|
||||||
CommandListEntry *entry = mCommandNameHash[name];
|
CommandListEntry *entry = mCommandNameHash[name];
|
||||||
|
@ -262,6 +262,7 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler
|
|||||||
#endif
|
#endif
|
||||||
bool includeMultis);
|
bool includeMultis);
|
||||||
|
|
||||||
|
wxString GetNameFromID( int id );
|
||||||
wxString GetLabelFromName(const wxString &name);
|
wxString GetLabelFromName(const wxString &name);
|
||||||
wxString GetPrefixedLabelFromName(const wxString &name);
|
wxString GetPrefixedLabelFromName(const wxString &name);
|
||||||
wxString GetCategoryFromName(const wxString &name);
|
wxString GetCategoryFromName(const wxString &name);
|
||||||
|
@ -277,6 +277,9 @@ public:
|
|||||||
|
|
||||||
/// Used to aggregate the various output targets a command may have.
|
/// Used to aggregate the various output targets a command may have.
|
||||||
/// Assumes responsibility for pointers passed into it.
|
/// Assumes responsibility for pointers passed into it.
|
||||||
|
/// mProgressTarget is a unique pointer, but mStatusTraget and
|
||||||
|
/// mErrorTarget are shared ones, because they may both point to the same
|
||||||
|
/// output
|
||||||
class CommandOutputTargets
|
class CommandOutputTargets
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -284,6 +287,9 @@ public:
|
|||||||
std::shared_ptr<CommandMessageTarget> mStatusTarget;
|
std::shared_ptr<CommandMessageTarget> mStatusTarget;
|
||||||
std::shared_ptr<CommandMessageTarget> mErrorTarget;
|
std::shared_ptr<CommandMessageTarget> mErrorTarget;
|
||||||
public:
|
public:
|
||||||
|
// && is not a reference to a reference, but rather a way to allow reference to a temporary
|
||||||
|
// that will be gone or transfered after we have taken it. It's a reference to an xvalue,
|
||||||
|
// or 'expiring value'.
|
||||||
CommandOutputTargets(std::unique_ptr<CommandProgressTarget> &&pt = TargetFactory::ProgressDefault(),
|
CommandOutputTargets(std::unique_ptr<CommandProgressTarget> &&pt = TargetFactory::ProgressDefault(),
|
||||||
std::shared_ptr<CommandMessageTarget> &&st = TargetFactory::MessageDefault(),
|
std::shared_ptr<CommandMessageTarget> &&st = TargetFactory::MessageDefault(),
|
||||||
std::shared_ptr<CommandMessageTarget> &&et = TargetFactory::MessageDefault())
|
std::shared_ptr<CommandMessageTarget> &&et = TargetFactory::MessageDefault())
|
||||||
|
@ -319,15 +319,19 @@ void GetInfoCommand::ExploreMenu( const CommandContext &context, wxMenu * pMenu,
|
|||||||
if( !pMenu )
|
if( !pMenu )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
CommandManager * pMan = context.GetProject()->GetCommandManager();
|
||||||
|
|
||||||
wxMenuItemList list = pMenu->GetMenuItems();
|
wxMenuItemList list = pMenu->GetMenuItems();
|
||||||
size_t lcnt = list.GetCount();
|
size_t lcnt = list.GetCount();
|
||||||
wxMenuItem * item;
|
wxMenuItem * item;
|
||||||
wxString Label;
|
wxString Label;
|
||||||
wxString Accel;
|
wxString Accel;
|
||||||
|
wxString Name;
|
||||||
|
|
||||||
for (size_t lndx = 0; lndx < lcnt; lndx++) {
|
for (size_t lndx = 0; lndx < lcnt; lndx++) {
|
||||||
item = list.Item(lndx)->GetData();
|
item = list.Item(lndx)->GetData();
|
||||||
Label = item->GetItemLabelText();
|
Label = item->GetItemLabelText();
|
||||||
|
Name = pMan->GetNameFromID( item->GetId() );
|
||||||
Accel = item->GetItemLabel();
|
Accel = item->GetItemLabel();
|
||||||
if( Accel.Contains("\t") )
|
if( Accel.Contains("\t") )
|
||||||
Accel = Accel.AfterLast('\t');
|
Accel = Accel.AfterLast('\t');
|
||||||
@ -341,12 +345,14 @@ void GetInfoCommand::ExploreMenu( const CommandContext &context, wxMenu * pMenu,
|
|||||||
if (item->IsCheck() && item->IsChecked())
|
if (item->IsCheck() && item->IsChecked())
|
||||||
flags +=2;
|
flags +=2;
|
||||||
|
|
||||||
context.StartArray();
|
context.StartStruct();
|
||||||
context.AddItem( depth );
|
context.AddItem( depth, "0" );
|
||||||
context.AddItem( flags );
|
context.AddItem( flags, "1" );
|
||||||
context.AddItem( Label );
|
context.AddItem( Label, "2" );
|
||||||
context.AddItem( Accel );
|
context.AddItem( Accel, "3" );
|
||||||
context.EndArray();
|
if( !Name.IsEmpty() )
|
||||||
|
context.AddItem( Name, "id" );// It is called Automation ID outside Audacity.
|
||||||
|
context.EndStruct();
|
||||||
|
|
||||||
if (item->IsSubMenu()) {
|
if (item->IsSubMenu()) {
|
||||||
pMenu = item->GetSubMenu();
|
pMenu = item->GetSubMenu();
|
||||||
|
@ -62,7 +62,7 @@ bool SetClipCommand::DefineParams( ShuttleParams & S ){
|
|||||||
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
|
S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours );
|
||||||
// Allowing a negative start time is not a mistake.
|
// Allowing a negative start time is not a mistake.
|
||||||
// It will be used in demonstrating time before zero.
|
// It will be used in demonstrating time before zero.
|
||||||
S.Optional( bHasT0 ).Define( mT0, wxT("Start"), -5.0, 0.0, 1000000.0);
|
S.Optional( bHasT0 ).Define( mT0, wxT("Start"), 0.0, -5.0, 1000000.0);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user