Audacity 3.2.0
ProjectSettings.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5ProjectSettings.cpp
6
7Paul Licameli split from AudacityProject.cpp
8
9**********************************************************************/
10
11#include "ProjectSettings.h"
12
13
14
15#include "AudioIOBase.h"
16#include "Project.h"
17#include "QualitySettings.h"
19
20wxDEFINE_EVENT(EVT_PROJECT_SETTINGS_CHANGE, wxCommandEvent);
21
22namespace {
23 void Notify(
25 long previousValue )
26 {
27 wxCommandEvent e{ EVT_PROJECT_SETTINGS_CHANGE };
28 e.SetInt( static_cast<int>( code ) );
29 e.SetExtraLong( previousValue );
30 project.ProcessEvent( e );
31 }
32}
33
37 auto result = std::make_shared< ProjectSettings >( project );
38 return result;
39 }
40};
41
43{
44 return project.AttachedObjects::Get< ProjectSettings >(
46}
47
49{
50 return Get( const_cast< AudacityProject & >( project ) );
51}
52
54 : mProject{ project }
55 , mCurrentBrushRadius ( 5 )
56{
57 bool multiToolActive = false;
58 gPrefs->Read(wxT("/GUI/ToolBars/Tools/MultiToolActive"), &multiToolActive);
59
60 if (multiToolActive)
62 else
64
66}
67
69{
70 gPrefs->Read(wxT("/GUI/EmptyCanBeDirty"), &mEmptyCanBeDirty, true);
71 gPrefs->Read(wxT("/GUI/ShowSplashScreen"), &mShowSplashScreen, true);
72 gPrefs->Read(wxT("/GUI/TracksFitVerticallyZoomed"),
74 // gPrefs->Read(wxT("/GUI/UpdateSpectrogram"),
75 // &mViewInfo.bUpdateSpectrogram, true);
76
77 // This code to change an empty projects rate is currently disabled, after
78 // discussion. The rule 'Default sample rate' only affects newly created
79 // projects was felt to be simpler and better.
80#if 0
81 // The DefaultProjectSample rate is the rate for new projects.
82 // Do not change this project's rate, unless there are no tracks.
83 if( TrackList::Get( *this ).size() == 0){
84 mRate = QualityDefaultSampleRate.Read();
85 // If necessary, we change this rate in the selection toolbar too.
86 auto bar = SelectionBar::Get( *this );
87 bar.SetRate( mRate );
88 }
89#endif
90}
91
93 if (auto oldValue = mCurrentTool; oldValue != tool) {
94 mCurrentTool = tool;
95 Notify( mProject, ChangedTool, oldValue );
96 }
97}
98
wxT("CloseDown"))
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
static const AudacityProject::AttachedObjects::RegisteredFactory sProjectSettingsKey
wxDEFINE_EVENT(EVT_PROJECT_SETTINGS_CHANGE, wxCommandEvent)
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Definition: ClientData.h:266
Holds various per-project settings values, and sends events to the project when certain values change...
void SetTool(int tool)
static ProjectSettings & Get(AudacityProject &project)
ProjectSettings(AudacityProject &project)
bool mTracksFitVerticallyZoomed
AudacityProject & mProject
void UpdatePrefs() override
static SelectionBar & Get(AudacityProject &project)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:354
virtual bool Read(const wxString &key, bool *value) const =0
void Notify(AudacityProject &project, ProjectSettings::EventCode code, long previousValue)