Audacity 3.2.0
PrefsPanel.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5PrefsPanel.cpp
6
7Paul Licameli split from PrefsDialog.cpp
8
9**********************************************************************/
10
11#include "PrefsPanel.h"
12#include <mutex>
13
14namespace {
15const auto PathStart = wxT("Preferences");
16
18{
20 return registry;
21}
22
25 bool expanded{ false };
26
27 PrefsItem( const wxString &name,
28 const PrefsPanel::Factory &factory_, bool expanded_ )
29 : ConcreteGroupItem<false>{ name }
30 , factory{ factory_ }, expanded{ expanded_ }
31 {}
32};
33
34// Collects registry tree nodes into a vector, in preorder.
37 : factories{ factories_ }
38 {
39 childCounts.push_back( 0 );
40 }
41 void BeginGroup( Registry::GroupItem &item, const Path & ) override
42 {
43 auto pItem = dynamic_cast<PrefsItem*>( &item );
44 if (!pItem)
45 return;
46 indices.push_back( factories.size() );
47 factories.emplace_back( pItem->factory, 0, pItem->expanded );
48 ++childCounts.back();
49 childCounts.push_back( 0 );
50 }
51 void EndGroup( Registry::GroupItem &item, const Path & ) override
52 {
53 auto pItem = dynamic_cast<PrefsItem*>( &item );
54 if (!pItem)
55 return;
56 auto &factory = factories[ indices.back() ];
57 factory.nChildren = childCounts.back();
58 childCounts.pop_back();
59 indices.pop_back();
60 }
61
63 std::vector<size_t> childCounts;
64 std::vector<size_t> indices;
65};
66}
67
70
72{ return XO("Audacity");}
73
74wxString PrefsPanel::GetVersion() const
75{ return AUDACITY_VERSION_STRING;}
76
78 const Factory &factory, bool expanded,
79 const Registry::Placement &placement )
80{
82 std::make_unique< PrefsItem >( name, factory, expanded ) );
83}
84
86{
87}
88
90{
91}
92
94{
95 return false;
96}
97
99{
100 return {};
101}
102
105{
106 // Once only, cause initial population of preferences for the ordering
107 // of some preference pages that used to be given in a table but are now
108 // separately registered in several .cpp files; the sequence of registration
109 // depends on unspecified accidents of static initialization order across
110 // compilation units, so we need something specific here to preserve old
111 // default appearance of the preference dialog.
112 // But this needs only to mention some strings -- there is no compilation or
113 // link dependency of this source file on those other implementation files.
115 PathStart,
116 {
117 {wxT(""),
118 wxT("Device,Playback,Recording,Quality,GUI,Tracks,ImportExport,Directories,Warnings,Effects,KeyConfig,Mouse")
119 },
120 {wxT("/Tracks"), wxT("TracksBehaviors,Spectrum")},
121 }
122 };
123
124 static Factories factories;
125 static std::once_flag flag;
126
127 std::call_once( flag, []{
128 PrefsItemVisitor visitor{ factories };
130 Registry::Visit( visitor, &top, &sRegistry() );
131 } );
132 return factories;
133}
static RegisteredToolbarFactory factory
const TranslatableString name
Definition: Distortion.cpp:82
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
#define XO(s)
Definition: Internat.h:31
#define BUILTIN_PREFS_PANEL_PREFIX
Definition: PrefsPanel.h:38
static std::once_flag flag
virtual ComponentInterfaceSymbol GetSymbol() const =0
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
const wxString & Internal() const
virtual ManualPageID HelpPageName()
If not empty string, the Help button is added below the panel.
Definition: PrefsPanel.cpp:98
std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) > Factory
Definition: PrefsPanel.h:79
virtual bool ShowsPreviewButton()
Definition: PrefsPanel.cpp:93
virtual VendorSymbol GetVendor() const override
Definition: PrefsPanel.cpp:71
virtual wxString GetVersion() const override
Definition: PrefsPanel.cpp:74
virtual void Cancel()
Definition: PrefsPanel.cpp:89
virtual ~PrefsPanel()
Definition: PrefsPanel.cpp:85
static Factories & DefaultFactories()
Definition: PrefsPanel.cpp:104
std::vector< PrefsPanel::PrefsNode > Factories
Definition: PrefsPanel.h:69
virtual PluginPath GetPath() const override
Definition: PrefsPanel.cpp:68
std::vector< Identifier > Path
Definition: Registry.h:245
void Visit(Visitor &visitor, BaseItem *pTopItem, const GroupItem *pRegistry)
Definition: Registry.cpp:713
void RegisterItem(GroupItem &registry, const Placement &placement, BaseItemPtr pItem)
Definition: Registry.cpp:750
static Registry::GroupItem & sRegistry()
Definition: PrefsPanel.cpp:17
Registration(const wxString &name, const Factory &factory, bool expanded=true, const Registry::Placement &placement={ wxEmptyString, {} })
Definition: PrefsPanel.cpp:77
PrefsItem(const wxString &name, const PrefsPanel::Factory &factory_, bool expanded_)
Definition: PrefsPanel.cpp:27
void BeginGroup(Registry::GroupItem &item, const Path &) override
Definition: PrefsPanel.cpp:41
PrefsItemVisitor(PrefsPanel::Factories &factories_)
Definition: PrefsPanel.cpp:36
void EndGroup(Registry::GroupItem &item, const Path &) override
Definition: PrefsPanel.cpp:51