Audacity  3.0.3
MeterPanelBase.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 MeterPanelBase.h
6 
7 Paul Licameli split from MeterPanel.h
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_METER_PANEL_BASE__
12 #define __AUDACITY_METER_PANEL_BASE__
13 
14 #include <utility>
15 #include "wxPanelWrapper.h"
16 
17 class Meter;
18 
20 
25 class AUDACITY_DLL_API MeterPanelBase /* not final */
26  : public wxPanelWrapper
27 {
28 public:
30  ~MeterPanelBase() override;
31 
32  template< typename ...Args >
33  MeterPanelBase( Args &&...args )
34  : wxPanelWrapper( std::forward<Args>(args)... )
35  { Init(); }
36 
37  std::shared_ptr<Meter> GetMeter() const;
38 
39  virtual void Clear() = 0;
40  virtual void Reset(double sampleRate, bool resetClipping) = 0;
41  virtual void UpdateDisplay(unsigned numChannels,
42  int numFrames, const float *sampleData) = 0;
43  virtual bool IsMeterDisabled() const = 0;
44  virtual float GetMaxPeak() const = 0;
45  virtual bool IsClipping() const = 0;
46  virtual int GetDBRange() const = 0;
47 
48 private:
49  static bool s_AcceptsFocus;
50  struct Resetter { void operator () (bool *p) const { if(p) *p = false; } };
51  using TempAllowFocus = std::unique_ptr<bool, Resetter>;
52 
53  bool AcceptsFocus() const override { return s_AcceptsFocus; }
54  bool AcceptsFocusFromKeyboard() const override { return true; }
55 
56 public:
57  static TempAllowFocus TemporarilyAllowFocus();
58 
59 private:
60  void Init();
61 
62  struct Forwarder;
63  std::shared_ptr<Forwarder> mForwarder;
64 };
65 
66 #endif
Init
Definition: ModuleManager.h:152
MeterPanelBase::UpdateDisplay
virtual void UpdateDisplay(unsigned numChannels, int numFrames, const float *sampleData)=0
MeterPanelBase::GetDBRange
virtual int GetDBRange() const =0
MeterPanelBase::IsClipping
virtual bool IsClipping() const =0
MeterPanelBase::s_AcceptsFocus
static bool s_AcceptsFocus
Definition: MeterPanelBase.h:49
wxPanelWrapper
Definition: wxPanelWrapper.h:41
wxPanelWrapper.h
Meter
AudioIO uses this to send sample buffers for real-time display updates.
Definition: Meter.h:16
MeterPanelBase
Inherits wxPanel and has a Meter; exposes shared_ptr to the Meter.
Definition: MeterPanelBase.h:27
MeterPanelBase::AcceptsFocusFromKeyboard
bool AcceptsFocusFromKeyboard() const override
Definition: MeterPanelBase.h:54
MeterPanelBase::GetMaxPeak
virtual float GetMaxPeak() const =0
MeterPanelBase::TempAllowFocus
std::unique_ptr< bool, Resetter > TempAllowFocus
Definition: MeterPanelBase.h:51
MeterPanelBase::Resetter
Definition: MeterPanelBase.h:50
MeterPanelBase::MeterPanelBase
MeterPanelBase(Args &&...args)
Definition: MeterPanelBase.h:33
MeterPanelBase::Clear
virtual void Clear()=0
wxPanelWrapper::wxPanelWrapper
wxPanelWrapper()
Definition: wxPanelWrapper.h:44
MeterPanelBase::mForwarder
std::shared_ptr< Forwarder > mForwarder
Definition: MeterPanelBase.h:62
MeterPanelBase::~MeterPanelBase
~MeterPanelBase() override
MeterPanelBase::IsMeterDisabled
virtual bool IsMeterDisabled() const =0
MeterPanelBase::Reset
virtual void Reset(double sampleRate, bool resetClipping)=0
MeterPanelBase::AcceptsFocus
bool AcceptsFocus() const override
Definition: MeterPanelBase.h:53