1
0
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:
Paul Licameli
2019-04-27 13:35:49 -04:00
parent caec2064e5
commit af039f19ff
12 changed files with 690 additions and 142 deletions

View File

@@ -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

View File

@@ -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