Audacity 3.2.0
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 () const override
 
TranslatableString GetDescription () const override
 
bool Commit () override
 
ManualPageID HelpPageName () override
 If not empty string, the Help button is added below the panel. More...
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual bool Commit ()=0
 
virtual PluginPath GetPath () const override
 
virtual VendorSymbol GetVendor () const override
 
virtual wxString GetVersion () const override
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual ManualPageID HelpPageName ()
 If not empty string, the Help button is added below the panel. More...
 
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 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 272 of file TracksPrefs.cpp.

276: PrefsPanel(parent, winid, XO("Tracks"))
277{
278 Populate();
279}
XO("Cut/Copy/Paste")
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:94
void Populate()

References Populate().

Here is the call graph for this function:

◆ ~TracksPrefs()

TracksPrefs::~TracksPrefs ( )

Definition at line 281 of file TracksPrefs.cpp.

282{
283}

Member Function Documentation

◆ Commit()

bool TracksPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 427 of file TracksPrefs.cpp.

428{
429 // Bug 1583: Clear the caching of the preference pinned state.
433
434 // Bug 1661: Don't store the name for new tracks if the name is the
435 // default in that language.
439 gPrefs->Flush();
440 }
441
443 return true;
444}
FileConfig * gPrefs
Definition: Prefs.cpp:70
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
#define S(N)
Definition: ToChars.cpp:64
StringSetting AudioTrackNameSetting
Definition: WaveTrack.cpp:2646
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
bool Delete()
Delete the key if present, and return true iff it was.
Definition: Prefs.cpp:508
void Invalidate() override
Definition: Prefs.h:282
const T & GetDefault() const
Definition: Prefs.h:192
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625
void PopulateOrExchange(ShuttleGui &S) override
static int iPreferencePinned
Definition: TracksPrefs.h:54
static wxString GetDefaultAudioTrackNamePreference()
Definition: WaveTrack.cpp:164

References AudioTrackNameSetting, SettingBase::Delete(), eIsSavingToPrefs, FileConfig::Flush(), Setting< T >::GetDefault(), WaveTrack::GetDefaultAudioTrackNamePreference(), gPrefs, Setting< T >::Invalidate(), iPreferencePinned, PopulateOrExchange(), and S.

Here is the call graph for this function:

◆ GetDescription()

TranslatableString TracksPrefs::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 290 of file TracksPrefs.cpp.

291{
292 return XO("Preferences for Tracks");
293}

References XO().

Here is the call graph for this function:

◆ GetPinnedHeadPositionPreference()

double TracksPrefs::GetPinnedHeadPositionPreference ( )
static

Definition at line 411 of file TracksPrefs.cpp.

412{
413 auto value = gPrefs->ReadDouble(
416 return std::max(0.0, std::min(1.0, value));
417}
int min(int a, int b)
const wxChar * PinnedHeadPositionPreferenceKey()
Definition: TracksPrefs.cpp:44

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 392 of file TracksPrefs.cpp.

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

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

Referenced by Scrubber::ShouldScrubPinned(), AdornedRulerPanel::ShowMenu(), AdornedRulerPanel::TogglePinnedHead(), and AdornedRulerPanel::UpdateButtonStates().

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

◆ GetSymbol()

ComponentInterfaceSymbol TracksPrefs::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 285 of file TracksPrefs.cpp.

286{
288}
#define TRACKS_PREFS_PLUGIN_SYMBOL
Definition: TracksPrefs.h:25

References TRACKS_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID TracksPrefs::HelpPageName ( )
overridevirtual

If not empty string, the Help button is added below the panel.

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 295 of file TracksPrefs.cpp.

296{
297 return "Tracks_Preferences";
298}

◆ Populate()

void TracksPrefs::Populate ( )
private

Definition at line 300 of file TracksPrefs.cpp.

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

References eIsCreatingFromPrefs, PopulateOrExchange(), and S.

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 318 of file TracksPrefs.cpp.

319{
320 auto viewModeSetting = ViewModeSetting();
321
322 S.SetBorder(2);
323 S.StartScroller();
324
325 S.StartStatic(XO("Display"));
326 {
327 S.TieCheckBox(XXO("Auto-&fit track height"),
328 {wxT("/GUI/TracksFitVerticallyZoomed"),
329 false});
330 S.TieCheckBox(XXO("Sho&w track name as overlay"),
331 {wxT("/GUI/ShowTrackNameInWaveform"),
332 false});
333#ifdef EXPERIMENTAL_HALF_WAVE
334 S.TieCheckBox(XXO("Use &half-wave display when collapsed"),
335 {wxT("/GUI/CollapseToHalfWave"),
336 false});
337#endif
338#ifdef SHOW_PINNED_UNPINNED_IN_PREFS
339 S.TieCheckBox(XXO("&Pinned Recording/Playback head"),
342#endif
343 S.TieCheckBox(XXO("A&uto-scroll if head unpinned"),
344 {wxT("/GUI/AutoScroll"),
345 true});
346
347 S.AddSpace(10);
348
349 S.StartMultiColumn(2);
350 {
351#ifdef SHOW_PINNED_POSITION_IN_PREFS
352 S.TieNumericTextBox(
353 XXO("Pinned &head position"),
356 30
357 );
358#endif
359
360 S.TieChoice(XXO("Default &view mode:"),
361 viewModeSetting );
362
363 S.TieChoice(XXO("Default Waveform scale:"),
365
366 S.TieChoice(XXO("Display &samples:"),
368
369 S.TieTextBox(XXO("Default audio track &name:"),
371 30);
372 }
373 S.EndMultiColumn();
374 }
375 S.EndStatic();
376
377 S.StartStatic(XO("Zoom Toggle"));
378 {
379 S.StartMultiColumn(4);
380 {
381 S.TieChoice(XXO("Preset 1:"),
382 zoom1Setting );
383
384 S.TieChoice(XXO("Preset 2:"),
385 zoom2Setting );
386 }
387 }
388 S.EndStatic();
389 S.EndScroller();
390}
wxT("CloseDown"))
XXO("&Cut/Copy/Paste Toolbar")
static EnumSetting< WaveTrackViewConstants::ZoomPresets > zoom2Setting
static EnumSetting< WaveTrackViewConstants::ZoomPresets > zoom1Setting
static TracksViewModeEnumSetting ViewModeSetting()
static EnumSetting< WaveTrackViewConstants::SampleDisplay > sampleDisplaySetting
static EnumSetting< WaveformSettings::ScaleTypeValues > waveformScaleSetting
Definition: TracksPrefs.cpp:62

References AudioTrackNameSetting, anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPositionPreferenceDefault(), anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPositionPreferenceKey(), anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPreferenceDefault(), anonymous_namespace{TracksPrefs.cpp}::PinnedHeadPreferenceKey(), S, sampleDisplaySetting, ViewModeSetting(), waveformScaleSetting, wxT(), 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 200 of file TracksPrefs.cpp.

201{
202 return sampleDisplaySetting.ReadEnum();
203}

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 419 of file TracksPrefs.cpp.

420{
421 value = std::max(0.0, std::min(1.0, value));
423 if(flush)
424 gPrefs->Flush();
425}

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 403 of file TracksPrefs.cpp.

404{
405 iPreferencePinned = value ? 1 :0;
406 gPrefs->Write(PinnedHeadPreferenceKey(), value);
407 if(flush)
408 gPrefs->Flush();
409}

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 172 of file TracksPrefs.cpp.

173{
174 return ViewModeSetting().ReadEnum();
175}
Enum ReadEnum() const
Definition: Prefs.h:527

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 177 of file TracksPrefs.cpp.

178{
179 return waveformScaleSetting.ReadEnum();
180}

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 261 of file TracksPrefs.cpp.

262{
263 return zoom1Setting.ReadEnum();
264}

References zoom1Setting.

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

Here is the caller graph for this function:

◆ Zoom2Choice()

WaveTrackViewConstants::ZoomPresets TracksPrefs::Zoom2Choice ( )
static

Definition at line 266 of file TracksPrefs.cpp.

267{
268 return zoom2Setting.ReadEnum();
269}

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 54 of file TracksPrefs.h.

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


The documentation for this class was generated from the following files: