Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
LV2EffectMeter Class Referencefinal

UI widget that watches a floating point location and then updates a bar. More...

#include <LV2EffectMeter.h>

Inheritance diagram for LV2EffectMeter:
[legend]
Collaboration diagram for LV2EffectMeter:
[legend]

Public Member Functions

 LV2EffectMeter (wxWindow *parent, const LV2ControlPortPtr ctrl, const float &value)
 
virtual ~LV2EffectMeter ()
 
void Disconnect ()
 

Private Member Functions

void OnErase (wxEraseEvent &evt)
 
void OnPaint (wxPaintEvent &evt)
 
void OnIdle (wxIdleEvent &evt)
 
void OnSize (wxSizeEvent &evt)
 

Private Attributes

bool mConnected { true }
 
const LV2ControlPortPtr mControlPort
 
const float & mValue
 
float mLastValue
 

Detailed Description

UI widget that watches a floating point location and then updates a bar.

Definition at line 22 of file LV2EffectMeter.h.

Constructor & Destructor Documentation

◆ LV2EffectMeter()

LV2EffectMeter::LV2EffectMeter ( wxWindow *  parent,
const LV2ControlPortPtr  ctrl,
const float &  value 
)

Definition at line 34 of file LV2EffectMeter.cpp.

36 : wxWindow{ parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
37 wxSIMPLE_BORDER }
38 , mControlPort(port)
39 , mValue{ value }
40{
41 mLastValue = -value;
42 SetBackgroundColour(*wxWHITE);
43 SetMinSize({ 20, 20 });
44}
const float & mValue
const LV2ControlPortPtr mControlPort

◆ ~LV2EffectMeter()

LV2EffectMeter::~LV2EffectMeter ( )
virtual

Definition at line 46 of file LV2EffectMeter.cpp.

47{
48}

Member Function Documentation

◆ Disconnect()

void LV2EffectMeter::Disconnect ( )
inline

Definition at line 28 of file LV2EffectMeter.h.

29 {
30 // Stop using mValue, it may be dangling
31 mConnected = false;
32 }

References mConnected.

◆ OnErase()

void LV2EffectMeter::OnErase ( wxEraseEvent &  evt)
private

Definition at line 59 of file LV2EffectMeter.cpp.

60{
61 // Just ignore it to prevent flashing
62}

◆ OnIdle()

void LV2EffectMeter::OnIdle ( wxIdleEvent &  evt)
private

Definition at line 50 of file LV2EffectMeter.cpp.

51{
52 evt.Skip();
53 if (!mConnected)
54 return;
55 if (mLastValue != mValue)
56 Refresh(false);
57}

References mConnected, mLastValue, and mValue.

◆ OnPaint()

void LV2EffectMeter::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 64 of file LV2EffectMeter.cpp.

65{
66 if (!mConnected)
67 return;
68
69 std::unique_ptr<wxDC> dc {wxAutoBufferedPaintDCFactory(this)};
70
71 // Cache some metrics
72 wxRect r = GetClientRect();
73 wxCoord x = r.GetLeft();
74 wxCoord y = r.GetTop();
75 wxCoord w = r.GetWidth();
76 wxCoord h = r.GetHeight();
77
78 // These use unscaled value, min, and max
79 float val = std::clamp(mValue, mControlPort->mMin, mControlPort->mMax)
80 - mControlPort->mMin;
81
82 // Setup for erasing the background
83 dc->SetPen(*wxTRANSPARENT_PEN);
84 dc->SetBrush(wxColour(100, 100, 220));
85
86 dc->Clear();
87 dc->DrawRectangle(x, y, (w * (val / fabs(mControlPort->mMax - mControlPort->mMin))), h);
88
90}

References mConnected, mControlPort, mLastValue, and mValue.

◆ OnSize()

void LV2EffectMeter::OnSize ( wxSizeEvent &  evt)
private

Definition at line 92 of file LV2EffectMeter.cpp.

93{
94 Refresh(false);
95}

Member Data Documentation

◆ mConnected

bool LV2EffectMeter::mConnected { true }
private

Definition at line 41 of file LV2EffectMeter.h.

Referenced by Disconnect(), OnIdle(), and OnPaint().

◆ mControlPort

const LV2ControlPortPtr LV2EffectMeter::mControlPort
private

Definition at line 42 of file LV2EffectMeter.h.

Referenced by OnPaint().

◆ mLastValue

float LV2EffectMeter::mLastValue
private

Definition at line 44 of file LV2EffectMeter.h.

Referenced by OnIdle(), and OnPaint().

◆ mValue

const float& LV2EffectMeter::mValue
private

Definition at line 43 of file LV2EffectMeter.h.

Referenced by OnIdle(), and OnPaint().


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