Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
PrefsPanel Class Referenceabstract

Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs, DirectoriesPrefs, GUIPrefs, KeyConfigPrefs, MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs. More...

#include <PrefsPanel.h>

Inheritance diagram for PrefsPanel:
[legend]
Collaboration diagram for PrefsPanel:
[legend]

Classes

struct  PrefsItem
 
struct  PrefsNode
 
struct  Registration
 
struct  Traits
 

Public Types

using Factories = std::vector< PrefsPanel::PrefsNode >
 
using Factory = std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) >
 

Public Member Functions

 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual bool Commit ()=0
 
virtual PluginPath GetPath () const override
 
virtual VendorSymbol GetVendor () const override
 
virtual wxString GetVersion () const override
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual ManualPageID HelpPageName ()
 If not empty string, the Help button is added below the panel. More...
 
virtual void Cancel ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static FactoriesDefaultFactories ()
 

Additional Inherited Members

- Private Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 

Detailed Description

Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs, DirectoriesPrefs, GUIPrefs, KeyConfigPrefs, MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.

The interface works like this: Each panel in the preferences dialog must derive from PrefsPanel. You must override Apply() with code to validate fields (returning false if any are bad), updating the global preferences object gPrefs, and instructing the applicable parts of the program to re-read the preference options.

To actually add the new panel, edit the PrefsDialog constructor to append the panel to its list of panels.

Definition at line 49 of file PrefsPanel.h.

Member Typedef Documentation

◆ Factories

Definition at line 72 of file PrefsPanel.h.

◆ Factory

using PrefsPanel::Factory = std::function< PrefsPanel * ( wxWindow *parent, wxWindowID winid, AudacityProject *) >

Definition at line 80 of file PrefsPanel.h.

Constructor & Destructor Documentation

◆ PrefsPanel()

PrefsPanel::PrefsPanel ( wxWindow *  parent,
wxWindowID  winid,
const TranslatableString title 
)
inline

Definition at line 94 of file PrefsPanel.h.

96 : wxPanelWrapper(parent, winid)
97 {
98 SetLabel(title); // Provide visual label
99 SetName(title); // Provide audible label
100 }
static const auto title
void SetLabel(const TranslatableString &label)

References wxPanelWrapper::SetLabel(), wxPanelWrapper::SetName(), and title.

Here is the call graph for this function:

◆ ~PrefsPanel()

PrefsPanel::~PrefsPanel ( )
virtual

Definition at line 47 of file PrefsPanel.cpp.

48{
49}

Member Function Documentation

◆ Cancel()

void PrefsPanel::Cancel ( )
virtual

Reimplemented in anonymous_namespace{AudioComPrefsPanel.cpp}::AudioComPrefsPanel, KeyConfigPrefs, and ThemePrefs.

Definition at line 51 of file PrefsPanel.cpp.

52{
53}

Referenced by PrefsDialog::OnCancel().

Here is the caller graph for this function:

◆ Commit()

virtual bool PrefsPanel::Commit ( )
pure virtual

◆ DefaultFactories()

PrefsPanel::Factories & PrefsPanel::DefaultFactories ( )
static

Definition at line 66 of file PrefsPanel.cpp.

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,ImportExport,Directories,Warnings,Effects,KeyConfig,Mouse")
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
static const auto PathStart
Definition: PrefsPanel.cpp:14
static std::once_flag flag
std::vector< PrefsPanel::PrefsNode > Factories
Definition: PrefsPanel.h:72
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
static Registry::GroupItem< Traits > & Registry()
Definition: PrefsPanel.cpp:17

References PrefsPanel::PrefsItem::expanded, PrefsPanel::PrefsItem::factory, factory, flag, Registry::NoOp, PathStart, PrefsPanel::PrefsItem::Registry(), Registry::Visit(), and wxT().

Here is the call graph for this function:

◆ GetPath()

PluginPath PrefsPanel::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 30 of file PrefsPanel.cpp.

#define BUILTIN_PREFS_PANEL_PREFIX
Definition: PrefsPanel.h:38
virtual ComponentInterfaceSymbol GetSymbol() const =0
const wxString & Internal() const

References BUILTIN_PREFS_PANEL_PREFIX, ComponentInterface::GetSymbol(), and ComponentInterfaceSymbol::Internal().

Here is the call graph for this function:

◆ GetVendor()

VendorSymbol PrefsPanel::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 33 of file PrefsPanel.cpp.

34{ return XO("Audacity");}
XO("Cut/Copy/Paste")

References XO().

Here is the call graph for this function:

◆ GetVersion()

wxString PrefsPanel::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 36 of file PrefsPanel.cpp.

37{ return AUDACITY_VERSION_STRING;}

◆ HelpPageName()

ManualPageID PrefsPanel::HelpPageName ( )
virtual

If not empty string, the Help button is added below the panel.

Default returns empty string.

Reimplemented in LibraryPrefs, ApplicationPrefs, BatchPrefs, DevicePrefs, DirectoriesPrefs, EffectsPrefs, ExtImportPrefs, GUIPrefs, ImportExportPrefs, KeyConfigPrefs, MidiIOPrefs, ModulePrefs, PlaybackPrefs, QualityPrefs, RecordingPrefs, SpectrumPrefs, ThemePrefs, TracksBehaviorsPrefs, TracksPrefs, and WaveformPrefs.

Definition at line 60 of file PrefsPanel.cpp.

61{
62 return {};
63}

◆ PopulateOrExchange()

virtual void PrefsPanel::PopulateOrExchange ( ShuttleGui WXUNUSEDS)
inlinevirtual

Definition at line 120 of file PrefsPanel.h.

120{};

Referenced by PrefsDialog::ShuttleAll().

Here is the caller graph for this function:

◆ Preview()

virtual void PrefsPanel::Preview ( )
inlinevirtual

Reimplemented in SpectrumPrefs.

Definition at line 105 of file PrefsPanel.h.

105{} // Make tentative changes

Referenced by PrefsDialog::OnOK().

Here is the caller graph for this function:

◆ ShowsPreviewButton()

bool PrefsPanel::ShowsPreviewButton ( )
virtual

Reimplemented in SpectrumPrefs, and WaveformPrefs.

Definition at line 55 of file PrefsPanel.cpp.

56{
57 return false;
58}

Referenced by PrefsDialog::PrefsDialog().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: