Audacity 3.2.0
LV2Editor.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file LV2Editor.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_EDITOR__
16#define __AUDACITY_LV2_EDITOR__
17
18#if USE_LV2
19
20#include "../EffectEditor.h"
21
22#include <optional>
23#include <vector>
24
25#include <wx/dialog.h>
26#include <wx/timer.h>
27#include <wx/weakref.h>
28#include <wx/window.h>
29#include <wx/windowptr.h>
30
31#include "LV2UIFeaturesList.h"
32#include "LV2Ports.h"
33#include "NativeWindow.h"
34
36
37// We use deprecated LV2 interfaces to remain compatible with older
38// plug-ins, so disable warnings
39LV2_DISABLE_DEPRECATION_WARNINGS
40
41class wxButton;
42class wxCheckBox;
43class wxChoice;
44class wxSlider;
45class wxTextCtrl;
46class NumericTextCtrl;
47
48class LV2EffectMeter;
49class LV2Instance;
50class LV2Wrapper;
52
53class LV2Editor final : public EffectEditor
54 , public wxEvtHandler
56{
57public:
59 const LilvPlugin &plug, LV2Instance &instance,
60 EffectSettingsAccess &access, const EffectOutputs *pOutputs,
61 double sampleRate,
62 const LV2FeaturesList &features,
63 const LV2Ports &ports, wxWindow *parent, bool useGUI);
64 ~LV2Editor() override;
65
66 bool ValidateUI() override;
67 bool UpdateUI() override;
68 bool IsGraphicalUI() override;
69 void Disconnect() override;
70
71 int ui_resize(int width, int height) override;
72 void ui_closed() override;
73
74#if defined(__WXGTK__)
75 static void size_request(GtkWidget *widget, GtkRequisition *requisition,
76 LV2Editor *pEditor);
77 void SizeRequest(GtkWidget *widget, GtkRequisition *requisition);
78#endif
79
83 bool BuildFancy(std::unique_ptr<LV2Wrapper> pWrapper,
85 bool BuildPlain(EffectSettingsAccess &access);
86
87 void suil_port_write(uint32_t port_index,
88 uint32_t buffer_size, uint32_t protocol, const void *buffer) override;
89 uint32_t suil_port_index(const char *port_symbol) override;
90
91 void UpdateControlPortValue(LV2EffectSettings& settings, size_t controlPortIndex, float value);
92
93 void OnTrigger(wxCommandEvent & evt);
94 void OnToggle(wxCommandEvent & evt);
95 void OnChoice(wxCommandEvent & evt);
96 void OnText(wxCommandEvent & evt);
97 void OnSlider(wxCommandEvent & evt);
98
99 void OnIdle(wxIdleEvent & evt);
100 void OnSize(wxSizeEvent & evt);
101
102 static std::shared_ptr<SuilHost> GetSuilHost();
103
104 const LilvPlugin &mPlug;
108 const double mSampleRate;
110 std::unique_ptr<LV2Wrapper> mpWrapper;
111 std::optional<const LV2UIFeaturesList> mUIFeatures;
113
114 std::shared_ptr<SuilHost> mSuilHost;
115 wxWindow *mParent;
116 bool mUseGUI{};
117
118 // UI
120 wxTextCtrl *mText{};
122 union {
123 wxButton *button;
124 wxCheckBox *checkbox;
125 wxChoice *choice;
127 wxSlider *slider;
128 };
129 };
131 std::vector<PlainUIControl> mPlainUIControls;
132 void SetSlider(const LV2ControlPortState &state, const PlainUIControl &ctrl);
133
134 // Two smart pointers are grouped because their destruction needs caution
135 struct UI {
136 void Destroy();
137 ~UI() { Destroy(); }
139 wxWindowPtr<NativeWindow> mNativeWin{};
140#ifdef __WXMAC__
141 bool mJustLeakMemory{ false };
142#endif
144
145 wxSize mNativeWinInitialSize{ wxDefaultSize };
146 wxSize mNativeWinLastSize{ wxDefaultSize };
147 bool mResizing{ false };
148#if defined(__WXGTK__)
149 bool mResized{ false };
150#endif
151
152 wxWeakRef<wxDialog> mDialog;
153 bool mExternalUIClosed{ false };
154
156 struct Timer : wxTimer {
158 void Notify() override;
160
161 const LV2UI_Idle_Interface *mUIIdleInterface{};
162 const LV2UI_Show_Interface *mUIShowInterface{};
164
165 DECLARE_EVENT_TABLE()
166};
167
168#endif
169#endif
EffectType
Lilv_ptr< SuilInstance, suil_instance_free > SuilInstancePtr
Definition: LV2Editor.h:35
std::unique_ptr< Type, Lilv_deleter< Type, f > > Lilv_ptr
Generate classes of smart pointers to lv2 resources.
Definition: LV2Utils.h:26
static Settings & settings()
Definition: TrackInfo.cpp:51
Hold values to send to effect output meters.
bool IsGraphicalUI() override
Definition: LV2Editor.cpp:144
wxWeakRef< wxDialog > mDialog
Definition: LV2Editor.h:152
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
Definition: LV2Editor.cpp:149
bool mResizing
Definition: LV2Editor.h:147
const LV2Ports & mPorts
Definition: LV2Editor.h:109
void OnIdle(wxIdleEvent &evt)
Definition: LV2Editor.cpp:819
const LilvPlugin & mPlug
Definition: LV2Editor.h:104
LV2PortUIStates mPortUIStates
Definition: LV2Editor.h:112
wxSize mNativeWinLastSize
Definition: LV2Editor.h:146
std::shared_ptr< SuilHost > mSuilHost
Definition: LV2Editor.h:114
const double mSampleRate
Definition: LV2Editor.h:108
void OnChoice(wxCommandEvent &evt)
Definition: LV2Editor.cpp:762
std::vector< PlainUIControl > mPlainUIControls
Array in correspondence with the control ports.
Definition: LV2Editor.h:131
std::unique_ptr< LV2Wrapper > mpWrapper
Definition: LV2Editor.h:110
LV2Instance & mInstance
Definition: LV2Editor.h:106
LV2Editor(const StatelessEffectUIServices &effect, EffectType type, const LilvPlugin &plug, LV2Instance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs, double sampleRate, const LV2FeaturesList &features, const LV2Ports &ports, wxWindow *parent, bool useGUI)
Definition: LV2Editor.cpp:103
static void size_request(GtkWidget *widget, GtkRequisition *requisition, LV2Editor *pEditor)
Definition: LV2Editor.cpp:1015
void OnSlider(wxCommandEvent &evt)
Definition: LV2Editor.cpp:790
~LV2Editor() override
Definition: LV2Editor.cpp:182
LV2Editor::Timer mTimer
wxWindow * mParent
Definition: LV2Editor.h:115
void OnTrigger(wxCommandEvent &evt)
Definition: LV2Editor.cpp:742
bool UpdateUI() override
Update appearance of the panel for changes in settings.
Definition: LV2Editor.cpp:641
bool BuildFancy(std::unique_ptr< LV2Wrapper > pWrapper, const EffectSettings &settings)
Definition: LV2Editor.cpp:203
struct LV2Editor::UI mUI
void OnSize(wxSizeEvent &evt)
Definition: LV2Editor.cpp:889
void OnToggle(wxCommandEvent &evt)
Definition: LV2Editor.cpp:752
void suil_port_write(uint32_t port_index, uint32_t buffer_size, uint32_t protocol, const void *buffer) override
Definition: LV2Editor.cpp:969
void ui_closed() override
Definition: LV2Editor.cpp:963
void UpdateControlPortValue(LV2EffectSettings &settings, size_t controlPortIndex, float value)
Definition: LV2Editor.cpp:722
const EffectOutputs * mpOutputs
Definition: LV2Editor.h:107
void SizeRequest(GtkWidget *widget, GtkRequisition *requisition)
Definition: LV2Editor.cpp:1021
uint32_t suil_port_index(const char *port_symbol) override
Definition: LV2Editor.cpp:998
bool mUseGUI
Definition: LV2Editor.h:116
const EffectType mType
Definition: LV2Editor.h:105
std::optional< const LV2UIFeaturesList > mUIFeatures
Definition: LV2Editor.h:111
bool mExternalUIClosed
Definition: LV2Editor.h:153
void OnText(wxCommandEvent &evt)
Definition: LV2Editor.cpp:773
int ui_resize(int width, int height) override
Definition: LV2Editor.cpp:949
NumericTextCtrl * mDuration
Definition: LV2Editor.h:163
static std::shared_ptr< SuilHost > GetSuilHost()
Definition: LV2Editor.cpp:187
const LV2UI_Show_Interface * mUIShowInterface
Definition: LV2Editor.h:162
const LV2UI_Idle_Interface * mUIIdleInterface
Definition: LV2Editor.h:161
wxSize mNativeWinInitialSize
Definition: LV2Editor.h:145
void SetSlider(const LV2ControlPortState &state, const PlainUIControl &ctrl)
Definition: LV2Editor.cpp:708
bool BuildPlain(EffectSettingsAccess &access)
Definition: LV2Editor.cpp:389
void Disconnect() override
On the first call only, may disconnect from further event handling.
Definition: LV2Editor.cpp:159
bool mResized
Definition: LV2Editor.h:149
UI widget that watches a floating point location and then updates a bar.
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
LV2EffectMeter * meter
Definition: LV2Editor.h:126
This must be destroyed before mSuilInstance.
Definition: LV2Editor.h:156
void Notify() override
Definition: LV2Editor.cpp:813
LV2_External_UI_Widget * mExternalWidget
Definition: LV2Editor.h:157
wxWindowPtr< NativeWindow > mNativeWin
Definition: LV2Editor.h:139
SuilInstancePtr mSuilInstance
Definition: LV2Editor.h:138
bool mJustLeakMemory
Definition: LV2Editor.h:141
void Destroy()
Definition: LV2Editor.cpp:52
Storage locations to be connected to LV2 control ports.
Definition: LV2Ports.h:206
Abstraction of host services that a plug-ins native UI needs.