1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Identifier not wxString in ctors of registry items

This commit is contained in:
Paul Licameli 2020-02-04 11:55:40 -05:00
parent db224895b0
commit a43c9a5337
2 changed files with 22 additions and 21 deletions

View File

@ -197,7 +197,7 @@ void MenuVisitor::DoSeparator()
namespace MenuTable { namespace MenuTable {
MenuItem::MenuItem( const wxString &internalName, MenuItem::MenuItem( const Identifier &internalName,
const TranslatableString &title_, BaseItemPtrs &&items_ ) const TranslatableString &title_, BaseItemPtrs &&items_ )
: ConcreteGroupItem< false, MenuVisitor >{ : ConcreteGroupItem< false, MenuVisitor >{
internalName, std::move( items_ ) }, title{ title_ } internalName, std::move( items_ ) }, title{ title_ }
@ -207,7 +207,7 @@ MenuItem::MenuItem( const wxString &internalName,
MenuItem::~MenuItem() {} MenuItem::~MenuItem() {}
ConditionalGroupItem::ConditionalGroupItem( ConditionalGroupItem::ConditionalGroupItem(
const wxString &internalName, Condition condition_, BaseItemPtrs &&items_ ) const Identifier &internalName, Condition condition_, BaseItemPtrs &&items_ )
: ConcreteGroupItem< false, MenuVisitor >{ : ConcreteGroupItem< false, MenuVisitor >{
internalName, std::move( items_ ) }, condition{ condition_ } internalName, std::move( items_ ) }, condition{ condition_ }
{ {
@ -226,7 +226,7 @@ CommandItem::CommandItem(const CommandID &name_,
{} {}
CommandItem::~CommandItem() {} CommandItem::~CommandItem() {}
CommandGroupItem::CommandGroupItem(const wxString &name_, CommandGroupItem::CommandGroupItem(const Identifier &name_,
std::vector< ComponentInterfaceSymbol > items_, std::vector< ComponentInterfaceSymbol > items_,
CommandFunctorPointer callback_, CommandFunctorPointer callback_,
CommandFlag flags_, CommandFlag flags_,

View File

@ -697,11 +697,11 @@ namespace MenuTable {
struct MenuItem final : ConcreteGroupItem< false, MenuVisitor > { struct MenuItem final : ConcreteGroupItem< false, MenuVisitor > {
// Construction from an internal name and a previously built-up // Construction from an internal name and a previously built-up
// vector of pointers // vector of pointers
MenuItem( const wxString &internalName, MenuItem( const Identifier &internalName,
const TranslatableString &title_, BaseItemPtrs &&items_ ); const TranslatableString &title_, BaseItemPtrs &&items_ );
// In-line, variadic constructor that doesn't require building a vector // In-line, variadic constructor that doesn't require building a vector
template< typename... Args > template< typename... Args >
MenuItem( const wxString &internalName, MenuItem( const Identifier &internalName,
const TranslatableString &title_, Args&&... args ) const TranslatableString &title_, Args&&... args )
: ConcreteGroupItem< false, MenuVisitor >{ : ConcreteGroupItem< false, MenuVisitor >{
internalName, std::forward<Args>(args)... } internalName, std::forward<Args>(args)... }
@ -719,11 +719,11 @@ namespace MenuTable {
// Construction from an internal name and a previously built-up // Construction from an internal name and a previously built-up
// vector of pointers // vector of pointers
ConditionalGroupItem( const wxString &internalName, ConditionalGroupItem( const Identifier &internalName,
Condition condition_, BaseItemPtrs &&items_ ); Condition condition_, BaseItemPtrs &&items_ );
// In-line, variadic constructor that doesn't require building a vector // In-line, variadic constructor that doesn't require building a vector
template< typename... Args > template< typename... Args >
ConditionalGroupItem( const wxString &internalName, ConditionalGroupItem( const Identifier &internalName,
Condition condition_, Args&&... args ) Condition condition_, Args&&... args )
: ConcreteGroupItem< false, MenuVisitor >{ : ConcreteGroupItem< false, MenuVisitor >{
internalName, std::forward<Args>(args)... } internalName, std::forward<Args>(args)... }
@ -794,7 +794,7 @@ namespace MenuTable {
// and dispatch to one common callback, which will be passed a number // and dispatch to one common callback, which will be passed a number
// in the CommandContext identifying the command // in the CommandContext identifying the command
struct CommandGroupItem final : SingleItem { struct CommandGroupItem final : SingleItem {
CommandGroupItem(const wxString &name_, CommandGroupItem(const Identifier &name_,
std::vector< ComponentInterfaceSymbol > items_, std::vector< ComponentInterfaceSymbol > items_,
CommandFunctorPointer callback_, CommandFunctorPointer callback_,
CommandFlag flags_, CommandFlag flags_,
@ -804,7 +804,7 @@ namespace MenuTable {
// Takes a pointer to member function directly, and delegates to the // Takes a pointer to member function directly, and delegates to the
// previous constructor; useful within the lifetime of a FinderScope // previous constructor; useful within the lifetime of a FinderScope
template< typename Handler > template< typename Handler >
CommandGroupItem(const wxString &name_, CommandGroupItem(const Identifier &name_,
std::vector< ComponentInterfaceSymbol > items_, std::vector< ComponentInterfaceSymbol > items_,
void (Handler::*pmf)(const CommandContext&), void (Handler::*pmf)(const CommandContext&),
CommandFlag flags_, CommandFlag flags_,
@ -830,7 +830,7 @@ namespace MenuTable {
{ {
using Appender = std::function< void( AudacityProject&, wxMenu& ) >; using Appender = std::function< void( AudacityProject&, wxMenu& ) >;
explicit SpecialItem( const wxString &internalName, const Appender &fn_ ) explicit SpecialItem( const Identifier &internalName, const Appender &fn_ )
: SingleItem{ internalName } : SingleItem{ internalName }
, fn{ fn_ } , fn{ fn_ }
{} {}
@ -843,7 +843,8 @@ namespace MenuTable {
struct MenuPart : ConcreteGroupItem< Transparent, MenuVisitor > struct MenuPart : ConcreteGroupItem< Transparent, MenuVisitor >
{ {
template< typename... Args > template< typename... Args >
MenuPart( const wxString &internalName, Args&&... args ) explicit
MenuPart( const Identifier &internalName, Args&&... args )
: ConcreteGroupItem< Transparent, MenuVisitor >{ : ConcreteGroupItem< Transparent, MenuVisitor >{
internalName, std::forward< Args >( args )... } internalName, std::forward< Args >( args )... }
{} {}
@ -863,7 +864,7 @@ namespace MenuTable {
// stable across Audacity versions. // stable across Audacity versions.
template< typename... Args > template< typename... Args >
inline std::unique_ptr< MenuItems > Items( inline std::unique_ptr< MenuItems > Items(
const wxString &internalName, Args&&... args ) const Identifier &internalName, Args&&... args )
{ return std::make_unique< MenuItems >( { return std::make_unique< MenuItems >(
internalName, std::forward<Args>(args)... ); } internalName, std::forward<Args>(args)... ); }
@ -874,7 +875,7 @@ namespace MenuTable {
// might clarify the logical groupings. // might clarify the logical groupings.
template< typename... Args > template< typename... Args >
inline std::unique_ptr< MenuSection > Section( inline std::unique_ptr< MenuSection > Section(
const wxString &internalName, Args&&... args ) const Identifier &internalName, Args&&... args )
{ return std::make_unique< MenuSection >( { return std::make_unique< MenuSection >(
internalName, std::forward<Args>(args)... ); } internalName, std::forward<Args>(args)... ); }
@ -886,11 +887,11 @@ namespace MenuTable {
// by path. // by path.
template< typename... Args > template< typename... Args >
inline std::unique_ptr<MenuItem> Menu( inline std::unique_ptr<MenuItem> Menu(
const wxString &internalName, const TranslatableString &title, Args&&... args ) const Identifier &internalName, const TranslatableString &title, Args&&... args )
{ return std::make_unique<MenuItem>( { return std::make_unique<MenuItem>(
internalName, title, std::forward<Args>(args)... ); } internalName, title, std::forward<Args>(args)... ); }
inline std::unique_ptr<MenuItem> Menu( inline std::unique_ptr<MenuItem> Menu(
const wxString &internalName, const TranslatableString &title, BaseItemPtrs &&items ) const Identifier &internalName, const TranslatableString &title, BaseItemPtrs &&items )
{ return std::make_unique<MenuItem>( { return std::make_unique<MenuItem>(
internalName, title, std::move( items ) ); } internalName, title, std::move( items ) ); }
@ -902,12 +903,12 @@ namespace MenuTable {
// Name for conditional group must be non-empty. // Name for conditional group must be non-empty.
template< typename... Args > template< typename... Args >
inline std::unique_ptr<ConditionalGroupItem> ConditionalItems( inline std::unique_ptr<ConditionalGroupItem> ConditionalItems(
const wxString &internalName, const Identifier &internalName,
ConditionalGroupItem::Condition condition, Args&&... args ) ConditionalGroupItem::Condition condition, Args&&... args )
{ return std::make_unique<ConditionalGroupItem>( { return std::make_unique<ConditionalGroupItem>(
internalName, condition, std::forward<Args>(args)... ); } internalName, condition, std::forward<Args>(args)... ); }
inline std::unique_ptr<ConditionalGroupItem> ConditionalItems( inline std::unique_ptr<ConditionalGroupItem> ConditionalItems(
const wxString &internalName, ConditionalGroupItem::Condition condition, const Identifier &internalName, ConditionalGroupItem::Condition condition,
BaseItemPtrs &&items ) BaseItemPtrs &&items )
{ return std::make_unique<ConditionalGroupItem>( { return std::make_unique<ConditionalGroupItem>(
internalName, condition, std::move( items ) ); } internalName, condition, std::move( items ) ); }
@ -921,14 +922,14 @@ namespace MenuTable {
// by path. // by path.
template< typename... Args > template< typename... Args >
inline BaseItemPtr MenuOrItems( inline BaseItemPtr MenuOrItems(
const wxString &internalName, const TranslatableString &title, Args&&... args ) const Identifier &internalName, const TranslatableString &title, Args&&... args )
{ if ( title.empty() ) { if ( title.empty() )
return Items( internalName, std::forward<Args>(args)... ); return Items( internalName, std::forward<Args>(args)... );
else else
return std::make_unique<MenuItem>( return std::make_unique<MenuItem>(
internalName, title, std::forward<Args>(args)... ); } internalName, title, std::forward<Args>(args)... ); }
inline BaseItemPtr MenuOrItems( inline BaseItemPtr MenuOrItems(
const wxString &internalName, const Identifier &internalName,
const TranslatableString &title, BaseItemPtrs &&items ) const TranslatableString &title, BaseItemPtrs &&items )
{ if ( title.empty() ) { if ( title.empty() )
return Items( internalName, std::move( items ) ); return Items( internalName, std::move( items ) );
@ -951,7 +952,7 @@ namespace MenuTable {
template< typename Handler > template< typename Handler >
inline std::unique_ptr<CommandGroupItem> CommandGroup( inline std::unique_ptr<CommandGroupItem> CommandGroup(
const wxString &name, const Identifier &name,
std::vector< ComponentInterfaceSymbol > items, std::vector< ComponentInterfaceSymbol > items,
void (Handler::*pmf)(const CommandContext&), void (Handler::*pmf)(const CommandContext&),
CommandFlag flags, bool isEffect = false, CommandFlag flags, bool isEffect = false,
@ -963,7 +964,7 @@ namespace MenuTable {
} }
inline std::unique_ptr<SpecialItem> Special( inline std::unique_ptr<SpecialItem> Special(
const wxString &name, const SpecialItem::Appender &fn ) const Identifier &name, const SpecialItem::Appender &fn )
{ return std::make_unique<SpecialItem>( name, fn ); } { return std::make_unique<SpecialItem>( name, fn ); }
// Typically you make a static object of this type in the .cpp file that // Typically you make a static object of this type in the .cpp file that