Audacity  3.0.3
PlaybackPrefs.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  PlaybackPrefs.cpp
6 
7  Joshua Haberman
8  Dominic Mazzoni
9  James Crook
10 
11 *******************************************************************//********************************************************************/
20 
21 
22 #include "PlaybackPrefs.h"
23 
24 #include <wx/defs.h>
25 #include <wx/textctrl.h>
26 
27 #include "../ShuttleGui.h"
28 #include "Prefs.h"
29 
30 PlaybackPrefs::PlaybackPrefs(wxWindow * parent, wxWindowID winid)
31 : PrefsPanel(parent, winid, XO("Playback"))
32 {
33  Populate();
34 }
35 
37 {
38 }
39 
41 {
43 }
44 
46 {
47  return XO("Preferences for Playback");
48 }
49 
51 {
52  return "Playback_Preferences";
53 }
54 
56 {
57  //------------------------- Main section --------------------
58  // Now construct the GUI itself.
59  // Use 'eIsCreatingFromPrefs' so that the GUI is
60  // initialised with values from gPrefs.
63  // ----------------------- End of main section --------------
64 }
65 
66 namespace {
68  {
69  return "/AudioIO/UnpinnedScrubbing";
70  }
72  {
73  return true;
74  }
76 }
77 
79 {
80  const auto suffix = XO("seconds");
81 
82  S.StartScroller();
83  S.SetBorder(2);
84 
85  S.StartStatic(XO("Effects Preview"));
86  {
87  S.StartThreeColumn();
88  {
89  S.NameSuffix(suffix)
90  .TieNumericTextBox(XXO("&Length:"),
91  {wxT("/AudioIO/EffectsPreviewLen"),
92  6.0},
93  9);
94  S.AddUnits(XO("seconds"));
95  }
96  S.EndThreeColumn();
97  }
98  S.EndStatic();
99 
100  /* i18n-hint: (noun) this is a preview of the cut */
101  S.StartStatic(XO("Cut Preview"));
102  {
103  S.StartThreeColumn();
104  {
105  S.NameSuffix(suffix)
106  .TieNumericTextBox(XXO("&Before cut region:"),
107  {wxT("/AudioIO/CutPreviewBeforeLen"),
108  2.0},
109  9);
110  S.AddUnits(XO("seconds"));
111 
112  S.NameSuffix(suffix)
113  .TieNumericTextBox(XXO("&After cut region:"),
114  {wxT("/AudioIO/CutPreviewAfterLen"),
115  1.0},
116  9);
117  S.AddUnits(XO("seconds"));
118  }
119  S.EndThreeColumn();
120  }
121  S.EndStatic();
122 
123  S.StartStatic(XO("Seek Time when playing"));
124  {
125  S.StartThreeColumn();
126  {
127  S.NameSuffix(suffix)
128  .TieNumericTextBox(XXO("&Short period:"),
129  {wxT("/AudioIO/SeekShortPeriod"),
130  1.0},
131  9);
132  S.AddUnits(XO("seconds"));
133 
134  S.NameSuffix(suffix)
135  .TieNumericTextBox(XXO("Lo&ng period:"),
136  {wxT("/AudioIO/SeekLongPeriod"),
137  15.0},
138  9);
139  S.AddUnits(XO("seconds"));
140  }
141  S.EndThreeColumn();
142  }
143  S.EndStatic();
144 
145  S.StartStatic(XO("Options"));
146  {
147  S.StartVerticalLay();
148  {
149  S.TieCheckBox(XXO("&Vari-Speed Play"), {"/AudioIO/VariSpeedPlay", true});
150  S.TieCheckBox(XXO("&Micro-fades"), {"/AudioIO/Microfades", false});
151  S.TieCheckBox(XXO("Always scrub un&pinned"),
154  }
155  S.EndVerticalLay();
156  }
157  S.EndStatic();
158 
159 
160  S.EndScroller();
161 
162 }
163 
165 {
166  if ( iPreferenceUnpinned >= 0 )
167  return iPreferenceUnpinned == 1;
168  bool bResult = gPrefs->ReadBool(
171  iPreferenceUnpinned = bResult ? 1: 0;
172  return bResult;
173 }
174 
176 {
177  iPreferenceUnpinned = -1;
178 
179  ShuttleGui S(this, eIsSavingToPrefs);
181 
182  return true;
183 }
184 
185 namespace{
187  [](wxWindow *parent, wxWindowID winid, AudacityProject *)
188  {
189  wxASSERT(parent); // to justify safenew
190  return safenew PlaybackPrefs(parent, winid);
191  }
192 };
193 }
ShuttleGui::NameSuffix
ShuttleGui & NameSuffix(const TranslatableString &suffix)
Definition: ShuttleGui.h:671
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1184
anonymous_namespace{PlaybackPrefs.cpp}::UnpinnedScrubbingPreferenceKey
const char * UnpinnedScrubbingPreferenceKey()
Definition: PlaybackPrefs.cpp:67
ShuttleGuiBase::EndThreeColumn
void EndThreeColumn()
Definition: ShuttleGui.h:369
PlaybackPrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: PlaybackPrefs.cpp:78
anonymous_namespace{PlaybackPrefs.cpp}::iPreferenceUnpinned
int iPreferenceUnpinned
Definition: PlaybackPrefs.cpp:75
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
PlaybackPrefs::Populate
void Populate()
Definition: PlaybackPrefs.cpp:55
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1629
PrefsPanel::Registration
Definition: PrefsPanel.h:84
XO
#define XO(s)
Definition: Internat.h:31
PlaybackPrefs::GetUnpinnedScrubbingPreference
static bool GetUnpinnedScrubbingPreference()
Definition: PlaybackPrefs.cpp:164
PLAYBACK_PREFS_PLUGIN_SYMBOL
#define PLAYBACK_PREFS_PLUGIN_SYMBOL
Definition: PlaybackPrefs.h:21
PlaybackPrefs::PlaybackPrefs
PlaybackPrefs(wxWindow *parent, wxWindowID winid)
Definition: PlaybackPrefs.cpp:30
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:971
PlaybackPrefs
A PrefsPanel used to select playback options.
Definition: PlaybackPrefs.h:24
PlaybackPrefs.h
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:938
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1203
ShuttleGuiBase::AddUnits
void AddUnits(const TranslatableString &Prompt, int wrapWidth=0)
Left aligned text string.
Definition: ShuttleGui.cpp:263
PlaybackPrefs::~PlaybackPrefs
virtual ~PlaybackPrefs()
Definition: PlaybackPrefs.cpp:36
ShuttleGuiBase::StartThreeColumn
void StartThreeColumn()
Definition: ShuttleGui.h:368
ShuttleGuiBase::TieNumericTextBox
wxTextCtrl * TieNumericTextBox(const TranslatableString &Prompt, int &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1673
anonymous_namespace{PlaybackPrefs.cpp}::sAttachment
PrefsPanel::Registration sAttachment
Definition: PlaybackPrefs.cpp:186
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
eIsSavingToPrefs
@ eIsSavingToPrefs
Definition: ShuttleGui.h:48
TaggedIdentifier< ManualPageIDTag >
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
PlaybackPrefs::HelpPageName
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
Definition: PlaybackPrefs.cpp:50
anonymous_namespace{PlaybackPrefs.cpp}::UnpinnedScrubbingPreferenceDefault
bool UnpinnedScrubbingPreferenceDefault()
Definition: PlaybackPrefs.cpp:71
PlaybackPrefs::Commit
bool Commit() override
Definition: PlaybackPrefs.cpp:175
PlaybackPrefs::GetDescription
TranslatableString GetDescription() override
Definition: PlaybackPrefs.cpp:45
PrefsPanel
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
Prefs.h
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:47
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
safenew
#define safenew
Definition: MemoryX.h:10
PlaybackPrefs::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: PlaybackPrefs.cpp:40
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631