Audacity 3.2.0
LV2Validator.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file LV2Validator.h
6 @brief Event handling object for user interfaces of LV2 effects
7
8 Paul Licameli split from LV2Effect.h
9
10 Audacity(R) is copyright (c) 1999-2013 Audacity Team.
11 License: GPL v2 or later. See License.txt.
12
13*********************************************************************/
14
15#ifndef __AUDACITY_LV2_VALIDATOR__
16#define __AUDACITY_LV2_VALIDATOR__
17
18#if USE_LV2
19
20#include "EffectPlugin.h"
21
22#include <optional>
23#include <vector>
24
25#include <wx/timer.h>
26#include <wx/window.h>
27#include <wx/windowptr.h>
28
29#include "LV2UIFeaturesList.h"
30#include "LV2Ports.h"
31#include "NativeWindow.h"
32
34
35// We use deprecated LV2 interfaces to remain compatible with older
36// plug-ins, so disable warnings
37LV2_DISABLE_DEPRECATION_WARNINGS
38
39class wxCheckBox;
40class wxChoice;
41class wxSlider;
42class wxTextCtrl;
43class NumericTextCtrl;
44
45class LV2EffectMeter;
46class LV2Instance;
47class LV2Wrapper;
48class EffectBase;
49
50class LV2Validator final : public EffectUIValidator
51 , public wxEvtHandler
53{
54public:
56 const LilvPlugin &plug, LV2Instance &instance,
57 EffectSettingsAccess &access, const EffectOutputs *pOutputs,
58 double sampleRate,
59 const LV2FeaturesList &features,
60 const LV2Ports &ports, wxWindow *parent, bool useGUI);
61 ~LV2Validator() override;
62
63 bool ValidateUI() override;
64 bool UpdateUI() override;
65 bool IsGraphicalUI() override;
66 void Disconnect() override;
67
68 int ui_resize(int width, int height) override;
69 void ui_closed() override;
70
71#if defined(__WXGTK__)
72 static void size_request(GtkWidget *widget, GtkRequisition *requisition,
73 LV2Validator *pValidator);
74 void SizeRequest(GtkWidget *widget, GtkRequisition *requisition);
75#endif
76
80 bool BuildFancy(std::unique_ptr<LV2Wrapper> pWrapper,
82 bool BuildPlain(EffectSettingsAccess &access);
83
84 void suil_port_write(uint32_t port_index,
85 uint32_t buffer_size, uint32_t protocol, const void *buffer) override;
86 uint32_t suil_port_index(const char *port_symbol) override;
87
88 void UpdateControlPortValue(LV2EffectSettings& settings, size_t controlPortIndex, float value);
89
90 void OnTrigger(wxCommandEvent & evt);
91 void OnToggle(wxCommandEvent & evt);
92 void OnChoice(wxCommandEvent & evt);
93 void OnText(wxCommandEvent & evt);
94 void OnSlider(wxCommandEvent & evt);
95
96 void OnIdle(wxIdleEvent & evt);
97 void OnSize(wxSizeEvent & evt);
98
99 static std::shared_ptr<SuilHost> GetSuilHost();
100
101 const LilvPlugin &mPlug;
105 const double mSampleRate;
107 std::unique_ptr<LV2Wrapper> mpWrapper;
108 std::optional<const LV2UIFeaturesList> mUIFeatures;
110
111 std::shared_ptr<SuilHost> mSuilHost;
112 wxWindow *mParent;
113 bool mUseGUI{};
114
115 // UI
117 wxTextCtrl *mText{};
119 union {
120 wxButton *button;
121 wxCheckBox *checkbox;
122 wxChoice *choice;
124 wxSlider *slider;
125 };
126 };
128 std::vector<PlainUIControl> mPlainUIControls;
129 void SetSlider(const LV2ControlPortState &state, const PlainUIControl &ctrl);
130
131 // Two smart pointers are grouped because their destruction needs caution
132 struct UI {
133 void Destroy();
134 ~UI() { Destroy(); }
136 wxWindowPtr<NativeWindow> mNativeWin{};
137#ifdef __WXMAC__
138 bool mJustLeakMemory{ false };
139#endif
141
142 wxSize mNativeWinInitialSize{ wxDefaultSize };
143 wxSize mNativeWinLastSize{ wxDefaultSize };
144 bool mResizing{ false };
145#if defined(__WXGTK__)
146 bool mResized{ false };
147#endif
148
149 wxWeakRef<wxDialog> mDialog;
150 bool mExternalUIClosed{ false };
151
153 struct Timer : wxTimer {
155 void Notify() override;
157
158 const LV2UI_Idle_Interface *mUIIdleInterface{};
159 const LV2UI_Show_Interface *mUIShowInterface{};
161
162 DECLARE_EVENT_TABLE()
163};
164
165#endif
166#endif
EffectType
std::unique_ptr< Type, Lilv_deleter< Type, f > > Lilv_ptr
Generate classes of smart pointers to lv2 resources.
Definition: LV2Utils.h:26
Lilv_ptr< SuilInstance, suil_instance_free > SuilInstancePtr
Definition: LV2Validator.h:33
static Settings & settings()
Definition: TrackInfo.cpp:87
Base class for many of the effects in Audacity.
Definition: EffectBase.h:33
Hold values to send to effect output meters.
Interface for transferring values from a panel of effect controls.
Definition: EffectPlugin.h:239
UI widget that watches a floating point location and then updates a bar.
void OnSize(wxSizeEvent &evt)
NumericTextCtrl * mDuration
Definition: LV2Validator.h:160
const LV2UI_Idle_Interface * mUIIdleInterface
Definition: LV2Validator.h:158
void SetSlider(const LV2ControlPortState &state, const PlainUIControl &ctrl)
const LV2Ports & mPorts
Definition: LV2Validator.h:106
const double mSampleRate
Definition: LV2Validator.h:105
std::vector< PlainUIControl > mPlainUIControls
Array in correspondence with the control ports.
Definition: LV2Validator.h:128
bool IsGraphicalUI() override
bool BuildFancy(std::unique_ptr< LV2Wrapper > pWrapper, const EffectSettings &settings)
bool BuildPlain(EffectSettingsAccess &access)
const EffectOutputs * mpOutputs
Definition: LV2Validator.h:104
std::shared_ptr< SuilHost > mSuilHost
Definition: LV2Validator.h:111
void Disconnect() override
On the first call only, may disconnect from further event handling.
wxWindow * mParent
Definition: LV2Validator.h:112
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
bool UpdateUI() override
Update appearance of the panel for changes in settings.
~LV2Validator() override
void OnSlider(wxCommandEvent &evt)
void suil_port_write(uint32_t port_index, uint32_t buffer_size, uint32_t protocol, const void *buffer) override
LV2PortUIStates mPortUIStates
Definition: LV2Validator.h:109
void OnIdle(wxIdleEvent &evt)
wxSize mNativeWinInitialSize
Definition: LV2Validator.h:142
struct LV2Validator::UI mUI
static std::shared_ptr< SuilHost > GetSuilHost()
void OnTrigger(wxCommandEvent &evt)
int ui_resize(int width, int height) override
LV2Validator::Timer mTimer
void OnText(wxCommandEvent &evt)
void OnChoice(wxCommandEvent &evt)
wxSize mNativeWinLastSize
Definition: LV2Validator.h:143
LV2Validator(EffectBase &effect, const LilvPlugin &plug, LV2Instance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs, double sampleRate, const LV2FeaturesList &features, const LV2Ports &ports, wxWindow *parent, bool useGUI)
void ui_closed() override
void UpdateControlPortValue(LV2EffectSettings &settings, size_t controlPortIndex, float value)
LV2Instance & mInstance
Definition: LV2Validator.h:103
std::optional< const LV2UIFeaturesList > mUIFeatures
Definition: LV2Validator.h:108
const EffectType mType
Definition: LV2Validator.h:102
const LilvPlugin & mPlug
Definition: LV2Validator.h:101
const LV2UI_Show_Interface * mUIShowInterface
Definition: LV2Validator.h:159
void OnToggle(wxCommandEvent &evt)
static void size_request(GtkWidget *widget, GtkRequisition *requisition, LV2Validator *pValidator)
std::unique_ptr< LV2Wrapper > mpWrapper
Definition: LV2Validator.h:107
void SizeRequest(GtkWidget *widget, GtkRequisition *requisition)
wxWeakRef< wxDialog > mDialog
Definition: LV2Validator.h:149
uint32_t suil_port_index(const char *port_symbol) override
bool mExternalUIClosed
Definition: LV2Validator.h:150
Manager of a handle to an LV2 plug-in instantiation.
Definition: LV2Wrapper.h:45
Externalized state of a plug-in.
Other UI related state of an instance of an LV2 Control port.
Definition: LV2Ports.h:237
Storage locations to be connected to LV2 control ports.
Definition: LV2Ports.h:206
Abstraction of host services that a plug-ins native UI needs.
This must be destroyed before mSuilInstance.
Definition: LV2Validator.h:153
void Notify() override
LV2_External_UI_Widget * mExternalWidget
Definition: LV2Validator.h:154
wxWindowPtr< NativeWindow > mNativeWin
Definition: LV2Validator.h:136
SuilInstancePtr mSuilInstance
Definition: LV2Validator.h:135