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

273: PrefsPanel(parent, winid, XO("Tracks"))
274{
275 Populate();
276}
#define XO(s)
Definition: Internat.h:31
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90
void Populate()

References Populate().

Here is the call graph for this function:

◆ ~TracksPrefs()

TracksPrefs::~TracksPrefs ( )

Definition at line 278 of file TracksPrefs.cpp.

279{
280}

Member Function Documentation

◆ Commit()

bool TracksPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 424 of file TracksPrefs.cpp.

425{
426 // Bug 1583: Clear the caching of the preference pinned state.
430
431 // Bug 1661: Don't store the name for new tracks if the name is the
432 // default in that language.
436 gPrefs->Flush();
437 }
438
439 return true;
440}
FileConfig * gPrefs
Definition: Prefs.cpp:71
@ eIsSavingToPrefs
Definition: ShuttleGui.h:49
#define S(N)
Definition: ToChars.cpp:64
StringSetting AudioTrackNameSetting
Definition: WaveTrack.cpp:2840
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
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:628
void PopulateOrExchange(ShuttleGui &S) override
static int iPreferencePinned
Definition: TracksPrefs.h:54
static wxString GetDefaultAudioTrackNamePreference()
Definition: WaveTrack.cpp:100

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

Here is the call graph for this function:

◆ GetDescription()

TranslatableString TracksPrefs::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 287 of file TracksPrefs.cpp.

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

References XO.

◆ GetPinnedHeadPositionPreference()

double TracksPrefs::GetPinnedHeadPositionPreference ( )
static

Definition at line 408 of file TracksPrefs.cpp.

409{
410 auto value = gPrefs->ReadDouble(
413 return std::max(0.0, std::min(1.0, value));
414}
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 389 of file TracksPrefs.cpp.

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

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 ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 282 of file TracksPrefs.cpp.

283{
285}
#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 292 of file TracksPrefs.cpp.

293{
294 return "Tracks_Preferences";
295}

◆ Populate()

void TracksPrefs::Populate ( )
private

Definition at line 297 of file TracksPrefs.cpp.

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

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

316{
317 auto viewModeSetting = ViewModeSetting();
318
319 S.SetBorder(2);
320 S.StartScroller();
321
322 S.StartStatic(XO("Display"));
323 {
324 S.TieCheckBox(XXO("Auto-&fit track height"),
325 {wxT("/GUI/TracksFitVerticallyZoomed"),
326 false});
327 S.TieCheckBox(XXO("Sho&w track name as overlay"),
328 {wxT("/GUI/ShowTrackNameInWaveform"),
329 false});
330#ifdef EXPERIMENTAL_HALF_WAVE
331 S.TieCheckBox(XXO("Use &half-wave display when collapsed"),
332 {wxT("/GUI/CollapseToHalfWave"),
333 false});
334#endif
335#ifdef SHOW_PINNED_UNPINNED_IN_PREFS
336 S.TieCheckBox(XXO("&Pinned Recording/Playback head"),
339#endif
340 S.TieCheckBox(XXO("A&uto-scroll if head unpinned"),
341 {wxT("/GUI/AutoScroll"),
342 true});
343
344 S.AddSpace(10);
345
346 S.StartMultiColumn(2);
347 {
348#ifdef SHOW_PINNED_POSITION_IN_PREFS
349 S.TieNumericTextBox(
350 XXO("Pinned &head position"),
353 30
354 );
355#endif
356
357 S.TieChoice(XXO("Default &view mode:"),
358 viewModeSetting );
359
360 S.TieChoice(XXO("Default Waveform scale:"),
362
363 S.TieChoice(XXO("Display &samples:"),
365
366 S.TieTextBox(XXO("Default audio track &name:"),
368 30);
369 }
370 S.EndMultiColumn();
371 }
372 S.EndStatic();
373
374 S.StartStatic(XO("Zoom Toggle"));
375 {
376 S.StartMultiColumn(4);
377 {
378 S.TieChoice(XXO("Preset 1:"),
379 zoom1Setting );
380
381 S.TieChoice(XXO("Preset 2:"),
382 zoom2Setting );
383 }
384 }
385 S.EndStatic();
386 S.EndScroller();
387}
#define XXO(s)
Definition: Internat.h:44
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:61

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

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

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

417{
418 value = std::max(0.0, std::min(1.0, value));
420 if(flush)
421 gPrefs->Flush();
422}

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

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

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

170{
171 return ViewModeSetting().ReadEnum();
172}
Enum ReadEnum() const
Definition: Prefs.h:524

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

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

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

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

References zoom1Setting.

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

Here is the caller graph for this function:

◆ Zoom2Choice()

WaveTrackViewConstants::ZoomPresets TracksPrefs::Zoom2Choice ( )
static

Definition at line 263 of file TracksPrefs.cpp.

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

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: