Audacity 3.2.0
WaveTrackViewConstants.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5WaveTrackViewConstants.cpp
6
7Paul Licameli split from class WaveTrack
8
9**********************************************************************/
10
11#include "Internat.h"
13
14// static
17{
18 // Remap old values.
19 enum class OldValues {
21 WaveformDB,
22 Spectrogram,
23 SpectrogramLogF,
24 Pitch,
25 };
26
27 Display newValue;
28 switch ((OldValues)oldValue) {
29 default:
31 newValue = Waveform; break;
32 case OldValues::WaveformDB:
33 newValue = obsoleteWaveformDBDisplay; break;
34 case OldValues::Spectrogram:
35 case OldValues::SpectrogramLogF:
36 case OldValues::Pitch:
37 newValue = Spectrum; break;
38 /*
39 case SpectrogramLogF:
40 newValue = WaveTrack::SpectrumLogDisplay; break;
41 case Pitch:
42 newValue = WaveTrack::PitchDisplay; break;
43 */
44 }
45 return newValue;
46}
47
48namespace {
49 class Registry {
50 public:
52 using Types = std::vector< Type >;
53
54 void Append( Type type )
55 {
56 types.emplace_back( std::move( type ) );
57 sorted = false;
58 }
59
61 {
62 if ( !sorted ) {
63 auto begin = types.begin(), end = types.end();
64 std::sort( begin, end );
65 // We don't want duplicate ids!
66 wxASSERT( end == std::adjacent_find( begin, end ) );
67 sorted = true;
68 }
69 return types;
70 }
71
72 private:
74 bool sorted = false;
75 };
76
78 {
79 static Registry result;
80 return result;
81 }
82}
83
85{
86 GetRegistry().Append( std::move( type ) );
87}
88
89// static
91 -> const std::vector<WaveTrackSubViewType> &
92{
93 return GetRegistry().Get();
94}
95
96// static
98{
99 auto &all = All();
100 if (all.empty())
102 return all[0].id;
103}
104
106 wxT("Multiview"), XXO("&Multi-view")
107};
wxT("CloseDown"))
XXO("&Cut/Copy/Paste Toolbar")
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150
Definition: Menus.h:35
AUDACITY_DLL_API const EnumValueSymbol MultiViewSymbol
String identifier for a preference for one of each type of view.
Display ConvertLegacyDisplayValue(int oldValue)
static const std::vector< WaveTrackSubViewType > & All()
Discover all registered types.
static Display Default()
Return a preferred type.