Audacity  2.2.2
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
WaveformSettings Class Reference

Waveform settings, either for one track or as defaults. More...

#include <WaveformSettings.h>

Classes

class  Globals
 

Public Types

enum  ScaleTypeValues : int { stLinear, stLogarithmic, stNumScaleTypes }
 
typedef int ScaleType
 

Public Member Functions

 WaveformSettings ()
 
 WaveformSettings (const WaveformSettings &other)
 
WaveformSettingsoperator= (const WaveformSettings &other)
 
 ~WaveformSettings ()
 
bool IsDefault () const
 
bool Validate (bool quiet)
 
void LoadPrefs ()
 
void SavePrefs ()
 
void Update ()
 
void ConvertToEnumeratedDBRange ()
 
void ConvertToActualDBRange ()
 
void NextLowerDBRange ()
 
void NextHigherDBRange ()
 
bool isLinear () const
 

Static Public Member Functions

static WaveformSettingsdefaults ()
 
static const wxArrayString & GetScaleNames ()
 

Public Attributes

ScaleType scaleType
 
int dBRange
 

Detailed Description

Waveform settings, either for one track or as defaults.

Definition at line 16 of file WaveformSettings.h.

Member Typedef Documentation

Definition at line 53 of file WaveformSettings.h.

Member Enumeration Documentation

Enumerator
stLinear 
stLogarithmic 
stNumScaleTypes 

Definition at line 54 of file WaveformSettings.h.

Constructor & Destructor Documentation

WaveformSettings::WaveformSettings ( )

Definition at line 49 of file WaveformSettings.cpp.

References LoadPrefs().

50 {
51  LoadPrefs();
52 }
WaveformSettings::WaveformSettings ( const WaveformSettings other)

Definition at line 54 of file WaveformSettings.cpp.

55  : scaleType(other.scaleType)
56  , dBRange(other.dBRange)
57 {
58 }
WaveformSettings::~WaveformSettings ( )

Definition at line 166 of file WaveformSettings.cpp.

167 {
168 }

Member Function Documentation

void WaveformSettings::ConvertToActualDBRange ( )

Definition at line 125 of file WaveformSettings.cpp.

References dBRange, GUIPrefs::GetRangeChoices(), and min().

Referenced by WaveformPrefs::Commit(), NextHigherDBRange(), NextLowerDBRange(), WaveformPrefs::Validate(), and Validate().

126 {
127  wxArrayString codes;
128  GUIPrefs::GetRangeChoices(NULL, &codes);
129  long value = 0;
130  codes[std::max(0, std::min((int)(codes.size()) - 1, dBRange))]
131  .ToLong(&value);
132  dBRange = (int)(value);
133 }
static void GetRangeChoices(wxArrayString *pChoices, wxArrayString *pCodes)
Definition: GUIPrefs.cpp:50
int min(int a, int b)
void WaveformSettings::ConvertToEnumeratedDBRange ( )

Definition at line 110 of file WaveformSettings.cpp.

References dBRange, and GUIPrefs::GetRangeChoices().

Referenced by WaveformPrefs::Commit(), NextHigherDBRange(), NextLowerDBRange(), WaveformPrefs::OnDefaults(), WaveformPrefs::Validate(), Validate(), and WaveformPrefs::WaveformPrefs().

111 {
112  // Assumes the codes are in ascending sequence.
113  wxArrayString codes;
114  GUIPrefs::GetRangeChoices(NULL, &codes);
115  int ii = 0;
116  for (int nn = codes.size(); ii < nn; ++ii) {
117  long value = 0;
118  codes[ii].ToLong(&value);
119  if (dBRange < value)
120  break;
121  }
122  dBRange = std::max(0, ii - 1);
123 }
static void GetRangeChoices(wxArrayString *pChoices, wxArrayString *pCodes)
Definition: GUIPrefs.cpp:50
WaveformSettings & WaveformSettings::defaults ( )
static
const wxArrayString & WaveformSettings::GetScaleNames ( )
static

Definition at line 150 of file WaveformSettings.cpp.

References _().

Referenced by WaveformPrefs::Populate().

151 {
152  class ScaleNamesArray final : public TranslatableStringArray
153  {
154  void Populate() override
155  {
156  // Keep in correspondence with enum WaveTrack::WaveTrackDisplay:
157  mContents.Add(_("Linear"));
158  mContents.Add(_("Logarithmic"));
159  }
160  };
161 
162  static ScaleNamesArray theArray;
163  return theArray.Get();
164 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
bool WaveformSettings::IsDefault ( ) const
inline

Definition at line 38 of file WaveformSettings.h.

References defaults().

39  {
40  return this == &defaults();
41  }
static WaveformSettings & defaults()
bool WaveformSettings::isLinear ( ) const
inline
void WaveformSettings::LoadPrefs ( )

Definition at line 87 of file WaveformSettings.cpp.

References dBRange, ENV_DB_KEY, ENV_DB_RANGE, gPrefs, scaleType, Update(), and Validate().

Referenced by PrefsDialog::OnOK(), AudacityProject::OnReloadPreferences(), and WaveformSettings().

88 {
89  scaleType = ScaleType(gPrefs->Read(wxT("/Waveform/ScaleType"), 0L));
90  bool newPrefFound = gPrefs->Read(wxT("/Waveform/dBRange"), &dBRange);
91  if (!newPrefFound)
93 
94  // Enforce legal values
95  Validate(true);
96 
97  Update();
98 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
#define ENV_DB_KEY
Definition: GUISettings.h:15
bool Validate(bool quiet)
#define ENV_DB_RANGE
Definition: GUISettings.h:16
void WaveformSettings::NextHigherDBRange ( )
void WaveformSettings::NextLowerDBRange ( )
WaveformSettings & WaveformSettings::operator= ( const WaveformSettings other)

Definition at line 60 of file WaveformSettings.cpp.

References dBRange, and scaleType.

61 {
62  if (this != &other) {
63  scaleType = other.scaleType;
64  dBRange = other.dBRange;
65  }
66  return *this;
67 }
void WaveformSettings::SavePrefs ( )

Definition at line 100 of file WaveformSettings.cpp.

References dBRange, gPrefs, and scaleType.

Referenced by WaveformPrefs::Commit().

101 {
102  gPrefs->Write(wxT("/Waveform/ScaleType"), long(scaleType));
103  gPrefs->Write(wxT("/Waveform/dBRange"), long(dBRange));
104 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void WaveformSettings::Update ( )

Definition at line 106 of file WaveformSettings.cpp.

Referenced by LoadPrefs().

107 {
108 }
bool WaveformSettings::Validate ( bool  quiet)

Definition at line 75 of file WaveformSettings.cpp.

References ConvertToActualDBRange(), ConvertToEnumeratedDBRange(), min(), scaleType, and stNumScaleTypes.

Referenced by LoadPrefs(), and WaveformPrefs::Validate().

76 {
78  std::max(0, std::min((int)(stNumScaleTypes) - 1, (int)(scaleType)))
79  );
80 
83 
84  return true;
85 }
int min(int a, int b)

Member Data Documentation

int WaveformSettings::dBRange
ScaleType WaveformSettings::scaleType

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