mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-26 07:13:49 +01:00
Boilerplate for empty waveform preferences, analogous to Spectra
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
#include "ThemePrefs.h"
|
||||
#include "TracksPrefs.h"
|
||||
#include "WarningsPrefs.h"
|
||||
#include "WaveformPrefs.h"
|
||||
#include "ExtImportPrefs.h"
|
||||
|
||||
#ifdef EXPERIMENTAL_MIDI_OUT
|
||||
@@ -131,6 +132,7 @@ PrefsDialog::Factories
|
||||
#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
|
||||
static LibraryPrefsFactory libraryPrefsFactory;
|
||||
#endif
|
||||
static WaveformPrefsFactory waveformPrefsFactory;
|
||||
static SpectrumPrefsFactory spectrumPrefsFactory;
|
||||
static DirectoriesPrefsFactory directoriesPrefsFactory;
|
||||
static WarningsPrefsFactory warningsPrefsFactory;
|
||||
@@ -161,6 +163,7 @@ PrefsDialog::Factories
|
||||
#if !defined(DISABLE_DYNAMIC_LOADING_FFMPEG) || !defined(DISABLE_DYNAMIC_LOADING_LAME)
|
||||
&libraryPrefsFactory,
|
||||
#endif
|
||||
&waveformPrefsFactory,
|
||||
&spectrumPrefsFactory,
|
||||
&directoriesPrefsFactory,
|
||||
&warningsPrefsFactory,
|
||||
|
||||
209
src/prefs/WaveformPrefs.cpp
Normal file
209
src/prefs/WaveformPrefs.cpp
Normal file
@@ -0,0 +1,209 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
WaveformPrefs.cpp
|
||||
|
||||
Paul Licameli
|
||||
|
||||
*******************************************************************//**
|
||||
|
||||
\class WaveformPrefs
|
||||
\brief A PrefsPanel for spectrum settings.
|
||||
|
||||
*//*******************************************************************/
|
||||
|
||||
#include "../Audacity.h"
|
||||
#include "WaveformPrefs.h"
|
||||
|
||||
#include <wx/checkbox.h>
|
||||
|
||||
#include "../Project.h"
|
||||
#include "../TrackPanel.h"
|
||||
#include "../ShuttleGUI.h"
|
||||
|
||||
WaveformPrefs::WaveformPrefs(wxWindow * parent, WaveTrack *wt)
|
||||
: PrefsPanel(parent, _("Waveforms"))
|
||||
, mWt(wt)
|
||||
, mPopulating(false)
|
||||
{
|
||||
if (mWt) {
|
||||
WaveformSettings &settings = wt->GetWaveformSettings();
|
||||
mDefaulted = (&WaveformSettings::defaults() == &settings);
|
||||
mTempSettings = settings;
|
||||
}
|
||||
else {
|
||||
mTempSettings = WaveformSettings::defaults();
|
||||
mDefaulted = false;
|
||||
}
|
||||
|
||||
Populate();
|
||||
}
|
||||
|
||||
WaveformPrefs::~WaveformPrefs()
|
||||
{
|
||||
}
|
||||
|
||||
enum {
|
||||
ID_DEFAULTS = 10001,
|
||||
ID_APPLY,
|
||||
};
|
||||
|
||||
void WaveformPrefs::Populate()
|
||||
{
|
||||
// Create control objects
|
||||
|
||||
//------------------------- Main section --------------------
|
||||
// Now construct the GUI itself.
|
||||
ShuttleGui S(this, eIsCreating);
|
||||
PopulateOrExchange(S);
|
||||
// ----------------------- End of main section --------------
|
||||
}
|
||||
|
||||
void WaveformPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
{
|
||||
mPopulating = true;
|
||||
|
||||
S.SetBorder(2);
|
||||
|
||||
// S.StartStatic(_("Track Settings"));
|
||||
{
|
||||
mDefaultsCheckbox = 0;
|
||||
if (mWt) {
|
||||
mDefaultsCheckbox = S.Id(ID_DEFAULTS).TieCheckBox(_("Defaults"), mDefaulted);
|
||||
}
|
||||
|
||||
S.StartStatic(_("Display"));
|
||||
{
|
||||
S.StartTwoColumn();
|
||||
{
|
||||
}
|
||||
S.EndTwoColumn();
|
||||
}
|
||||
S.EndStatic();
|
||||
}
|
||||
// S.EndStatic();
|
||||
|
||||
/*
|
||||
S.StartStatic(_("Global settings"));
|
||||
{
|
||||
}
|
||||
S.EndStatic();
|
||||
*/
|
||||
|
||||
S.StartMultiColumn(2, wxALIGN_RIGHT);
|
||||
{
|
||||
S.Id(ID_APPLY).AddButton(_("Appl&y"));
|
||||
}
|
||||
S.EndMultiColumn();
|
||||
|
||||
mPopulating = false;
|
||||
}
|
||||
|
||||
bool WaveformPrefs::Validate()
|
||||
{
|
||||
// Do checking for whole numbers
|
||||
|
||||
// ToDo: use wxIntegerValidator<unsigned> when available
|
||||
|
||||
ShuttleGui S(this, eIsGettingFromDialog);
|
||||
PopulateOrExchange(S);
|
||||
|
||||
// Delegate range checking to WaveformSettings class
|
||||
const bool result = mTempSettings.Validate(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool WaveformPrefs::Apply()
|
||||
{
|
||||
const bool isOpenPage = this->IsShown();
|
||||
|
||||
WaveTrack *const partner =
|
||||
mWt ? static_cast<WaveTrack*>(mWt->GetLink()) : 0;
|
||||
|
||||
ShuttleGui S(this, eIsGettingFromDialog);
|
||||
PopulateOrExchange(S);
|
||||
|
||||
WaveformSettings::Globals::Get().SavePrefs();
|
||||
|
||||
if (mWt) {
|
||||
if (mDefaulted) {
|
||||
mWt->SetWaveformSettings(NULL);
|
||||
if (partner)
|
||||
partner->SetWaveformSettings(NULL);
|
||||
}
|
||||
else {
|
||||
WaveformSettings *pSettings =
|
||||
&mWt->GetIndependentWaveformSettings();
|
||||
*pSettings = mTempSettings;
|
||||
if (partner) {
|
||||
pSettings = &partner->GetIndependentWaveformSettings();
|
||||
*pSettings = mTempSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!mWt || mDefaulted) {
|
||||
WaveformSettings *const pSettings =
|
||||
&WaveformSettings::defaults();
|
||||
*pSettings = mTempSettings;
|
||||
pSettings->SavePrefs();
|
||||
}
|
||||
|
||||
if (mWt && isOpenPage) {
|
||||
// Future: open page will determine view type
|
||||
/*
|
||||
mWt->SetDisplay(WaveTrack::Waveform);
|
||||
if (partner)
|
||||
partner->SetDisplay(WaveTrack::Waveform);
|
||||
*/
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WaveformPrefs::OnControl(wxCommandEvent&)
|
||||
{
|
||||
// Common routine for most controls
|
||||
// If any per-track setting is changed, break the association with defaults
|
||||
// Skip this, and View Settings... will be able to change defaults instead
|
||||
// when the checkbox is on, as in the original design.
|
||||
|
||||
if (mDefaultsCheckbox && !mPopulating) {
|
||||
mDefaulted = false;
|
||||
mDefaultsCheckbox->SetValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
void WaveformPrefs::OnDefaults(wxCommandEvent &)
|
||||
{
|
||||
if (mDefaultsCheckbox->IsChecked()) {
|
||||
mTempSettings = WaveformSettings::defaults();
|
||||
mDefaulted = true;
|
||||
ShuttleGui S(this, eIsSettingToDialog);
|
||||
PopulateOrExchange(S);
|
||||
}
|
||||
}
|
||||
|
||||
void WaveformPrefs::OnApply(wxCommandEvent &)
|
||||
{
|
||||
if (Validate()) {
|
||||
Apply();
|
||||
::GetActiveProject()->GetTrackPanel()->Refresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(WaveformPrefs, PrefsPanel)
|
||||
EVT_CHECKBOX(ID_DEFAULTS, WaveformPrefs::OnDefaults)
|
||||
EVT_BUTTON(ID_APPLY, WaveformPrefs::OnApply)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
WaveformPrefsFactory::WaveformPrefsFactory(WaveTrack *wt)
|
||||
: mWt(wt)
|
||||
{
|
||||
}
|
||||
|
||||
PrefsPanel *WaveformPrefsFactory::Create(wxWindow *parent)
|
||||
{
|
||||
return new WaveformPrefs(parent, mWt);
|
||||
}
|
||||
58
src/prefs/WaveformPrefs.h
Normal file
58
src/prefs/WaveformPrefs.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
WaveformPrefs.h
|
||||
|
||||
Paul Licameli
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
|
||||
#ifndef __AUDACITY_WAVEFORM_PREFS__
|
||||
#define __AUDACITY_WAVEFORM_PREFS__
|
||||
|
||||
#include "PrefsPanel.h"
|
||||
#include "WaveformSettings.h"
|
||||
|
||||
class ShuttleGui;
|
||||
class WaveTrack;
|
||||
class wxCheckBox;
|
||||
|
||||
class WaveformPrefs :public PrefsPanel
|
||||
{
|
||||
public:
|
||||
WaveformPrefs(wxWindow * parent, WaveTrack *wt);
|
||||
virtual ~WaveformPrefs();
|
||||
virtual bool Apply();
|
||||
virtual bool Validate();
|
||||
|
||||
private:
|
||||
void Populate();
|
||||
void PopulateOrExchange(ShuttleGui & S);
|
||||
|
||||
void OnControl(wxCommandEvent&);
|
||||
void OnDefaults(wxCommandEvent&);
|
||||
void OnApply(wxCommandEvent &);
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
WaveTrack *const mWt;
|
||||
bool mDefaulted;
|
||||
|
||||
wxCheckBox *mDefaultsCheckbox;
|
||||
|
||||
WaveformSettings mTempSettings;
|
||||
|
||||
bool mPopulating;
|
||||
};
|
||||
|
||||
class WaveformPrefsFactory : public PrefsPanelFactory
|
||||
{
|
||||
public:
|
||||
explicit WaveformPrefsFactory(WaveTrack *wt = 0);
|
||||
virtual PrefsPanel *Create(wxWindow *parent);
|
||||
|
||||
private:
|
||||
WaveTrack *const mWt;
|
||||
};
|
||||
#endif
|
||||
86
src/prefs/WaveformSettings.cpp
Normal file
86
src/prefs/WaveformSettings.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
WaveformSettings.cpp
|
||||
|
||||
Paul Licameli
|
||||
|
||||
*******************************************************************//**
|
||||
|
||||
\class WaveformSettings
|
||||
\brief Waveform settings, either for one track or as defaults.
|
||||
|
||||
*//*******************************************************************/
|
||||
|
||||
#include "../Audacity.h"
|
||||
#include "WaveformSettings.h"
|
||||
|
||||
WaveformSettings::Globals::Globals()
|
||||
{
|
||||
LoadPrefs();
|
||||
}
|
||||
|
||||
void WaveformSettings::Globals::SavePrefs()
|
||||
{
|
||||
}
|
||||
|
||||
void WaveformSettings::Globals::LoadPrefs()
|
||||
{
|
||||
}
|
||||
|
||||
WaveformSettings::Globals
|
||||
&WaveformSettings::Globals::Get()
|
||||
{
|
||||
static Globals instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
WaveformSettings::WaveformSettings()
|
||||
{
|
||||
LoadPrefs();
|
||||
}
|
||||
|
||||
WaveformSettings::WaveformSettings(const WaveformSettings &other)
|
||||
{
|
||||
}
|
||||
|
||||
WaveformSettings &WaveformSettings::operator= (const WaveformSettings &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
WaveformSettings& WaveformSettings::defaults()
|
||||
{
|
||||
static WaveformSettings instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
bool WaveformSettings::Validate(bool quiet)
|
||||
{
|
||||
quiet;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void WaveformSettings::LoadPrefs()
|
||||
{
|
||||
// Enforce legal values
|
||||
Validate(true);
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
void WaveformSettings::SavePrefs()
|
||||
{
|
||||
}
|
||||
|
||||
void WaveformSettings::Update()
|
||||
{
|
||||
}
|
||||
|
||||
WaveformSettings::~WaveformSettings()
|
||||
{
|
||||
}
|
||||
46
src/prefs/WaveformSettings.h
Normal file
46
src/prefs/WaveformSettings.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
WaveformSettings.h
|
||||
|
||||
Paul Licameli
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_WAVEFORM_SETTINGS__
|
||||
#define __AUDACITY_WAVEFORM_SETTINGS__
|
||||
|
||||
class WaveformSettings
|
||||
{
|
||||
public:
|
||||
|
||||
// Singleton for settings that are not per-track
|
||||
class Globals
|
||||
{
|
||||
public:
|
||||
static Globals &Get();
|
||||
void SavePrefs();
|
||||
|
||||
private:
|
||||
Globals();
|
||||
void LoadPrefs();
|
||||
};
|
||||
|
||||
static WaveformSettings &defaults();
|
||||
WaveformSettings();
|
||||
WaveformSettings(const WaveformSettings &other);
|
||||
WaveformSettings& operator= (const WaveformSettings &other);
|
||||
~WaveformSettings();
|
||||
|
||||
bool IsDefault() const
|
||||
{
|
||||
return this == &defaults();
|
||||
}
|
||||
|
||||
bool Validate(bool quiet);
|
||||
void LoadPrefs();
|
||||
void SavePrefs();
|
||||
void Update();
|
||||
};
|
||||
#endif
|
||||
Reference in New Issue
Block a user