Audacity 3.2.0
LibraryPrefs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 LibraryPrefs.cpp
6
7 Joshua Haberman
8 Dominic Mazzoni
9 James Crook
10
11*******************************************************************//*******************************************************************/
18
19
20#include "LibraryPrefs.h"
21
22#include "ShuttleGui.h"
23
24#include <wx/defs.h>
25#include <wx/stattext.h>
26
28static const auto PathStart = wxT("LibraryPreferences");
29
31{
33 return registry;
34}
35
37 const Identifier &id, Populator populator)
38 : SingleItem{ id }
39 , mPopulator{ move(populator) }
40{}
41
43 const Identifier &id, Populator populator,
44 const Registry::Placement &placement )
45 : RegisteredItem{
46 std::make_unique< PopulatorItem >( id, move(populator) ),
47 placement
48 }
49{}
50
52{
53 return !PopulatorItem::Registry().items.empty();
54}
55
56LibraryPrefs::LibraryPrefs(wxWindow * parent, wxWindowID winid)
57/* i18-hint: refers to optional plug-in software libraries */
58: PrefsPanel(parent, winid, XO("Libraries"))
59{
60 Populate();
61}
62
64{
65}
66
68{
70}
71
73{
74 return XO("Preferences for Library");
75}
76
78{
79 return "Libraries_Preferences";
80}
81
84{
85 //------------------------- Main section --------------------
86 // Now construct the GUI itself.
87 // Use 'eIsCreatingFromPrefs' so that the GUI is
88 // initialised with values from gPrefs.
91 // ----------------------- End of main section --------------
92}
93
100{
101 using namespace Registry;
103 PathStart,
104 { {wxT(""), wxT("MP3,FFmpeg") } },
105 };
106
107 S.SetBorder(2);
108 S.StartScroller();
109
110 struct MyVisitor final : Visitor {
111 MyVisitor( ShuttleGui &S ) : S{ S }
112 {
113 // visit the registry to collect the plug-ins properly
114 // sorted
116 Registry::Visit( *this, &top, &PopulatorItem::Registry() );
117 }
118
119 void Visit( Registry::SingleItem &item, const Path &path ) override
120 {
121 static_cast<PopulatorItem&>(item).mPopulator(S);
122 }
123
124 ShuttleGui &S;
125 } visitor{ S };
126
127 S.EndScroller();
128}
129
131{
134
135 return true;
136}
137
138namespace{
140 [](wxWindow *parent, wxWindowID winid, AudacityProject *) -> PrefsPanel *
141 {
142 wxASSERT(parent); // to justify safenew
144 return safenew LibraryPrefs(parent, winid);
145 else
146 return nullptr;
147 },
148 false,
149 // Register with an explicit ordering hint because this one might be
150 // absent
151 { "", { Registry::OrderingHint::Before, "Directories" } }
152};
153}
154
156{
158}
wxT("CloseDown"))
XO("Cut/Copy/Paste")
static const auto PathStart
#define LIBRARY_PREFS_PLUGIN_SYMBOL
Definition: LibraryPrefs.h:25
auto Visit(Visitor &&vis, Variant &&var)
Mimic some of std::visit, for the case of one visitor only.
Definition: MemoryX.h:628
#define safenew
Definition: MemoryX.h:10
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
#define S(N)
Definition: ToChars.cpp:64
int id
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
A PrefsPanel used to select manage external libraries like the MP3 and FFmpeg encoding libraries.
Definition: LibraryPrefs.h:28
bool Commit() override
ComponentInterfaceSymbol GetSymbol() const override
std::function< void(ShuttleGui &) > Populator
Type of function that adds to the Library preference page.
Definition: LibraryPrefs.h:33
TranslatableString GetDescription() const override
void Populate()
Creates the dialog and its contents.
void PopulateOrExchange(ShuttleGui &S) override
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
LibraryPrefs(wxWindow *parent, wxWindowID winid)
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: Menus.h:35
void Visit(Visitor &visitor, BaseItem *pTopItem, const GroupItem *pRegistry)
Definition: Registry.cpp:713
PrefsPanel::Registration sAttachment
STL namespace.
PopulatorItem(const Identifier &id, Populator populator)
static Registry::GroupItem & Registry()
RegisteredControls(const Identifier &id, Populator populator, const Registry::Placement &placement={ wxEmptyString, {} })
BaseItemPtrs items
Definition: Registry.h:141