Audacity  3.0.3
WaveTrackViewConstants.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 WaveTrackViewConstants.cpp
6 
7 Paul Licameli split from class WaveTrack
8 
9 **********************************************************************/
10 
11 #include "Internat.h"
12 #include "WaveTrackViewConstants.h"
13 
14 // static
17 {
18  // Remap old values.
19  enum class OldValues {
20  Waveform,
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 
48 namespace {
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 };
Registry
Definition: Menus.h:36
anonymous_namespace{WaveTrackViewConstants.cpp}::Registry::Types
std::vector< Type > Types
Definition: WaveTrackViewConstants.cpp:52
WaveTrackViewConstants::obsoleteWaveformDBDisplay
@ obsoleteWaveformDBDisplay
Definition: WaveTrackViewConstants.h:27
WaveTrackSubViewType::Default
static Display Default()
Return a preferred type.
Definition: WaveTrackViewConstants.cpp:97
WaveTrackViewConstants::ConvertLegacyDisplayValue
Display ConvertLegacyDisplayValue(int oldValue)
Definition: WaveTrackViewConstants.cpp:16
WaveTrackViewConstants::Display
Display
Definition: WaveTrackViewConstants.h:18
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:61
XXO
#define XXO(s)
Definition: Internat.h:44
WaveTrackSubViewType
Definition: WaveTrackViewConstants.h:91
WaveTrackViewConstants::MultiViewSymbol
AUDACITY_DLL_API const EnumValueSymbol MultiViewSymbol
String identifier for a preference for one of each type of view.
Definition: WaveTrackViewConstants.cpp:105
WaveTrackSubViewType::All
static const std::vector< WaveTrackSubViewType > & All()
Discover all registered types.
Definition: WaveTrackViewConstants.cpp:90
Internat.h
anonymous_namespace{WaveTrackViewConstants.cpp}::Registry::Get
Types & Get()
Definition: WaveTrackViewConstants.cpp:60
anonymous_namespace{WaveTrackViewConstants.cpp}::Registry::Append
void Append(Type type)
Definition: WaveTrackViewConstants.cpp:54
WaveTrackViewConstants.h
anonymous_namespace{WaveTrackViewConstants.cpp}::GetRegistry
Registry & GetRegistry()
Definition: WaveTrackViewConstants.cpp:77
anonymous_namespace{WaveTrackViewConstants.cpp}::Registry::types
Types types
Definition: WaveTrackViewConstants.cpp:73
WaveTrackViewConstants::Spectrum
@ Spectrum
Definition: WaveTrackViewConstants.h:29
WaveTrackViewConstants::Waveform
@ Waveform
Definition: WaveTrackViewConstants.h:24
WaveTrackSubViewType::RegisteredType::RegisteredType
RegisteredType(WaveTrackSubViewType type)
Definition: WaveTrackViewConstants.cpp:84