30 #include <lv2/lv2plug.in/ns/extensions/ui/ui.h> 32 #include <lvtk/feature.hpp> 33 #include <lvtk/ext/common.h> 34 #include <lvtk/ext/data_access.hpp> 35 #include <lvtk/ext/instance_access.hpp> 37 #include "private/debug.hpp" 38 #include "private/ui_features.hpp" 44 #define widget_cast(w) reinterpret_cast<LV2UI_Widget*> (w) 57 get_lv2g2g_descriptors();
89 template<
class Derived,
class Ext1 = end,
class Ext2 = end,
90 class Ext3 = end,
class Ext4 = end,
class Ext5 = end,
91 class Ext6 = end,
class Ext7 = end,
class Ext8 = end,
93 class UI :
public MixinTree<Derived, Ext1, Ext2, Ext3, Ext4, Ext5, Ext6,
106 m_features = s_features;
107 m_bundle_path = s_bundle_path;
115 Derived::map_feature_handlers(hmap);
119 FeatureHandlerMap::iterator miter;
120 miter = hmap.find((*iter)->URI);
121 if (miter != hmap.end())
123 miter->second(static_cast<Derived*>(
this),
133 port_event(uint32_t port, uint32_t buffer_size, uint32_t format,
146 LV2UI_Descriptor desc;
147 std::memset(&desc, 0,
sizeof(LV2UI_Descriptor));
148 desc.URI = strdup(uri);
149 desc.instantiate = &Derived::create_ui_instance;
150 desc.cleanup = &Derived::delete_ui_instance;
151 desc.port_event = &Derived::_port_event;
152 desc.extension_data = &Derived::extension_data;
154 get_lv2g2g_descriptors().push_back(desc);
155 return get_lv2g2g_descriptors().size() - 1;
165 write(uint32_t port, uint32_t buffer_size, uint32_t format,
168 (*m_wfunc)(m_ctrl, port, buffer_size, format, buffer);
175 write(port,
sizeof(
float), 0, &value);
193 return m_bundle_path;
212 #if defined (LVTK_EXTRAS_ENABLED) 213 friend class WriteMIDI<true>::I<Derived>;
214 friend class
WriteMIDI<false>::I<Derived>;
215 friend class WriteOSC<true>::I<Derived>;
216 friend class WriteOSC<false>::I<Derived>;
225 create_ui_instance (LV2UI_Descriptor const* descriptor,
226 char const* plugin_uri, char const* bundle_path,
227 LV2UI_Write_Function write_func, LV2UI_Controller ctrl,
228 LV2UI_Widget* widget, LV2_Feature const* const * features)
234 s_wfunc = write_func;
235 s_features = features;
236 s_bundle_path = bundle_path;
241 std::clog <<
"[LV2::UI] Creating UI...\n\n" 242 <<
" Plugin URI: \"" << plugin_uri <<
"\"\n" 243 <<
" Bundle path: \"" << bundle_path <<
"\"\n" 244 <<
" UI Features:\n";
246 for (iter = features; *iter; ++iter)
247 std::clog <<
" \"" << (*iter)->URI <<
"\"\n";
252 std::clog <<
" Creating LV2 Widget..." << std::endl;
253 Derived* ui =
new Derived(plugin_uri);
254 *widget = ui->widget();
257 if (ui->check_ok() && *widget != NULL)
259 return reinterpret_cast<LV2UI_Handle
>(ui);
272 delete_ui_instance(LV2UI_Handle instance)
274 delete static_cast<Derived*
>(instance);
282 _port_event(LV2UI_Handle instance, uint32_t port,
283 uint32_t buffer_size, uint32_t format,
void const* buffer)
285 static_cast<Derived*
>(instance)->port_event(port, buffer_size,
290 LV2UI_Write_Function m_wfunc;
292 char const* m_bundle_path;
295 static LV2UI_Write_Function s_wfunc;
297 static char const* s_bundle_path;
302 template<
class Derived,
class Ext1,
class Ext2,
class Ext3,
class Ext4,
303 class Ext5,
class Ext6,
class Ext7,
class Ext8,
class Ext9>
307 template<
class Derived,
class Ext1,
class Ext2,
class Ext3,
class Ext4,
308 class Ext5,
class Ext6,
class Ext7,
class Ext8,
class Ext9>
309 LV2UI_Write_Function
UI<Derived, Ext1, Ext2, Ext3, Ext4, Ext5, Ext6,
310 Ext7, Ext8, Ext9>::s_wfunc = 0;
312 template<
class Derived,
class Ext1,
class Ext2,
class Ext3,
class Ext4,
313 class Ext5,
class Ext6,
class Ext7,
class Ext8,
class Ext9>
315 Ext6, Ext7, Ext8, Ext9>::s_features = 0;
317 template<
class Derived,
class Ext1,
class Ext2,
class Ext3,
class Ext4,
318 class Ext5,
class Ext6,
class Ext7,
class Ext8,
class Ext9>
319 char const*
UI<Derived, Ext1, Ext2, Ext3, Ext4, Ext5, Ext6, Ext7, Ext8,
320 Ext9>::s_bundle_path = 0;
void write_control(uint32_t port, float value)
Definition: ui.hpp:173
void write(uint32_t port, uint32_t buffer_size, uint32_t format, void const *buffer)
Definition: ui.hpp:165
Definition: write_midi.hpp:44
void * controller()
Definition: ui.hpp:203
LV2_Feature Feature
Definition: feature.hpp:41
static int register_class(char const *uri)
Definition: ui.hpp:144
Definition: feature.hpp:34
void port_event(uint32_t port, uint32_t buffer_size, uint32_t format, void const *buffer)
Definition: ui.hpp:133
Feature const *const * features()
Definition: ui.hpp:184
map< string, FeatureHandler > FeatureHandlerMap
Definition: feature.hpp:57
char const * bundle_path() const
Definition: ui.hpp:191