mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-18 01:27:41 +02:00
Demote convenience function that makes computed items to base class
This commit is contained in:
parent
4d7a9f00a1
commit
87382d51d8
@ -141,6 +141,22 @@ public:
|
|||||||
return mTop;
|
return mTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forms a computed item, which may be omitted when function returns null
|
||||||
|
// and thus can be a conditional item
|
||||||
|
template< typename Table >
|
||||||
|
static Registry::BaseItemPtr Computed(
|
||||||
|
const std::function< Registry::BaseItemPtr( Table& ) > &factory )
|
||||||
|
{
|
||||||
|
using namespace Registry;
|
||||||
|
return std::make_unique< ComputedItem >(
|
||||||
|
[factory]( Visitor &baseVisitor ){
|
||||||
|
auto &visitor = static_cast< PopupMenuVisitor& >( baseVisitor );
|
||||||
|
auto &table = static_cast< Table& >( visitor.mTable );
|
||||||
|
return factory( table );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RegisterItem(
|
void RegisterItem(
|
||||||
const Registry::Placement &placement, Registry::BaseItemPtr pItem );
|
const Registry::Placement &placement, Registry::BaseItemPtr pItem );
|
||||||
@ -197,16 +213,14 @@ public:
|
|||||||
// Appends a computed item, which may be omitted when function returns null
|
// Appends a computed item, which may be omitted when function returns null
|
||||||
// and thus can be a conditional item
|
// and thus can be a conditional item
|
||||||
using Factory = std::function< Registry::BaseItemPtr( Derived& ) >;
|
using Factory = std::function< Registry::BaseItemPtr( Derived& ) >;
|
||||||
|
static Registry::BaseItemPtr Computed( const Factory &factory )
|
||||||
|
{
|
||||||
|
return Base::Computed( factory );
|
||||||
|
}
|
||||||
|
|
||||||
void Append( const Factory &factory )
|
void Append( const Factory &factory )
|
||||||
{
|
{
|
||||||
using namespace Registry;
|
Append( Computed( factory ) );
|
||||||
Append( std::make_unique< ComputedItem >(
|
|
||||||
[factory]( Visitor &baseVisitor ){
|
|
||||||
auto &visitor = static_cast< PopupMenuVisitor& >( baseVisitor );
|
|
||||||
auto &table = static_cast< Derived& >( visitor.mTable );
|
|
||||||
return factory( table );
|
|
||||||
}
|
|
||||||
) );
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user