Audacity  3.0.3
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
TracksPrefs Class Referencefinal

A PrefsPanel for track display and behavior properties. More...

#include <TracksPrefs.h>

Inheritance diagram for TracksPrefs:
[legend]
Collaboration diagram for TracksPrefs:
[legend]

Public Member Functions

 TracksPrefs (wxWindow *parent, wxWindowID winid)
 
 ~TracksPrefs ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
bool Commit () override
 
wxString HelpPageName () override
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual PluginPath GetPath ()
 
virtual VendorSymbol GetVendor ()
 
virtual wxString GetVersion ()
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual void Cancel ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static bool GetPinnedHeadPreference ()
 
static void SetPinnedHeadPreference (bool value, bool flush=false)
 
static double GetPinnedHeadPositionPreference ()
 
static void SetPinnedHeadPositionPreference (double value, bool flush=false)
 
static wxString GetDefaultAudioTrackNamePreference ()
 
static WaveTrackViewConstants::Display ViewModeChoice ()
 
static WaveformSettings::ScaleTypeValues WaveformScaleChoice ()
 
static WaveTrackViewConstants::SampleDisplay SampleViewChoice ()
 
static WaveTrackViewConstants::ZoomPresets Zoom1Choice ()
 
static WaveTrackViewConstants::ZoomPresets Zoom2Choice ()
 
- Static Public Member Functions inherited from PrefsPanel
static FactoriesDefaultFactories ()
 

Private Member Functions

void Populate ()
 
void PopulateOrExchange (ShuttleGui &S) override
 

Static Private Attributes

static int iPreferencePinned = -1
 

Additional Inherited Members

- Public Types inherited from PrefsPanel
using Factories = std::vector< PrefsPanel::PrefsNode >
 
using Factory = std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) >
 

Detailed Description

A PrefsPanel for track display and behavior properties.

Definition at line 27 of file TracksPrefs.h.

Constructor & Destructor Documentation

◆ TracksPrefs()

TracksPrefs::TracksPrefs ( wxWindow *  parent,
wxWindowID  winid 
)

Definition at line 268 of file TracksPrefs.cpp.

272 : PrefsPanel(parent, winid, XO("Tracks"))
273 {
274  Populate();
275 }

References Populate().

Here is the call graph for this function:

◆ ~TracksPrefs()

TracksPrefs::~TracksPrefs ( )

Definition at line 277 of file TracksPrefs.cpp.

278 {
279 }

Member Function Documentation

◆ Commit()

bool TracksPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 436 of file TracksPrefs.cpp.

437 {
438  // Bug 1583: Clear the caching of the preference pinned state.
439  iPreferencePinned = -1;
440  ShuttleGui S(this, eIsSavingToPrefs);
442 
443  // Bug 1661: Don't store the name for new tracks if the name is the
444  // default in that language.
445  if (GetDefaultAudioTrackNamePreference() == _("Audio Track")) {
446  gPrefs->DeleteEntry(wxT("/GUI/TrackNames/DefaultTrackName"));
447  gPrefs->Flush();
448  }
449 
450  return true;
451 }

References _, FileConfig::DeleteEntry(), eIsSavingToPrefs, FileConfig::Flush(), GetDefaultAudioTrackNamePreference(), gPrefs, iPreferencePinned, and PopulateOrExchange().

Here is the call graph for this function:

◆ GetDefaultAudioTrackNamePreference()

wxString TracksPrefs::GetDefaultAudioTrackNamePreference ( )
static

Definition at line 422 of file TracksPrefs.cpp.

423 {
424  const auto name =
425  gPrefs->Read(wxT("/GUI/TrackNames/DefaultTrackName"), wxT(""));
426 
427  if (name.empty() || ( name == "Audio Track" ))
428  // When nothing was specified,
429  // the default-default is whatever translation of...
430  /* i18n-hint: The default name for an audio track. */
431  return _("Audio Track");
432  else
433  return name;
434 }

References _, TranslatableString::empty(), gPrefs, and name.

Referenced by Commit(), ProjectAudioManager::DoRecord(), and WaveTrack::WaveTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDescription()

TranslatableString TracksPrefs::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 286 of file TracksPrefs.cpp.

287 {
288  return XO("Preferences for Tracks");
289 }

References XO.

◆ GetPinnedHeadPositionPreference()

double TracksPrefs::GetPinnedHeadPositionPreference ( )
static

Definition at line 406 of file TracksPrefs.cpp.

407 {
408  auto value = gPrefs->ReadDouble(
411  return std::max(0.0, std::min(1.0, value));
412 }

References gPrefs, min(), anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPositionPreferenceDefault(), and anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPositionPreferenceKey().

Referenced by anonymous_namespace{AdornedRulerPanel.cpp}::PlayheadHandle::Click(), anonymous_namespace{Scrubbing.cpp}::FindScrubbingSpeed(), anonymous_namespace{Scrubbing.cpp}::FindSeekSpeed(), anonymous_namespace{AdornedRulerPanel.cpp}::GetPlayHeadX(), and ProjectWindow::PlaybackScroller::OnTimer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPinnedHeadPreference()

bool TracksPrefs::GetPinnedHeadPreference ( )
static

Definition at line 387 of file TracksPrefs.cpp.

388 {
389  // JKC: Cache this setting as it is read many times during drawing, and otherwise causes screen flicker.
390  // Correct solution would be to re-write wxFileConfig to be efficient.
391  if( iPreferencePinned >= 0 )
392  return iPreferencePinned == 1;
393  bool bResult = gPrefs->ReadBool(PinnedHeadPreferenceKey(), PinnedHeadPreferenceDefault());
394  iPreferencePinned = bResult ? 1: 0;
395  return bResult;
396 }

References gPrefs, iPreferencePinned, anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPreferenceDefault(), and anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPreferenceKey().

Referenced by Scrubber::ShouldScrubPinned(), AdornedRulerPanel::ShowMenu(), AdornedRulerPanel::TogglePinnedHead(), anonymous_namespace{TransportMenus.cpp}::TransportMenu(), and AdornedRulerPanel::UpdateButtonStates().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol TracksPrefs::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 281 of file TracksPrefs.cpp.

282 {
284 }

References TRACKS_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

wxString TracksPrefs::HelpPageName ( )
overridevirtual

Reimplemented from PrefsPanel.

Definition at line 291 of file TracksPrefs.cpp.

292 {
293  return "Tracks_Preferences";
294 }

◆ Populate()

void TracksPrefs::Populate ( )
private

Definition at line 296 of file TracksPrefs.cpp.

297 {
298  // Keep view choices and codes in proper correspondence --
299  // we don't display them by increasing integer values.
300 
301 
302  // How samples are displayed when zoomed in:
303 
304 
305  //------------------------- Main section --------------------
306  // Now construct the GUI itself.
307  // Use 'eIsCreatingFromPrefs' so that the GUI is
308  // initialised with values from gPrefs.
311  // ----------------------- End of main section --------------
312 }

References eIsCreatingFromPrefs, and PopulateOrExchange().

Referenced by TracksPrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PopulateOrExchange()

void TracksPrefs::PopulateOrExchange ( ShuttleGui S)
overrideprivate

Definition at line 314 of file TracksPrefs.cpp.

315 {
316  S.SetBorder(2);
317  S.StartScroller();
318 
319  S.StartStatic(XO("Display"));
320  {
321  S.TieCheckBox(XXO("Auto-&fit track height"),
322  {wxT("/GUI/TracksFitVerticallyZoomed"),
323  false});
324  S.TieCheckBox(XXO("Sho&w track name as overlay"),
325  {wxT("/GUI/ShowTrackNameInWaveform"),
326  false});
327 #ifdef EXPERIMENTAL_HALF_WAVE
328  S.TieCheckBox(XXO("Use &half-wave display when collapsed"),
329  {wxT("/GUI/CollapseToHalfWave"),
330  false});
331 #endif
332 #ifdef SHOW_PINNED_UNPINNED_IN_PREFS
333  S.TieCheckBox(XXO("&Pinned Recording/Playback head"),
336 #endif
337  S.TieCheckBox(XXO("A&uto-scroll if head unpinned"),
338  {wxT("/GUI/AutoScroll"),
339  true});
340 
341  S.AddSpace(10);
342 
343  S.StartMultiColumn(2);
344  {
345 #ifdef SHOW_PINNED_POSITION_IN_PREFS
347  XXO("Pinned &head position"),
350  30
351  );
352 #endif
353 
354  S.TieChoice(XXO("Default &view mode:"),
355  viewModeSetting() );
356 
357  S.TieChoice(XXO("Default Waveform scale:"),
359 
360  S.TieChoice(XXO("Display &samples:"),
362 
363  S.TieTextBox(XXO("Default audio track &name:"),
364  {wxT("/GUI/TrackNames/DefaultTrackName"),
365  _("Audio Track")},
366  30);
367  }
368  S.EndMultiColumn();
369  }
370  S.EndStatic();
371 
372  S.StartStatic(XO("Zoom Toggle"));
373  {
374  S.StartMultiColumn(4);
375  {
376  S.TieChoice(XXO("Preset 1:"),
377  zoom1Setting );
378 
379  S.TieChoice(XXO("Preset 2:"),
380  zoom2Setting );
381  }
382  }
383  S.EndStatic();
384  S.EndScroller();
385 }

References _, ShuttleGui::AddSpace(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndScroller(), ShuttleGuiBase::EndStatic(), anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPositionPreferenceDefault(), anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPositionPreferenceKey(), anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPreferenceDefault(), anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPreferenceKey(), sampleDisplaySetting, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartScroller(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::TieCheckBox(), ShuttleGuiBase::TieChoice(), ShuttleGuiBase::TieNumericTextBox(), ShuttleGuiBase::TieTextBox(), viewModeSetting(), waveformScaleSetting, XO, XXO, zoom1Setting, and zoom2Setting.

Referenced by Commit(), and Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SampleViewChoice()

WaveTrackViewConstants::SampleDisplay TracksPrefs::SampleViewChoice ( )
static

Definition at line 196 of file TracksPrefs.cpp.

197 {
198  return sampleDisplaySetting.ReadEnum();
199 }

References sampleDisplaySetting.

Referenced by TrackArtist::UpdatePrefs().

Here is the caller graph for this function:

◆ SetPinnedHeadPositionPreference()

void TracksPrefs::SetPinnedHeadPositionPreference ( double  value,
bool  flush = false 
)
static

Definition at line 414 of file TracksPrefs.cpp.

415 {
416  value = std::max(0.0, std::min(1.0, value));
417  gPrefs->Write(PinnedHeadPositionPreferenceKey(), value);
418  if(flush)
419  gPrefs->Flush();
420 }

References FileConfig::Flush(), gPrefs, min(), and anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPositionPreferenceKey().

Referenced by anonymous_namespace{AdornedRulerPanel.cpp}::PlayheadHandle::Cancel(), anonymous_namespace{AdornedRulerPanel.cpp}::PlayheadHandle::Click(), anonymous_namespace{AdornedRulerPanel.cpp}::PlayheadHandle::Drag(), and anonymous_namespace{AdornedRulerPanel.cpp}::PlayheadHandle::Release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPinnedHeadPreference()

void TracksPrefs::SetPinnedHeadPreference ( bool  value,
bool  flush = false 
)
static

Definition at line 398 of file TracksPrefs.cpp.

399 {
400  iPreferencePinned = value ? 1 :0;
401  gPrefs->Write(PinnedHeadPreferenceKey(), value);
402  if(flush)
403  gPrefs->Flush();
404 }

References FileConfig::Flush(), gPrefs, iPreferencePinned, and anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPreferenceKey().

Referenced by AdornedRulerPanel::TogglePinnedHead().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ViewModeChoice()

WaveTrackViewConstants::Display TracksPrefs::ViewModeChoice ( )
static

Definition at line 168 of file TracksPrefs.cpp.

169 {
170  return viewModeSetting().ReadEnum();
171 }

References EnumSetting< Enum >::ReadEnum(), and viewModeSetting().

Referenced by WaveTrackView::BuildSubViews().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WaveformScaleChoice()

WaveformSettings::ScaleTypeValues TracksPrefs::WaveformScaleChoice ( )
static

Definition at line 173 of file TracksPrefs.cpp.

174 {
175  return waveformScaleSetting.ReadEnum();
176 }

References waveformScaleSetting.

Referenced by WaveformSettings::LoadPrefs(), and WaveformSettings::UpdatePrefs().

Here is the caller graph for this function:

◆ Zoom1Choice()

WaveTrackViewConstants::ZoomPresets TracksPrefs::Zoom1Choice ( )
static

Definition at line 257 of file TracksPrefs.cpp.

258 {
259  return zoom1Setting.ReadEnum();
260 }

References zoom1Setting.

Referenced by ViewActions::Handler::OnZoomToggle().

Here is the caller graph for this function:

◆ Zoom2Choice()

WaveTrackViewConstants::ZoomPresets TracksPrefs::Zoom2Choice ( )
static

Definition at line 262 of file TracksPrefs.cpp.

263 {
264  return zoom2Setting.ReadEnum();
265 }

References zoom2Setting.

Referenced by ViewActions::Handler::OnZoomToggle().

Here is the caller graph for this function:

Member Data Documentation

◆ iPreferencePinned

int TracksPrefs::iPreferencePinned = -1
staticprivate

Definition at line 56 of file TracksPrefs.h.

Referenced by Commit(), GetPinnedHeadPreference(), and SetPinnedHeadPreference().


The documentation for this class was generated from the following files:
zoom1Setting
static EnumSetting< WaveTrackViewConstants::ZoomPresets > zoom1Setting
Definition: TracksPrefs.cpp:237
TranslatableString::empty
bool empty() const
Definition: TranslatableString.h:72
anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPositionPreferenceDefault
double PinnedHeadPositionPreferenceDefault()
Definition: TracksPrefs.cpp:48
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:68
viewModeSetting
static TracksViewModeEnumSetting viewModeSetting()
Definition: TracksPrefs.cpp:146
ShuttleGuiBase::TieCheckBox
wxCheckBox * TieCheckBox(const TranslatableString &Prompt, bool &Var)
Definition: ShuttleGui.cpp:1603
TracksPrefs::Populate
void Populate()
Definition: TracksPrefs.cpp:296
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2421
FileConfig::DeleteEntry
virtual bool DeleteEntry(const wxString &key, bool bDeleteGroupIfEmpty=true) wxOVERRIDE
Definition: FileConfig.cpp:219
XO
#define XO(s)
Definition: Internat.h:31
zoom2Setting
static EnumSetting< WaveTrackViewConstants::ZoomPresets > zoom2Setting
Definition: TracksPrefs.cpp:247
TracksPrefs::iPreferencePinned
static int iPreferencePinned
Definition: TracksPrefs.h:56
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1212
waveformScaleSetting
static EnumSetting< WaveformSettings::ScaleTypeValues > waveformScaleSetting
Definition: TracksPrefs.cpp:60
sampleDisplaySetting
static EnumSetting< WaveTrackViewConstants::SampleDisplay > sampleDisplaySetting
Definition: TracksPrefs.cpp:180
TracksPrefs::GetDefaultAudioTrackNamePreference
static wxString GetDefaultAudioTrackNamePreference()
Definition: TracksPrefs.cpp:422
anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPreferenceKey
const wxChar * PinnedHeadPreferenceKey()
Definition: TracksPrefs.cpp:33
ShuttleGuiBase::TieTextBox
wxTextCtrl * TieTextBox(const TranslatableString &Caption, wxString &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1626
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:964
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:931
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPreferenceDefault
bool PinnedHeadPreferenceDefault()
Definition: TracksPrefs.cpp:38
name
const TranslatableString name
Definition: Distortion.cpp:98
ShuttleGuiBase::TieNumericTextBox
wxTextCtrl * TieNumericTextBox(const TranslatableString &Prompt, int &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1647
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:886
eIsSavingToPrefs
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
TracksPrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: TracksPrefs.cpp:314
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:153
EnumSetting::ReadEnum
Enum ReadEnum() const
Definition: Prefs.h:364
_
#define _(s)
Definition: Internat.h:75
anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPositionPreferenceKey
const wxChar * PinnedHeadPositionPreferenceKey()
Definition: TracksPrefs.cpp:43
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:484
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:915
ShuttleGuiBase::TieChoice
wxChoice * TieChoice(const TranslatableString &Prompt, TranslatableString &Selected, const TranslatableStrings &choices)
Definition: ShuttleGui.cpp:1701
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625
PrefsPanel::PrefsPanel
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90
TRACKS_PREFS_PLUGIN_SYMBOL
#define TRACKS_PREFS_PLUGIN_SYMBOL
Definition: TracksPrefs.h:25