Audacity 3.2.0
PrefsPanel.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 PrefsPanel.h
6
7 Joshua Haberman
8
9*******************************************************************//*******************************************************************/
26
27#ifndef __AUDACITY_PREFS_PANEL__
28#define __AUDACITY_PREFS_PANEL__
29
30#include <functional>
31#include "../widgets/wxPanelWrapper.h" // to inherit
32#include "ComponentInterface.h"
33#include "Registry.h"
34
35/* A few constants for an attempt at semi-uniformity */
36#define PREFS_FONT_SIZE 8
37
38#define BUILTIN_PREFS_PANEL_PREFIX wxT("Built-in PrefsPanel: ")
39
40/* these are spacing guidelines: ie. radio buttons should have a 5 pixel
41 * border on each side */
42#define RADIO_BUTTON_BORDER 5
43#define TOP_LEVEL_BORDER 5
44#define GENERIC_CONTROL_BORDER 5
45
46class AudacityProject;
47class ShuttleGui;
48
49class AUDACITY_DLL_API PrefsPanel /* not final */
51{
52 public:
53 // An array of PrefsNode specifies the tree of pages in pre-order traversal.
54 struct PrefsNode {
55 using Factory =
56 std::function< PrefsPanel * (
57 wxWindow *parent, wxWindowID winid, AudacityProject *) >;
59 size_t nChildren{ 0 };
60 bool expanded{ false };
61
62 PrefsNode(const Factory &factory_,
63 unsigned nChildren_ = 0,
64 bool expanded_ = true)
65 : factory(factory_), nChildren(nChildren_), expanded(expanded_)
66 {}
67 };
68
69 using Factories = std::vector<PrefsPanel::PrefsNode>;
70 static Factories &DefaultFactories();
71
72 // \brief Type alias for factories such as GUIPrefsFactory that produce a
73 // PrefsPanel, used by the Preferences dialog in a treebook.
74 // The project pointer may be null. Usually it's not needed because
75 // preferences are global. But sometimes you need a project, such as to
76 // preview the preference changes for spectrograms.
77 using Factory =
78 std::function< PrefsPanel * (
79 wxWindow *parent, wxWindowID winid, AudacityProject *) >;
80
81 // Typically you make a static object of this type in the .cpp file that
82 // also implements the PrefsPanel subclass.
83 struct AUDACITY_DLL_API Registration final
84 {
85 Registration( const wxString &name, const Factory &factory,
86 bool expanded = true,
87 const Registry::Placement &placement = { wxEmptyString, {} });
88 };
89
90 PrefsPanel(wxWindow * parent,
91 wxWindowID winid, const TranslatableString &title)
92 : wxPanelWrapper(parent, winid)
93 {
94 SetLabel(title); // Provide visual label
95 SetName(title); // Provide audible label
96 }
97
98 virtual ~PrefsPanel();
99
100 // NEW virtuals
101 virtual void Preview() {} // Make tentative changes
102 virtual bool Commit() = 0; // used to be called "Apply"
103
104
105 virtual PluginPath GetPath() const override;
106 virtual VendorSymbol GetVendor() const override;
107 virtual wxString GetVersion() const override;
108
109 //virtual ComponentInterfaceSymbol GetSymbol();
110 //virtual wxString GetDescription();
111
112
113 // If it returns True, the Preview button is added below the panel
114 // Default returns false
115 virtual bool ShowsPreviewButton();
116 virtual void PopulateOrExchange( ShuttleGui & WXUNUSED(S) ){};
117
119
120 virtual ManualPageID HelpPageName();
121
122 virtual void Cancel();
123};
124
125#endif
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
static const auto title
#define S(N)
Definition: ToChars.cpp:64
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
ComponentInterface provides name / vendor / version functions to identify plugins....
virtual wxString GetVersion() const =0
virtual PluginPath GetPath() const =0
virtual VendorSymbol GetVendor() const =0
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90
std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) > Factory
Definition: PrefsPanel.h:79
virtual bool Commit()=0
virtual void Preview()
Definition: PrefsPanel.h:101
virtual void PopulateOrExchange(ShuttleGui &WXUNUSED(S))
Definition: PrefsPanel.h:116
std::vector< PrefsPanel::PrefsNode > Factories
Definition: PrefsPanel.h:69
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
Holds a msgid for the translation catalog; may also bind format arguments.
void SetLabel(const TranslatableString &label)
static RegisteredToolbarFactory factory
PrefsNode(const Factory &factory_, unsigned nChildren_=0, bool expanded_=true)
Definition: PrefsPanel.h:62
std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) > Factory
Definition: PrefsPanel.h:57