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 // See enum EventCode below for values of GetInt() identifying changed setting
25 // The previous value of that setting can also be found using GetExtraLong()
26 wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
27  EVT_PROJECT_SETTINGS_CHANGE, wxCommandEvent);
28 
29 enum
30 {
34 };
35 
36 namespace ToolCodes {
37 enum {
38  // The buttons that are in the Tools toolbar must be in correspondence
39  // with the first few
45 
46 #ifdef EXPERIMENTAL_BRUSH_TOOL
47  brushTool,
48 #endif
49 
52 };
53 }
54 
57 class AUDACITY_DLL_API ProjectSettings final
58  : public ClientData::Base
59  , private PrefsListener
60 {
61 public:
62  static ProjectSettings &Get( AudacityProject &project );
63  static const ProjectSettings &Get( const AudacityProject &project );
64 
65  // Values retrievable from GetInt() of the event for settings change
66  enum EventCode : int {
69  ChangedTool
70  };
71 
72  explicit ProjectSettings( AudacityProject &project );
73  ProjectSettings( const ProjectSettings & ) PROHIBITED;
74  ProjectSettings &operator=( const ProjectSettings & ) PROHIBITED;
75 
76 
77  bool GetTracksFitVerticallyZoomed() const { return mTracksFitVerticallyZoomed; } //lda
78  void SetTracksFitVerticallyZoomed(bool flag) { mTracksFitVerticallyZoomed = flag; } //lda
79 
80  bool GetShowId3Dialog() const { return mShowId3Dialog; } //lda
81  void SetShowId3Dialog(bool flag) { mShowId3Dialog = flag; } //lda
82 
83  bool IsSyncLocked() const;
84  void SetSyncLock(bool flag);
85 
86  // Snap To
87 
88  void SetSnapTo(int snap);
89  int GetSnapTo() const;
90 
91  // Current tool
92 
93  void SetTool(int tool);
94  int GetTool() const { return mCurrentTool; }
95 
96  // Current brush radius
97  void SetBrushRadius(int brushRadius) { mCurrentBrushRadius = brushRadius; }
98  int GetBrushRadius() const { return mCurrentBrushRadius; }
99 
100  void SetSmartSelection(bool isSelected) { mbSmartSelection = isSelected; }
101  bool IsSmartSelection() const { return mbSmartSelection; }
102 
103  void SetOvertones(bool isSelected) { mbOvertones = isSelected; }
104  bool IsOvertones() const { return mbOvertones; }
105 
106  // Speed play
107  double GetPlaySpeed() const {
108  return mPlaySpeed.load( std::memory_order_relaxed ); }
109  void SetPlaySpeed( double value ) {
110  mPlaySpeed.store( value, std::memory_order_relaxed ); }
111 
112  // Selection Format
113  void SetSelectionFormat(const NumericFormatSymbol & format);
114  const NumericFormatSymbol & GetSelectionFormat() const;
115 
116  // AudioTime format
117  void SetAudioTimeFormat(const NumericFormatSymbol & format);
118  const NumericFormatSymbol & GetAudioTimeFormat() const;
119 
120  // Spectral Selection Formats
121  void SetFrequencySelectionFormatName(const NumericFormatSymbol & format);
122  const NumericFormatSymbol & GetFrequencySelectionFormatName() const;
123 
124  void SetBandwidthSelectionFormatName(const NumericFormatSymbol & format);
125  const NumericFormatSymbol & GetBandwidthSelectionFormatName() const;
126 
127  bool IsSoloSimple() const { return mSoloPref == wxT("Simple"); }
128  bool IsSoloNone() const { return mSoloPref == wxT("None"); }
129 
130  bool EmptyCanBeDirty() const { return mEmptyCanBeDirty; }
131 
132  bool GetShowSplashScreen() const { return mShowSplashScreen; }
133 
134 private:
135  void UpdatePrefs() override;
136 
138 
143 
144  wxString mSoloPref;
145 
146  // This is atomic because scrubber may read it in a separate thread from
147  // the main
148  std::atomic<double> mPlaySpeed{};
149 
150  int mSnapTo;
151 
155  bool mbSmartSelection { false };
156  bool mbOvertones { false };
157 
158  bool mTracksFitVerticallyZoomed{ false }; //lda
159  bool mShowId3Dialog{ true }; //lda
160  bool mIsSyncLocked{ false };
163 };
164 
165 #endif
ProjectSettings::mProject
AudacityProject & mProject
Definition: ProjectSettings.h:137
ProjectSettings::GetPlaySpeed
double GetPlaySpeed() const
Definition: ProjectSettings.h:107
SNAP_OFF
@ SNAP_OFF
Definition: ProjectSettings.h:31
ProjectSettings::mFrequencySelectionFormatName
NumericFormatSymbol mFrequencySelectionFormatName
Definition: ProjectSettings.h:140
ToolCodes::drawTool
@ drawTool
Definition: ProjectSettings.h:42
ToolCodes::selectTool
@ selectTool
Definition: ProjectSettings.h:40
anonymous_namespace{ToolsToolBar.cpp}::SetTool
void SetTool(AudacityProject &project, int tool)
Called by handlers that set tools.
Definition: ToolsToolBar.cpp:278
ToolCodes
Definition: ProjectSettings.h:36
ProjectSettings::GetShowSplashScreen
bool GetShowSplashScreen() const
Definition: ProjectSettings.h:132
flag
static std::once_flag flag
Definition: WaveformView.cpp:1119
ProjectSettings::operator=
ProjectSettings & operator=(const ProjectSettings &) PROHIBITED
ToolCodes::zoomTool
@ zoomTool
Definition: ProjectSettings.h:43
ProjectSettings::SetTracksFitVerticallyZoomed
void SetTracksFitVerticallyZoomed(bool flag)
Definition: ProjectSettings.h:78
ProjectSettings::mCurrentTool
int mCurrentTool
Definition: ProjectSettings.h:152
ProjectSettings::IsOvertones
bool IsOvertones() const
Definition: ProjectSettings.h:104
ClientData::Base
A convenient default parameter for class template Site.
Definition: ClientData.h:28
ProjectSettings::mAudioTimeFormat
NumericFormatSymbol mAudioTimeFormat
Definition: ProjectSettings.h:142
ProjectSettings::mSelectionFormat
NumericFormatSymbol mSelectionFormat
Definition: ProjectSettings.h:139
ToolCodes::firstTool
@ firstTool
Definition: ProjectSettings.h:51
TrackInfo::UpdatePrefs
AUDACITY_DLL_API void UpdatePrefs(wxWindow *pParent)
ProjectSettings::GetTool
int GetTool() const
Definition: ProjectSettings.h:94
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:392
ProjectSettings::mBandwidthSelectionFormatName
NumericFormatSymbol mBandwidthSelectionFormatName
Definition: ProjectSettings.h:141
ProjectSettings::SetBrushRadius
void SetBrushRadius(int brushRadius)
Definition: ProjectSettings.h:97
ProjectSettings::EventCode
EventCode
Definition: ProjectSettings.h:66
ProjectSettings::ChangedSyncLock
@ ChangedSyncLock
Definition: ProjectSettings.h:67
ToolCodes::numTools
@ numTools
Definition: ProjectSettings.h:50
SNAP_NEAREST
@ SNAP_NEAREST
Definition: ProjectSettings.h:32
ProjectSettings::SetSmartSelection
void SetSmartSelection(bool isSelected)
Definition: ProjectSettings.h:100
ProjectSettings::mSnapTo
int mSnapTo
Definition: ProjectSettings.h:150
SNAP_PRIOR
@ SNAP_PRIOR
Definition: ProjectSettings.h:33
ToolCodes::multiTool
@ multiTool
Definition: ProjectSettings.h:44
ProjectSettings::mShowSplashScreen
bool mShowSplashScreen
Definition: ProjectSettings.h:162
ProjectSettings::EmptyCanBeDirty
bool EmptyCanBeDirty() const
Definition: ProjectSettings.h:130
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:80
format
int format
Definition: ExportPCM.cpp:56
ProjectSettings::ProjectSettings
ProjectSettings(const ProjectSettings &) PROHIBITED
ProjectSettings::SetShowId3Dialog
void SetShowId3Dialog(bool flag)
Definition: ProjectSettings.h:81
ProjectSettings::mCurrentBrushRadius
int mCurrentBrushRadius
Definition: ProjectSettings.h:153
Types.h
ProjectSettings::IsSoloSimple
bool IsSoloSimple() const
Definition: ProjectSettings.h:127
ToolCodes::envelopeTool
@ envelopeTool
Definition: ProjectSettings.h:41
ProjectSettings::GetTracksFitVerticallyZoomed
bool GetTracksFitVerticallyZoomed() const
Definition: ProjectSettings.h:77
ProjectSettings::mSoloPref
wxString mSoloPref
Definition: ProjectSettings.h:144
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
ProjectSettings::SetPlaySpeed
void SetPlaySpeed(double value)
Definition: ProjectSettings.h:109
ProjectSettings::ChangedProjectRate
@ ChangedProjectRate
Definition: ProjectSettings.h:68
Prefs.h
ProjectSettings::mEmptyCanBeDirty
bool mEmptyCanBeDirty
Definition: ProjectSettings.h:161
ProjectSettings::IsSoloNone
bool IsSoloNone() const
Definition: ProjectSettings.h:128
ProjectSettings::GetBrushRadius
int GetBrushRadius() const
Definition: ProjectSettings.h:98
ProjectSettings::IsSmartSelection
bool IsSmartSelection() const
Definition: ProjectSettings.h:101
wxDECLARE_EXPORTED_EVENT
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_PROJECT_SETTINGS_CHANGE, wxCommandEvent)
ProjectSettings
Holds various per-project settings values, and sends events to the project when certain values change...
Definition: ProjectSettings.h:60
ProjectSettings::mCurrentBrushHop
int mCurrentBrushHop
Definition: ProjectSettings.h:154
ProjectSettings::SetOvertones
void SetOvertones(bool isSelected)
Definition: ProjectSettings.h:103