mirror of
https://github.com/cookiengineer/audacity
synced 2026-02-25 15:41:07 +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:
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "Experimental.h"
|
||||
|
||||
#include "ClientData.h"
|
||||
#include "Track.h"
|
||||
#include "Prefs.h"
|
||||
#include "SelectionState.h"
|
||||
@@ -172,6 +173,10 @@ class WaveTrack;
|
||||
|
||||
class MenuManager;
|
||||
|
||||
using AttachedObjects = ClientData::Site<
|
||||
AudacityProject, ClientData::Base, ClientData::SkipCopying, std::shared_ptr
|
||||
>;
|
||||
|
||||
class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
||||
public TrackPanelListener,
|
||||
public SelectionBarListener,
|
||||
@@ -179,8 +184,11 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
||||
public XMLTagHandler,
|
||||
public AudioIOListener,
|
||||
private PrefsListener
|
||||
, public AttachedObjects
|
||||
{
|
||||
public:
|
||||
using AttachedObjects = ::AttachedObjects;
|
||||
|
||||
AudacityProject(wxWindow * parent, wxWindowID id,
|
||||
const wxPoint & pos, const wxSize & size);
|
||||
virtual ~AudacityProject();
|
||||
@@ -188,24 +196,6 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
||||
// Next available ID for sub-windows
|
||||
int NextWindowID();
|
||||
|
||||
using AttachedObject = wxObject;
|
||||
using AttachedObjectFactory =
|
||||
std::function< std::unique_ptr<AttachedObject>() >;
|
||||
|
||||
// Typically a static object. Allows various application code to
|
||||
// attach per-project state, without Project.cpp needing to include a header
|
||||
// file or know the details.
|
||||
class RegisteredAttachedObjectFactory {
|
||||
public:
|
||||
RegisteredAttachedObjectFactory( const AttachedObjectFactory &factory );
|
||||
|
||||
private:
|
||||
friend AudacityProject;
|
||||
size_t mIndex {};
|
||||
};
|
||||
AttachedObject &
|
||||
GetAttachedObject( const RegisteredAttachedObjectFactory& factory );
|
||||
|
||||
virtual void ApplyUpdatedTheme();
|
||||
|
||||
AudioIOStartStreamOptions GetDefaultPlayOptions();
|
||||
@@ -724,7 +714,6 @@ private:
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::vector< std::unique_ptr<AttachedObject> > mAttachedObjects;
|
||||
std::unique_ptr<MenuManager> mMenuManager;
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user