mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 00:20:06 +02:00
PrefsPanel::Factory is a specialization of std::function...
... We don't need to define a class for it
This commit is contained in:
parent
8117ca8823
commit
bf005c0dec
@ -1829,9 +1829,8 @@ bool AudacityApp::InitTempDir()
|
||||
}
|
||||
|
||||
// Only want one page of the preferences
|
||||
DirectoriesPrefsFactory directoriesPrefsFactory;
|
||||
PrefsDialog::Factories factories;
|
||||
factories.push_back(&directoriesPrefsFactory);
|
||||
factories.push_back(DirectoriesPrefsFactory());
|
||||
GlobalPrefsDialog dialog(NULL, factories);
|
||||
dialog.ShowModal();
|
||||
|
||||
|
@ -1555,9 +1555,8 @@ bool CommandManager::HandleMenuID(int id, CommandFlag flags, CommandMask mask)
|
||||
#ifdef EXPERIMENTAL_EASY_CHANGE_KEY_BINDINGS
|
||||
if (::wxGetMouseState().ShiftDown()) {
|
||||
// Only want one page of the preferences
|
||||
KeyConfigPrefsFactory keyConfigPrefsFactory{ entry->name };
|
||||
PrefsDialog::Factories factories;
|
||||
factories.push_back(&keyConfigPrefsFactory);
|
||||
factories.push_back(KeyConfigPrefsFactory( entry->name ));
|
||||
GlobalPrefsDialog dialog(GetActiveProject(), factories);
|
||||
dialog.ShowModal();
|
||||
MenuCreator::RebuildAllMenuBars();
|
||||
|
@ -95,8 +95,9 @@ BatchPrefs::~BatchPrefs()
|
||||
{
|
||||
}
|
||||
|
||||
PrefsPanel *BatchPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
BatchPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew BatchPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -39,10 +39,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
/// A PrefsPanelFactory that creates one BatchPrefs panel.
|
||||
class BatchPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one BatchPrefs panel.
|
||||
extern PrefsPanel::Factory BatchPrefsFactory;
|
||||
#endif
|
||||
|
@ -420,8 +420,10 @@ bool DevicePrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *DevicePrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
DevicePrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew DevicePrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -57,11 +57,7 @@ class DevicePrefs final : public PrefsPanel
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one DevicePrefs panel.
|
||||
class DevicePrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one DevicePrefs panel.
|
||||
extern PrefsPanel::Factory DevicePrefsFactory;
|
||||
|
||||
#endif
|
||||
|
@ -287,8 +287,11 @@ bool DirectoriesPrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *DirectoriesPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew DirectoriesPrefs(parent, winid);
|
||||
PrefsPanel::Factory
|
||||
DirectoriesPrefsFactory() {
|
||||
return [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew DirectoriesPrefs(parent, winid);
|
||||
};
|
||||
}
|
||||
|
@ -44,10 +44,7 @@ class DirectoriesPrefs final : public PrefsPanel
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one DirectoriesPrefs panel.
|
||||
class DirectoriesPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one DirectoriesPrefs panel.
|
||||
/// This one is used not only in the Preferences command.
|
||||
extern PrefsPanel::Factory DirectoriesPrefsFactory();
|
||||
#endif
|
||||
|
@ -200,8 +200,9 @@ bool EffectsPrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *EffectsPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
EffectsPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew EffectsPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -37,10 +37,6 @@ class EffectsPrefs final : public PrefsPanel
|
||||
void Populate();
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one EffectsPrefs panel.
|
||||
class EffectsPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one EffectsPrefs panel.
|
||||
extern PrefsPanel::Factory EffectsPrefsFactory;
|
||||
#endif
|
||||
|
@ -822,8 +822,9 @@ void ExtImportPrefsDropTarget::OnLeave()
|
||||
{
|
||||
}
|
||||
|
||||
PrefsPanel *ExtImportPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
ExtImportPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew ExtImportPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -114,10 +114,6 @@ class ExtImportPrefs final : public PrefsPanel
|
||||
};
|
||||
|
||||
|
||||
/// A PrefsPanelFactory that creates one ExtImportPrefs panel.
|
||||
class ExtImportPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one ExtImportPrefs panel.
|
||||
extern PrefsPanel::Factory ExtImportPrefsFactory;
|
||||
#endif
|
||||
|
@ -268,8 +268,9 @@ bool GUIPrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *GUIPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
GUIPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew GUIPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -53,10 +53,6 @@ class GUIPrefs final : public PrefsPanel
|
||||
wxArrayStringEx mRangeChoices;
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one GUIPrefs panel.
|
||||
class GUIPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one GUIPrefs panel.
|
||||
extern PrefsPanel::Factory GUIPrefsFactory;
|
||||
#endif
|
||||
|
@ -128,8 +128,9 @@ bool ImportExportPrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *ImportExportPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
ImportExportPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew ImportExportPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -37,10 +37,6 @@ class ImportExportPrefs final : public PrefsPanel
|
||||
void Populate();
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one ImportExportPrefs panel.
|
||||
class ImportExportPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one ImportExportPrefs panel.
|
||||
extern PrefsPanel::Factory ImportExportPrefsFactory;
|
||||
#endif
|
||||
|
@ -688,9 +688,13 @@ void KeyConfigPrefs::Cancel()
|
||||
return;
|
||||
}
|
||||
|
||||
PrefsPanel *KeyConfigPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
KeyConfigPrefsFactory( const CommandID &name )
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
auto result = safenew KeyConfigPrefs{ parent, winid, mName };
|
||||
return result;
|
||||
return [=](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
auto result = safenew KeyConfigPrefs{ parent, winid, name };
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
@ -93,15 +93,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
/// A PrefsPanelFactory that creates one KeyConfigPrefs panel.
|
||||
class KeyConfigPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
KeyConfigPrefsFactory(const CommandID &name = {})
|
||||
: mName{ name } {}
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
|
||||
private:
|
||||
CommandID mName;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one KeyConfigPrefs panel.
|
||||
/// This factory can be parametrized by name, which specifies a command to be
|
||||
/// focused initially
|
||||
extern PrefsPanel::Factory KeyConfigPrefsFactory(
|
||||
const CommandID &name = {} );
|
||||
#endif
|
||||
|
@ -267,8 +267,9 @@ bool LibraryPrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *LibraryPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
LibraryPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew LibraryPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -50,10 +50,6 @@ class LibraryPrefs final : public PrefsPanel
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one LibraryPrefs panel.
|
||||
class LibraryPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one LibraryPrefs panel.
|
||||
extern PrefsPanel::Factory LibraryPrefsFactory;
|
||||
#endif
|
||||
|
@ -299,10 +299,11 @@ bool MidiIOPrefs::Validate()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *MidiIOPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
MidiIOPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew MidiIOPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -68,12 +68,8 @@ class MidiIOPrefs final : public PrefsPanel
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one MidiIOPrefs panel.
|
||||
class MidiIOPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one MidiIOPrefs panel.
|
||||
extern PrefsPanel::Factory MidiIOPrefsFactory;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -180,8 +180,9 @@ void ModulePrefs::SetModuleStatus(const FilePath &fname, int iStatus){
|
||||
gPrefs->Flush();
|
||||
}
|
||||
|
||||
PrefsPanel *ModulePrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
ModulePrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew ModulePrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -55,10 +55,6 @@ class ModulePrefs final : public PrefsPanel
|
||||
FilePaths mPaths;
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one ModulePrefs panel.
|
||||
class ModulePrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one ModulePrefs panel.
|
||||
extern PrefsPanel::Factory ModulePrefsFactory;
|
||||
#endif
|
||||
|
@ -218,8 +218,9 @@ bool MousePrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *MousePrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
MousePrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew MousePrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -41,10 +41,6 @@ class MousePrefs final : public PrefsPanel
|
||||
wxListCtrl * mList;
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one MousePrefs panel.
|
||||
class MousePrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one MousePrefs panel.
|
||||
extern PrefsPanel::Factory MousePrefsFactory;
|
||||
#endif
|
||||
|
@ -183,9 +183,10 @@ bool PlaybackPrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *PlaybackPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
PlaybackPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew PlaybackPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -39,11 +39,7 @@ class PlaybackPrefs final : public PrefsPanel
|
||||
};
|
||||
|
||||
|
||||
/// A PrefsPanelFactory that creates one PlaybackPrefs panel.
|
||||
class PlaybackPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one PlaybackPrefs panel.
|
||||
extern PrefsPanel::Factory PlaybackPrefsFactory;
|
||||
|
||||
#endif
|
||||
|
@ -487,72 +487,42 @@ PrefsDialog::Factories
|
||||
{
|
||||
// To do, perhaps: create this table by registration, without including each PrefsPanel
|
||||
// class... and thus allowing a plug-in protocol
|
||||
static DevicePrefsFactory devicePrefsFactory;
|
||||
static PlaybackPrefsFactory playbackPrefsFactory;
|
||||
static RecordingPrefsFactory recordingPrefsFactory;
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
static MidiIOPrefsFactory midiIOPrefsFactory;
|
||||
#endif
|
||||
static QualityPrefsFactory qualityPrefsFactory;
|
||||
static GUIPrefsFactory guiPrefsFactory;
|
||||
static TracksPrefsFactory tracksPrefsFactory;
|
||||
static ImportExportPrefsFactory importExportPrefsFactory;
|
||||
static ExtImportPrefsFactory extImportPrefsFactory;
|
||||
static ProjectsPrefsFactory projectsPrefsFactory;
|
||||
#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
|
||||
static LibraryPrefsFactory libraryPrefsFactory;
|
||||
#endif
|
||||
// static WaveformPrefsFactory waveformPrefsFactory;
|
||||
static TracksBehaviorsPrefsFactory tracksBehaviorsPrefsFactory;
|
||||
static SpectrumPrefsFactory spectrumPrefsFactory;
|
||||
static DirectoriesPrefsFactory directoriesPrefsFactory;
|
||||
static WarningsPrefsFactory warningsPrefsFactory;
|
||||
static EffectsPrefsFactory effectsPrefsFactory;
|
||||
#ifdef EXPERIMENTAL_THEME_PREFS
|
||||
static ThemePrefsFactory themePrefsFactory;
|
||||
#endif
|
||||
// static BatchPrefsFactory batchPrefsFactory;
|
||||
static KeyConfigPrefsFactory keyConfigPrefsFactory;
|
||||
static MousePrefsFactory mousePrefsFactory;
|
||||
#ifdef EXPERIMENTAL_MODULE_PREFS
|
||||
static ModulePrefsFactory modulePrefsFactory;
|
||||
#endif
|
||||
|
||||
static PrefsNode nodes[] = {
|
||||
&devicePrefsFactory,
|
||||
&playbackPrefsFactory,
|
||||
&recordingPrefsFactory,
|
||||
DevicePrefsFactory,
|
||||
PlaybackPrefsFactory,
|
||||
RecordingPrefsFactory,
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
&midiIOPrefsFactory,
|
||||
MidiIOPrefsFactory,
|
||||
#endif
|
||||
&qualityPrefsFactory,
|
||||
&guiPrefsFactory,
|
||||
QualityPrefsFactory,
|
||||
GUIPrefsFactory,
|
||||
|
||||
// Group other page(s)
|
||||
PrefsNode(&tracksPrefsFactory, 2),
|
||||
// &waveformPrefsFactory,
|
||||
&tracksBehaviorsPrefsFactory,
|
||||
&spectrumPrefsFactory,
|
||||
PrefsNode(TracksPrefsFactory, 2),
|
||||
// WaveformPrefsFactory(),
|
||||
TracksBehaviorsPrefsFactory,
|
||||
SpectrumPrefsFactory(),
|
||||
|
||||
// Group one other page
|
||||
PrefsNode(&importExportPrefsFactory, 1),
|
||||
&extImportPrefsFactory,
|
||||
PrefsNode(ImportExportPrefsFactory, 1),
|
||||
ExtImportPrefsFactory,
|
||||
|
||||
&projectsPrefsFactory,
|
||||
ProjectsPrefsFactory,
|
||||
#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
|
||||
&libraryPrefsFactory,
|
||||
LibraryPrefsFactory,
|
||||
#endif
|
||||
&directoriesPrefsFactory,
|
||||
&warningsPrefsFactory,
|
||||
&effectsPrefsFactory,
|
||||
DirectoriesPrefsFactory(),
|
||||
WarningsPrefsFactory,
|
||||
EffectsPrefsFactory,
|
||||
#ifdef EXPERIMENTAL_THEME_PREFS
|
||||
&themePrefsFactory,
|
||||
ThemePrefsFactory,
|
||||
#endif
|
||||
// &batchPrefsFactory,
|
||||
&keyConfigPrefsFactory,
|
||||
&mousePrefsFactory,
|
||||
KeyConfigPrefsFactory(),
|
||||
MousePrefsFactory,
|
||||
#ifdef EXPERIMENTAL_MODULE_PREFS
|
||||
&modulePrefsFactory,
|
||||
ModulePrefsFactory,
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -601,7 +571,7 @@ PrefsDialog::PrefsDialog
|
||||
it != end; ++it, ++iPage)
|
||||
{
|
||||
const PrefsNode &node = *it;
|
||||
PrefsPanelFactory &factory = *node.pFactory;
|
||||
const PrefsPanel::Factory &factory = node.factory;
|
||||
wxWindow *const w = factory(mCategories, wxID_ANY);
|
||||
if (stack.empty())
|
||||
// Parameters are: AddPage(page, name, IsSelected, imageId).
|
||||
@ -629,7 +599,7 @@ PrefsDialog::PrefsDialog
|
||||
|
||||
// Unique page, don't show the factory
|
||||
const PrefsNode &node = factories[0];
|
||||
PrefsPanelFactory &factory = *node.pFactory;
|
||||
const PrefsPanel::Factory &factory = node.factory;
|
||||
mUniquePage = factory(this, wxID_ANY);
|
||||
wxWindow * uniquePageWindow = S.Prop(1).AddWindow(mUniquePage, wxEXPAND);
|
||||
// We're not in the wxTreebook, so add the accelerator here
|
||||
|
@ -12,6 +12,7 @@
|
||||
#ifndef __AUDACITY_PREFS_DIALOG__
|
||||
#define __AUDACITY_PREFS_DIALOG__
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include "../widgets/wxPanelWrapper.h" // to inherit
|
||||
#include "../Internat.h"
|
||||
@ -19,7 +20,6 @@
|
||||
class wxTreebook;
|
||||
class wxTreeEvent;
|
||||
class PrefsPanel;
|
||||
class PrefsPanelFactory;
|
||||
class ShuttleGui;
|
||||
|
||||
#ifdef __GNUC__
|
||||
@ -33,14 +33,16 @@ class PrefsDialog /* not final */ : public wxDialogWrapper
|
||||
public:
|
||||
// An array of PrefsNode specifies the tree of pages in pre-order traversal.
|
||||
struct PrefsNode {
|
||||
PrefsPanelFactory * CONST pFactory;
|
||||
using Factory =
|
||||
std::function< PrefsPanel * (wxWindow *parent, wxWindowID winid) >;
|
||||
Factory factory;
|
||||
CONST int nChildren;
|
||||
bool expanded;
|
||||
|
||||
PrefsNode(PrefsPanelFactory *pFactory_,
|
||||
PrefsNode(const Factory &factory_,
|
||||
int nChildren_ = 0,
|
||||
bool expanded_ = true)
|
||||
: pFactory(pFactory_), nChildren(nChildren_), expanded(expanded_)
|
||||
: factory(factory_), nChildren(nChildren_), expanded(expanded_)
|
||||
{}
|
||||
};
|
||||
typedef std::vector<PrefsNode> Factories;
|
||||
|
@ -22,17 +22,12 @@ MousePrefs, QualityPrefs, SpectrumPrefs and ThemePrefs.
|
||||
To actually add the new panel, edit the PrefsDialog constructor
|
||||
to append the panel to its list of panels.
|
||||
|
||||
*******************************************************************//**
|
||||
|
||||
\class PrefsPanelFactory
|
||||
\brief Base class for factories such as GUIPrefsFactory that produce a
|
||||
PrefsPanel.
|
||||
|
||||
*//*******************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_PREFS_PANEL__
|
||||
#define __AUDACITY_PREFS_PANEL__
|
||||
|
||||
#include <functional>
|
||||
#include "../widgets/wxPanelWrapper.h" // to inherit
|
||||
#include "../include/audacity/ComponentInterface.h"
|
||||
|
||||
@ -52,6 +47,11 @@ class ShuttleGui;
|
||||
class PrefsPanel /* not final */ : public wxPanelWrapper, ComponentInterface
|
||||
{
|
||||
public:
|
||||
// \brief Type alias for factories such as GUIPrefsFactory that produce a
|
||||
// PrefsPanel.
|
||||
using Factory =
|
||||
std::function< PrefsPanel * (wxWindow *parent, wxWindowID winid) >;
|
||||
|
||||
PrefsPanel(wxWindow * parent, wxWindowID winid, const wxString &title)
|
||||
: wxPanelWrapper(parent, winid)
|
||||
{
|
||||
@ -86,11 +86,4 @@ class PrefsPanel /* not final */ : public wxPanelWrapper, ComponentInterface
|
||||
virtual void Cancel();
|
||||
};
|
||||
|
||||
class PrefsPanelFactory /* not final */
|
||||
{
|
||||
public:
|
||||
// Precondition: parent != NULL
|
||||
virtual PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -99,8 +99,9 @@ bool ProjectsPrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *ProjectsPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
ProjectsPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew ProjectsPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -37,10 +37,6 @@ class ProjectsPrefs final : public PrefsPanel
|
||||
void Populate();
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one ProjectPrefs panel.
|
||||
class ProjectsPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one ProjectPrefs panel.
|
||||
extern PrefsPanel::Factory ProjectsPrefsFactory;
|
||||
#endif
|
||||
|
@ -277,11 +277,12 @@ bool QualityPrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *QualityPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
QualityPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew QualityPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
||||
sampleFormat QualityPrefs::SampleFormatChoice()
|
||||
{
|
||||
|
@ -59,10 +59,6 @@ class QualityPrefs final : public PrefsPanel
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one QualityPrefs panel.
|
||||
class QualityPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one QualityPrefs panel.
|
||||
extern PrefsPanel::Factory QualityPrefsFactory;
|
||||
#endif
|
||||
|
@ -305,8 +305,9 @@ void RecordingPrefs::OnToggleCustomName(wxCommandEvent & /* Evt */)
|
||||
mToggleCustomName->Enable(mUseCustomTrackName);
|
||||
}
|
||||
|
||||
PrefsPanel *RecordingPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
RecordingPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew RecordingPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -44,10 +44,6 @@ class RecordingPrefs final : public PrefsPanel
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one RecordingPrefs panel.
|
||||
class RecordingPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one RecordingPrefs panel.
|
||||
extern PrefsPanel::Factory RecordingPrefsFactory;
|
||||
#endif
|
||||
|
@ -575,13 +575,12 @@ BEGIN_EVENT_TABLE(SpectrumPrefs, PrefsPanel)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
SpectrumPrefsFactory::SpectrumPrefsFactory(WaveTrack *wt)
|
||||
: mWt(wt)
|
||||
PrefsPanel::Factory
|
||||
SpectrumPrefsFactory( WaveTrack *wt )
|
||||
{
|
||||
}
|
||||
|
||||
PrefsPanel *SpectrumPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew SpectrumPrefs(parent, winid, mWt);
|
||||
return [=](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew SpectrumPrefs(parent, winid, wt);
|
||||
};
|
||||
}
|
||||
|
@ -105,14 +105,8 @@ class SpectrumPrefs final : public PrefsPanel
|
||||
bool mCommitted{};
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one SpectrumPrefs panel.
|
||||
class SpectrumPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
explicit SpectrumPrefsFactory(WaveTrack *wt = 0);
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
|
||||
private:
|
||||
WaveTrack *const mWt;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one SpectrumPrefs panel.
|
||||
/// This factory can be parametrized by a single track, to change settings
|
||||
/// non-globally
|
||||
extern PrefsPanel::Factory SpectrumPrefsFactory( WaveTrack *wt = 0 );
|
||||
#endif
|
||||
|
@ -216,8 +216,9 @@ bool ThemePrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *ThemePrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
ThemePrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew ThemePrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -46,10 +46,6 @@ class ThemePrefs final : public PrefsPanel
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one ThemePrefs panel.
|
||||
class ThemePrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one ThemePrefs panel.
|
||||
extern PrefsPanel::Factory ThemePrefsFactory;
|
||||
#endif
|
||||
|
@ -134,12 +134,9 @@ bool TracksBehaviorsPrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
TracksBehaviorsPrefsFactory::TracksBehaviorsPrefsFactory()
|
||||
{
|
||||
}
|
||||
|
||||
PrefsPanel *TracksBehaviorsPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
TracksBehaviorsPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew TracksBehaviorsPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -43,12 +43,6 @@ class TracksBehaviorsPrefs final : public PrefsPanel
|
||||
wxArrayStringEx mSoloChoices;
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one TracksBehaviorsPrefs panel.
|
||||
class TracksBehaviorsPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
explicit TracksBehaviorsPrefsFactory();
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one TracksBehaviorsPrefs panel.
|
||||
extern PrefsPanel::Factory TracksBehaviorsPrefsFactory;
|
||||
#endif
|
||||
|
@ -406,8 +406,9 @@ bool TracksPrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *TracksPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
TracksPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew TracksPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -54,10 +54,6 @@ class TracksPrefs final : public PrefsPanel
|
||||
static int iPreferencePinned;
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one TracksPrefs panel.
|
||||
class TracksPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one TracksPrefs panel.
|
||||
extern PrefsPanel::Factory TracksPrefsFactory;
|
||||
#endif
|
||||
|
@ -106,8 +106,9 @@ bool WarningsPrefs::Commit()
|
||||
return true;
|
||||
}
|
||||
|
||||
PrefsPanel *WarningsPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
PrefsPanel::Factory
|
||||
WarningsPrefsFactory = [](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew WarningsPrefs(parent, winid);
|
||||
}
|
||||
};
|
||||
|
@ -37,10 +37,6 @@ class WarningsPrefs final : public PrefsPanel
|
||||
void PopulateOrExchange(ShuttleGui & S) override;
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one WarningPrefs panel.
|
||||
class WarningsPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one WarningPrefs panel.
|
||||
extern PrefsPanel::Factory WarningsPrefsFactory;
|
||||
#endif
|
||||
|
@ -247,13 +247,12 @@ EVT_CHOICE(ID_RANGE, WaveformPrefs::OnControl)
|
||||
EVT_CHECKBOX(ID_DEFAULTS, WaveformPrefs::OnDefaults)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
WaveformPrefsFactory::WaveformPrefsFactory(WaveTrack *wt)
|
||||
: mWt(wt)
|
||||
PrefsPanel::Factory
|
||||
WaveformPrefsFactory(WaveTrack *wt)
|
||||
{
|
||||
}
|
||||
|
||||
PrefsPanel *WaveformPrefsFactory::operator () (wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew WaveformPrefs(parent, winid, mWt);
|
||||
return [=](wxWindow *parent, wxWindowID winid)
|
||||
{
|
||||
wxASSERT(parent); // to justify safenew
|
||||
return safenew WaveformPrefs(parent, winid, wt);
|
||||
};
|
||||
}
|
||||
|
@ -63,14 +63,8 @@ private:
|
||||
bool mPopulating;
|
||||
};
|
||||
|
||||
/// A PrefsPanelFactory that creates one WaveformPrefs panel.
|
||||
class WaveformPrefsFactory final : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
explicit WaveformPrefsFactory(WaveTrack *wt = 0);
|
||||
PrefsPanel *operator () (wxWindow *parent, wxWindowID winid) override;
|
||||
|
||||
private:
|
||||
WaveTrack *const mWt;
|
||||
};
|
||||
/// A PrefsPanel::Factory that creates one WaveformPrefs panel.
|
||||
/// This factory can be parametrized by a single track, to change settings
|
||||
/// non-globally
|
||||
extern PrefsPanel::Factory WaveformPrefsFactory(WaveTrack *wt);
|
||||
#endif
|
||||
|
@ -781,13 +781,10 @@ void WaveTrackMenuTable::OnSpectrogramSettings(wxCommandEvent &)
|
||||
}
|
||||
|
||||
WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
|
||||
// WaveformPrefsFactory waveformFactory(pTrack);
|
||||
// TracksBehaviorsPrefsFactory tracksBehaviorsFactory();
|
||||
SpectrumPrefsFactory spectrumFactory(pTrack);
|
||||
|
||||
PrefsDialog::Factories factories;
|
||||
// factories.push_back(&waveformFactory);
|
||||
factories.push_back(&spectrumFactory);
|
||||
// factories.push_back(WaveformPrefsFactory( pTrack ));
|
||||
factories.push_back(SpectrumPrefsFactory( pTrack ));
|
||||
const int page =
|
||||
// (pTrack->GetDisplay() == WaveTrack::Spectrum) ? 1 :
|
||||
0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user