diff --git a/src/Shuttle.cpp b/src/Shuttle.cpp index c5d2534b2..3f38b4145 100644 --- a/src/Shuttle.cpp +++ b/src/Shuttle.cpp @@ -559,11 +559,17 @@ void ShuttleSetAutomation::DefineEnum( int &var, const wxChar * key, const int v } bool ShuttleGetDefinition::IsOptional(){ - bool result = pOptionalFlag ? true : false; + 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 ) { } diff --git a/src/Shuttle.h b/src/Shuttle.h index 76918f995..54db8c1c3 100644 --- a/src/Shuttle.h +++ b/src/Shuttle.h @@ -136,6 +136,7 @@ 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; diff --git a/src/commands/CommandManager.cpp b/src/commands/CommandManager.cpp index e26363447..08c4a8272 100644 --- a/src/commands/CommandManager.cpp +++ b/src/commands/CommandManager.cpp @@ -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) { CommandListEntry *entry = mCommandNameHash[name]; diff --git a/src/commands/CommandManager.h b/src/commands/CommandManager.h index 7da616006..add7e2c82 100644 --- a/src/commands/CommandManager.h +++ b/src/commands/CommandManager.h @@ -262,6 +262,7 @@ class AUDACITY_DLL_API CommandManager final : public XMLTagHandler #endif bool includeMultis); + wxString GetNameFromID( int id ); wxString GetLabelFromName(const wxString &name); wxString GetPrefixedLabelFromName(const wxString &name); wxString GetCategoryFromName(const wxString &name); diff --git a/src/commands/CommandTargets.h b/src/commands/CommandTargets.h index d1d1f9535..9222dccaf 100644 --- a/src/commands/CommandTargets.h +++ b/src/commands/CommandTargets.h @@ -277,6 +277,9 @@ public: /// Used to aggregate the various output targets a command may have. /// 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 { public: @@ -284,6 +287,9 @@ public: std::shared_ptr mStatusTarget; std::shared_ptr mErrorTarget; 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 &&pt = TargetFactory::ProgressDefault(), std::shared_ptr &&st = TargetFactory::MessageDefault(), std::shared_ptr &&et = TargetFactory::MessageDefault()) diff --git a/src/commands/GetInfoCommand.cpp b/src/commands/GetInfoCommand.cpp index 1e3339dd4..4de4c9349 100644 --- a/src/commands/GetInfoCommand.cpp +++ b/src/commands/GetInfoCommand.cpp @@ -319,15 +319,19 @@ void GetInfoCommand::ExploreMenu( const CommandContext &context, wxMenu * pMenu, if( !pMenu ) return; + CommandManager * pMan = context.GetProject()->GetCommandManager(); + wxMenuItemList list = pMenu->GetMenuItems(); size_t lcnt = list.GetCount(); wxMenuItem * item; wxString Label; wxString Accel; + wxString Name; for (size_t lndx = 0; lndx < lcnt; lndx++) { item = list.Item(lndx)->GetData(); Label = item->GetItemLabelText(); + Name = pMan->GetNameFromID( item->GetId() ); Accel = item->GetItemLabel(); if( Accel.Contains("\t") ) Accel = Accel.AfterLast('\t'); @@ -341,12 +345,14 @@ void GetInfoCommand::ExploreMenu( const CommandContext &context, wxMenu * pMenu, if (item->IsCheck() && item->IsChecked()) flags +=2; - context.StartArray(); - context.AddItem( depth ); - context.AddItem( flags ); - context.AddItem( Label ); - context.AddItem( Accel ); - context.EndArray(); + context.StartStruct(); + context.AddItem( depth, "0" ); + context.AddItem( flags, "1" ); + context.AddItem( Label, "2" ); + context.AddItem( Accel, "3" ); + if( !Name.IsEmpty() ) + context.AddItem( Name, "id" );// It is called Automation ID outside Audacity. + context.EndStruct(); if (item->IsSubMenu()) { pMenu = item->GetSubMenu(); diff --git a/src/commands/SetClipCommand.cpp b/src/commands/SetClipCommand.cpp index 6233f733b..5724109a0 100644 --- a/src/commands/SetClipCommand.cpp +++ b/src/commands/SetClipCommand.cpp @@ -62,7 +62,7 @@ bool SetClipCommand::DefineParams( ShuttleParams & S ){ S.Optional( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, colours ); // Allowing a negative start time is not a mistake. // 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; };