Audacity  3.0.3
ProjectSettings.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 ProjectSettings.h
6 
7 Paul Licameli split from AudacityProject.h
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_PROJECT_SETTINGS__
12 #define __AUDACITY_PROJECT_SETTINGS__
13 
14 #include <atomic>
15 #include <wx/event.h> // to declare custom event type
16 
17 #include "ClientData.h" // to inherit
18 #include "Prefs.h" // to inherit
19 #include "audacity/Types.h"
20 
21 class AudacityProject;
22 
23 // Sent to the project when certain settings change
24 wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
25  EVT_PROJECT_SETTINGS_CHANGE, wxCommandEvent);
26 
27 enum
28 {
32 };
33 
34 namespace ToolCodes {
35 enum {
43 
46 };
47 }
48 
51 class AUDACITY_DLL_API ProjectSettings final
52  : public ClientData::Base
53  , private PrefsListener
54 {
55 public:
56  static ProjectSettings &Get( AudacityProject &project );
57  static const ProjectSettings &Get( const AudacityProject &project );
58 
59  // Values retrievable from GetInt() of the event for settings change
60  enum EventCode : int {
62  ChangedProjectRate
63  };
64 
65  explicit ProjectSettings( AudacityProject &project );
66  ProjectSettings( const ProjectSettings & ) PROHIBITED;
67  ProjectSettings &operator=( const ProjectSettings & ) PROHIBITED;
68 
69 
70  bool GetTracksFitVerticallyZoomed() const { return mTracksFitVerticallyZoomed; } //lda
71  void SetTracksFitVerticallyZoomed(bool flag) { mTracksFitVerticallyZoomed = flag; } //lda
72 
73  bool GetShowId3Dialog() const { return mShowId3Dialog; } //lda
74  void SetShowId3Dialog(bool flag) { mShowId3Dialog = flag; } //lda
75 
76  bool IsSyncLocked() const;
77  void SetSyncLock(bool flag);
78 
79  // Rate
80 
81  void SetRate(double rate);
82  double GetRate() const;
83 
84  // Snap To
85 
86  void SetSnapTo(int snap);
87  int GetSnapTo() const;
88 
89  // Current tool
90 
91  void SetTool(int tool) { mCurrentTool = tool; }
92  int GetTool() const { return mCurrentTool; }
93 
94  // Speed play
95  double GetPlaySpeed() const {
96  return mPlaySpeed.load( std::memory_order_relaxed ); }
97  void SetPlaySpeed( double value ) {
98  mPlaySpeed.store( value, std::memory_order_relaxed ); }
99 
100  // Selection Format
101  void SetSelectionFormat(const NumericFormatSymbol & format);
102  const NumericFormatSymbol & GetSelectionFormat() const;
103 
104  // AudioTime format
105  void SetAudioTimeFormat(const NumericFormatSymbol & format);
106  const NumericFormatSymbol & GetAudioTimeFormat() const;
107 
108  // Spectral Selection Formats
109  void SetFrequencySelectionFormatName(const NumericFormatSymbol & format);
110  const NumericFormatSymbol & GetFrequencySelectionFormatName() const;
111 
112  void SetBandwidthSelectionFormatName(const NumericFormatSymbol & format);
113  const NumericFormatSymbol & GetBandwidthSelectionFormatName() const;
114 
115  bool IsSoloSimple() const { return mSoloPref == wxT("Simple"); }
116  bool IsSoloNone() const { return mSoloPref == wxT("None"); }
117 
118  bool EmptyCanBeDirty() const { return mEmptyCanBeDirty; }
119 
120  bool GetShowSplashScreen() const { return mShowSplashScreen; }
121 
122 private:
123  void UpdatePrefs() override;
124 
126 
131 
132  wxString mSoloPref;
133 
134  double mRate;
135 
136  // This is atomic because scrubber may read it in a separate thread from
137  // the main
138  std::atomic<double> mPlaySpeed{};
139 
140  int mSnapTo;
141 
143 
144  bool mTracksFitVerticallyZoomed{ false }; //lda
145  bool mShowId3Dialog{ true }; //lda
146  bool mIsSyncLocked{ false };
149 };
150 
151 #endif
ProjectSettings::mProject
AudacityProject & mProject
Definition: ProjectSettings.h:125
ProjectSettings::GetPlaySpeed
double GetPlaySpeed() const
Definition: ProjectSettings.h:95
SNAP_OFF
@ SNAP_OFF
Definition: ProjectSettings.h:29
ProjectSettings::mFrequencySelectionFormatName
NumericFormatSymbol mFrequencySelectionFormatName
Definition: ProjectSettings.h:128
ToolCodes::drawTool
@ drawTool
Definition: ProjectSettings.h:38
ToolCodes::selectTool
@ selectTool
Definition: ProjectSettings.h:36
ToolCodes
Definition: ProjectSettings.h:34
ProjectSettings::GetShowSplashScreen
bool GetShowSplashScreen() const
Definition: ProjectSettings.h:120
flag
static std::once_flag flag
Definition: WaveformView.cpp:1125
ProjectSettings::operator=
ProjectSettings & operator=(const ProjectSettings &) PROHIBITED
ToolCodes::zoomTool
@ zoomTool
Definition: ProjectSettings.h:39
ProjectSettings::SetTracksFitVerticallyZoomed
void SetTracksFitVerticallyZoomed(bool flag)
Definition: ProjectSettings.h:71
ProjectSettings::mCurrentTool
int mCurrentTool
Definition: ProjectSettings.h:142
ClientData::Base
A convenient default parameter for class template Site.
Definition: ClientData.h:28
ProjectSettings::mAudioTimeFormat
NumericFormatSymbol mAudioTimeFormat
Definition: ProjectSettings.h:130
ProjectSettings::mSelectionFormat
NumericFormatSymbol mSelectionFormat
Definition: ProjectSettings.h:127
ToolCodes::firstTool
@ firstTool
Definition: ProjectSettings.h:44
TrackInfo::UpdatePrefs
AUDACITY_DLL_API void UpdatePrefs(wxWindow *pParent)
ProjectSettings::GetTool
int GetTool() const
Definition: ProjectSettings.h:92
ClientData.h
Utility ClientData::Site to register hooks into a host class that attach client data.
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
PrefsListener
A listener notified of changes in preferences.
Definition: Prefs.h:389
ProjectSettings::SetTool
void SetTool(int tool)
Definition: ProjectSettings.h:91
ProjectSettings::mBandwidthSelectionFormatName
NumericFormatSymbol mBandwidthSelectionFormatName
Definition: ProjectSettings.h:129
ProjectSettings::EventCode
EventCode
Definition: ProjectSettings.h:60
ProjectSettings::ChangedSyncLock
@ ChangedSyncLock
Definition: ProjectSettings.h:61
ToolCodes::numTools
@ numTools
Definition: ProjectSettings.h:42
SNAP_NEAREST
@ SNAP_NEAREST
Definition: ProjectSettings.h:30
ProjectSettings::mSnapTo
int mSnapTo
Definition: ProjectSettings.h:140
SNAP_PRIOR
@ SNAP_PRIOR
Definition: ProjectSettings.h:31
ToolCodes::multiTool
@ multiTool
Definition: ProjectSettings.h:41
ProjectSettings::mShowSplashScreen
bool mShowSplashScreen
Definition: ProjectSettings.h:148
ProjectSettings::EmptyCanBeDirty
bool EmptyCanBeDirty() const
Definition: ProjectSettings.h:118
BasicUI::Get
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
ProjectSettings::GetShowId3Dialog
bool GetShowId3Dialog() const
Definition: ProjectSettings.h:73
format
int format
Definition: ExportPCM.cpp:56
ToolCodes::slideTool
@ slideTool
Definition: ProjectSettings.h:40
ProjectSettings::ProjectSettings
ProjectSettings(const ProjectSettings &) PROHIBITED
ProjectSettings::SetShowId3Dialog
void SetShowId3Dialog(bool flag)
Definition: ProjectSettings.h:74
Types.h
ProjectSettings::IsSoloSimple
bool IsSoloSimple() const
Definition: ProjectSettings.h:115
ToolCodes::envelopeTool
@ envelopeTool
Definition: ProjectSettings.h:37
ProjectSettings::mRate
double mRate
Definition: ProjectSettings.h:134
ProjectSettings::GetTracksFitVerticallyZoomed
bool GetTracksFitVerticallyZoomed() const
Definition: ProjectSettings.h:70
ProjectSettings::mSoloPref
wxString mSoloPref
Definition: ProjectSettings.h:132
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:113
ToolCodes::lastTool
@ lastTool
Definition: ProjectSettings.h:45
ProjectSettings::SetPlaySpeed
void SetPlaySpeed(double value)
Definition: ProjectSettings.h:97
Prefs.h
ProjectSettings::mEmptyCanBeDirty
bool mEmptyCanBeDirty
Definition: ProjectSettings.h:147
ProjectSettings::IsSoloNone
bool IsSoloNone() const
Definition: ProjectSettings.h:116
wxDECLARE_EXPORTED_EVENT
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_PROJECT_SETTINGS_CHANGE, wxCommandEvent)
ProjectSettings
Holds various per-project settings values, including the sample rate, and sends events to the project...
Definition: ProjectSettings.h:54