Audacity 3.2.0
WaveformSettings.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5WaveformSettings.h
6
7Paul Licameli
8
9**********************************************************************/
10
11#ifndef __AUDACITY_WAVEFORM_SETTINGS__
12#define __AUDACITY_WAVEFORM_SETTINGS__
13
14#include "ClientData.h" // to inherit
15#include "Prefs.h"
16
17class wxRect;
18
20class WaveChannel;
21class WaveTrack;
22
23class AUDACITY_DLL_API WaveformSettings
24 : public PrefsListener
25 , public ClientData::Cloneable<>
26{
27public:
28
31 static WaveformSettings &Get(const WaveTrack &track);
32
36 static WaveformSettings &Get(const WaveChannel &channel);
37
39 static void Set(
40 WaveChannel &channel, std::unique_ptr<WaveformSettings> pSettings );
41
42 // Singleton for settings that are not per-track
43 class AUDACITY_DLL_API Globals
44 {
45 public:
46 static Globals &Get();
47 void SavePrefs();
48
49 private:
50 Globals();
51 void LoadPrefs();
52 };
53
54 static WaveformSettings &defaults();
55
59 ~WaveformSettings() override;
60
61 PointerType Clone() const override;
62
63 bool IsDefault() const
64 {
65 return this == &defaults();
66 }
67
68 bool Validate(bool quiet);
69 void LoadPrefs();
70 void SavePrefs();
71 void Update();
72
73 void UpdatePrefs() override;
74
75 void ConvertToEnumeratedDBRange();
76 void ConvertToActualDBRange();
77 void NextLowerDBRange();
78 void NextHigherDBRange();
79
80 typedef int ScaleType;
81 enum ScaleTypeValues : int {
85
87 };
88
89 static const EnumValueSymbols &GetScaleNames();
90
93
94 // Convenience
95 bool isLinear() const { return scaleType == stLinearAmp || scaleType == stLinearDb; }
96};
97
98class AUDACITY_DLL_API WaveformScale
99 : public ClientData::Cloneable<>
100{
101public:
103 static WaveformScale &Get(const WaveTrack &track);
104
108 static WaveformScale &Get(const WaveChannel &channel);
109
110 ~WaveformScale() override;
111 PointerType Clone() const override;
112
113 int ZeroLevelYCoordinate(wxRect rect) const;
114
115 void GetDisplayBounds(float &min, float &max) const
116 { min = mDisplayMin; max = mDisplayMax; }
117
118 void SetDisplayBounds(float min, float max)
119 { mDisplayMin = min; mDisplayMax = max; }
120
121 float GetLastScaleType() const { return mLastScaleType; }
122 void SetLastScaleType(int type) { mLastScaleType = type; }
123
124 int GetLastDBRange() const { return mLastdBRange; }
125 void SetLastDBRange(int range) { mLastdBRange = range; }
126
127private:
128 float mDisplayMin = -1.0f, mDisplayMax = 1.0f;
129 int mLastScaleType = -1;
130 int mLastdBRange = -1;
131};
132
133#endif
Utility ClientData::Site to register hooks into a host class that attach client data.
int min(int a, int b)
A listener notified of changes in preferences.
Definition: Prefs.h:652
virtual void UpdatePrefs()=0
Definition: Prefs.cpp:154
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
void SetLastDBRange(int range)
void GetDisplayBounds(float &min, float &max) const
int GetLastDBRange() const
void SetDisplayBounds(float min, float max)
void SetLastScaleType(int type)
~WaveformScale() override
float GetLastScaleType() const
Waveform settings, either for one track or as defaults.
bool isLinear() const
bool IsDefault() const
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:196
A convenient base class defining abstract virtual Clone() for a given kind of pointer.
Definition: ClientData.h:50
virtual PointerType Clone() const =0
Owner< Base > PointerType
Definition: ClientData.h:54
Cloneable & operator=(const Cloneable &)=default