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
14static const auto PathStart = L"Preferences";
15
16
18{
19 static Registry::GroupItem<Traits> registry{ PathStart };
20 return registry;
21}
22
24 const PrefsPanel::Factory &factory, bool expanded
25) : GroupItem{ name }
26 , factory{ factory }
27 , expanded{ expanded }
28{}
29
32
34{ return XO("Audacity");}
35
36wxString PrefsPanel::GetVersion() const
37{ return AUDACITY_VERSION_STRING;}
38
40 const Factory &factory, bool expanded,
41 const Registry::Placement &placement )
42 : RegisteredItem{
43 std::make_unique< PrefsItem >( name, factory, expanded ), placement }
44{
45}
46
48{
49}
50
52{
53}
54
56{
57 return false;
58}
59
61{
62 return {};
63}
64
67{
68 // Once only, cause initial population of preferences for the ordering
69 // of some preference pages that used to be given in a table but are now
70 // separately registered in several .cpp files; the sequence of registration
71 // depends on unspecified accidents of static initialization order across
72 // compilation units, so we need something specific here to preserve old
73 // default appearance of the preference dialog.
74 // But this needs only to mention some strings -- there is no compilation or
75 // link dependency of this source file on those other implementation files.
78 {
79 {wxT(""),
80 wxT("Device,Playback,Recording,Quality,GUI,Tracks,Directories,Warnings,Effects,KeyConfig,Mouse,Module,Application")
81 },
82 {wxT("/Tracks"), wxT("TracksBehaviors,Spectrum")},
83 }
84 };
85
86 static Factories sFactories;
87 static std::once_flag flag;
88
89 std::call_once(flag, []{
90 // Collect registry tree nodes into a vector, in preorder.
91 std::vector<size_t> childCounts;
92 std::vector<size_t> indices;
93 childCounts.push_back(0);
94 Factories factories;
95
97 Registry::Visit(std::tuple{
98 [&](const PrefsItem &item, auto&) {
99 if (!item.factory)
100 return;
101 indices.push_back(factories.size());
102 factories.emplace_back(item.factory, 0, item.expanded);
103 ++childCounts.back();
104 childCounts.push_back(0);
105 },
107 [&](const PrefsItem &item, auto&) {
108 if (!item.factory)
109 return;
110 auto &factory = factories[indices.back()];
111 factory.nChildren = childCounts.back();
112 childCounts.pop_back();
113 indices.pop_back();
114 }
115 }, &top, &PrefsItem::Registry());
116 sFactories.swap(factories);
117 });
118 return sFactories;
119}
wxT("CloseDown"))
static RegisteredToolbarFactory factory
const TranslatableString name
Definition: Distortion.cpp:76
XO("Cut/Copy/Paste")
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
static const auto PathStart
Definition: PrefsPanel.cpp:14
#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:60
std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) > Factory
Definition: PrefsPanel.h:82
virtual bool ShowsPreviewButton()
Definition: PrefsPanel.cpp:55
virtual VendorSymbol GetVendor() const override
Definition: PrefsPanel.cpp:33
virtual wxString GetVersion() const override
Definition: PrefsPanel.cpp:36
virtual void Cancel()
Definition: PrefsPanel.cpp:51
virtual ~PrefsPanel()
Definition: PrefsPanel.cpp:47
static Factories & DefaultFactories()
Definition: PrefsPanel.cpp:66
std::vector< PrefsPanel::PrefsNode > Factories
Definition: PrefsPanel.h:72
virtual PluginPath GetPath() const override
Definition: PrefsPanel.cpp:30
constexpr auto NoOp
Supply this when one member of a visitor function triple isn't needed.
Definition: Registry.h:530
void Visit(const Visitors &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
Definition: Registry.h:609
STL namespace.
PrefsPanel::Factory factory
Definition: PrefsPanel.h:134
static Registry::GroupItem< Traits > & Registry()
Definition: PrefsPanel.cpp:17
PrefsItem(const wxString &name, const PrefsPanel::Factory &factory, bool expanded)
Definition: PrefsPanel.cpp:23
Registration(const wxString &name, const Factory &factory, bool expanded=true, const Registry::Placement &placement={ wxEmptyString, {} })
Definition: PrefsPanel.cpp:39