mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-21 08:27:13 +01:00
Generalize means for decoupled code to add data to core structures...
... Generalizing what was first done at 280e8d9 for certain menu command
handlers.
Allow core data structures to host data attached by other code, on which it
need have no compilation or link dependencies.
This commit is contained in:
@@ -301,6 +301,7 @@ namespace NavigationActions {
|
||||
|
||||
struct Handler
|
||||
: CommandHandlerObject // MUST be the first base class!
|
||||
, ClientData::Base
|
||||
, PrefsListener
|
||||
{
|
||||
|
||||
@@ -539,12 +540,12 @@ Handler()
|
||||
|
||||
// Handler is stateful. Needs a factory registered with
|
||||
// AudacityProject.
|
||||
static const AudacityProject::RegisteredAttachedObjectFactory factory{ []{
|
||||
return std::make_unique< NavigationActions::Handler >();
|
||||
} };
|
||||
static const AudacityProject::AttachedObjects::RegisteredFactory key{
|
||||
[](AudacityProject&) {
|
||||
return std::make_unique< NavigationActions::Handler >(); } };
|
||||
|
||||
static CommandHandlerObject &findCommandHandler(AudacityProject &project) {
|
||||
return static_cast<NavigationActions::Handler&>(
|
||||
project.GetAttachedObject(factory));
|
||||
return project.AttachedObjects::Get< NavigationActions::Handler >( key );
|
||||
};
|
||||
|
||||
// Menu definitions
|
||||
|
||||
@@ -553,6 +553,7 @@ void DoSelectSomething(AudacityProject &project)
|
||||
|
||||
struct Handler
|
||||
: CommandHandlerObject // MUST be the first base class!
|
||||
, ClientData::Base
|
||||
, PrefsListener
|
||||
{
|
||||
|
||||
@@ -1133,12 +1134,12 @@ Handler()
|
||||
|
||||
// Handler is stateful. Needs a factory registered with
|
||||
// AudacityProject.
|
||||
static const AudacityProject::RegisteredAttachedObjectFactory factory{ []{
|
||||
return std::make_unique< SelectActions::Handler >();
|
||||
} };
|
||||
static const AudacityProject::AttachedObjects::RegisteredFactory key{
|
||||
[](AudacityProject&) {
|
||||
return std::make_unique< SelectActions::Handler >(); } };
|
||||
|
||||
static CommandHandlerObject &findCommandHandler(AudacityProject &project) {
|
||||
return static_cast<SelectActions::Handler&>(
|
||||
project.GetAttachedObject(factory));
|
||||
return project.AttachedObjects::Get< SelectActions::Handler >( key );
|
||||
};
|
||||
|
||||
// Menu definitions
|
||||
|
||||
Reference in New Issue
Block a user