Add support for ui:touch extension (not tested in a host)

master
Peter Nelson 2013-02-18 19:20:35 +00:00
parent d2c38bb48a
commit a91526c672
4 changed files with 21 additions and 0 deletions

View File

@ -27,12 +27,17 @@ void LV2PUi::Instantiate(
LV2UI_Widget *widget, LV2UI_Widget *widget,
const LV2_Feature *const *features) const LV2_Feature *const *features)
{ {
this->resize = NULL;
this->touch = NULL;
PuglNativeWindow parent = 0; PuglNativeWindow parent = 0;
for (; features && *features; ++features) { for (; features && *features; ++features) {
if (!strcmp((*features)->URI, LV2_UI__parent)) { if (!strcmp((*features)->URI, LV2_UI__parent)) {
parent = (PuglNativeWindow)(*features)->data; parent = (PuglNativeWindow)(*features)->data;
} else if (!strcmp((*features)->URI, LV2_UI__resize)) { } else if (!strcmp((*features)->URI, LV2_UI__resize)) {
this->resize = (LV2UI_Resize *)(*features)->data; this->resize = (LV2UI_Resize *)(*features)->data;
} else if (!strcmp((*features)->URI, LV2_UI__touch)) {
this->touch = (LV2UI_Touch *)(*features)->data;
} }
} }
@ -78,6 +83,13 @@ LV2PUi::~LV2PUi()
{ {
} }
void LV2PUi::WidgetGrabbed(const Widget *widget, bool grabbed)
{
if (this->touch) {
this->touch->touch(this, widget->port, grabbed);
}
}
static void lv2pui_cleanup(LV2UI_Handle handle) static void lv2pui_cleanup(LV2UI_Handle handle)
{ {
LV2PUi *lv2pui = (LV2PUi *)handle; LV2PUi *lv2pui = (LV2PUi *)handle;

View File

@ -12,6 +12,7 @@ struct LV2PUi : PUi {
LV2UI_Write_Function write; LV2UI_Write_Function write;
LV2UI_Controller controller; LV2UI_Controller controller;
LV2UI_Resize *resize; LV2UI_Resize *resize;
LV2UI_Touch *touch;
virtual ~LV2PUi(); virtual ~LV2PUi();
@ -27,6 +28,8 @@ struct LV2PUi : PUi {
virtual void PortEvent(uint32_t port_index, uint32_t buffer_size, uint32_t format, const void *buffer); virtual void PortEvent(uint32_t port_index, uint32_t buffer_size, uint32_t format, const void *buffer);
/* virtual */ void ParameterChanged(const Widget *w); /* virtual */ void ParameterChanged(const Widget *w);
/* virtual */ void WidgetGrabbed(const Widget *widget, bool grabbed);
}; };
struct StringCompare { struct StringCompare {

View File

@ -125,6 +125,10 @@ void PUi::OnMouse(int button, bool press, int x, int y)
this->mb &= ~(1 << button); this->mb &= ~(1 << button);
} }
if (this->active) {
this->WidgetGrabbed(this->active, this->mb);
}
if (!this->mb) { if (!this->mb) {
/* No button press, check for widget focus change */ /* No button press, check for widget focus change */
Widget *w = this->widget->GetWidget(x, y); Widget *w = this->widget->GetWidget(x, y);

View File

@ -63,6 +63,8 @@ struct PUi : PTextures {
virtual void ParameterChanged(const Widget *widget) = 0; virtual void ParameterChanged(const Widget *widget) = 0;
void SetFunc(); void SetFunc();
virtual void WidgetGrabbed(const Widget *widget, bool grabbed) {}
}; };
#endif /* PUI_H */ #endif /* PUI_H */