From a91526c672e083bb6fcc1b994d4c3534555bfe03 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Mon, 18 Feb 2013 19:20:35 +0000 Subject: [PATCH] Add support for ui:touch extension (not tested in a host) --- pui/lv2pui.cpp | 12 ++++++++++++ pui/lv2pui.h | 3 +++ pui/pui.cpp | 4 ++++ pui/pui.h | 2 ++ 4 files changed, 21 insertions(+) diff --git a/pui/lv2pui.cpp b/pui/lv2pui.cpp index 1649301..75b8d56 100644 --- a/pui/lv2pui.cpp +++ b/pui/lv2pui.cpp @@ -27,12 +27,17 @@ void LV2PUi::Instantiate( LV2UI_Widget *widget, const LV2_Feature *const *features) { + this->resize = NULL; + this->touch = NULL; + PuglNativeWindow parent = 0; for (; features && *features; ++features) { if (!strcmp((*features)->URI, LV2_UI__parent)) { parent = (PuglNativeWindow)(*features)->data; } else if (!strcmp((*features)->URI, LV2_UI__resize)) { 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) { LV2PUi *lv2pui = (LV2PUi *)handle; diff --git a/pui/lv2pui.h b/pui/lv2pui.h index c2ca176..8abbff6 100644 --- a/pui/lv2pui.h +++ b/pui/lv2pui.h @@ -12,6 +12,7 @@ struct LV2PUi : PUi { LV2UI_Write_Function write; LV2UI_Controller controller; LV2UI_Resize *resize; + LV2UI_Touch *touch; 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 ParameterChanged(const Widget *w); + + /* virtual */ void WidgetGrabbed(const Widget *widget, bool grabbed); }; struct StringCompare { diff --git a/pui/pui.cpp b/pui/pui.cpp index 9f35eea..b9222b8 100644 --- a/pui/pui.cpp +++ b/pui/pui.cpp @@ -125,6 +125,10 @@ void PUi::OnMouse(int button, bool press, int x, int y) this->mb &= ~(1 << button); } + if (this->active) { + this->WidgetGrabbed(this->active, this->mb); + } + if (!this->mb) { /* No button press, check for widget focus change */ Widget *w = this->widget->GetWidget(x, y); diff --git a/pui/pui.h b/pui/pui.h index 63d2303..a312fa5 100644 --- a/pui/pui.h +++ b/pui/pui.h @@ -63,6 +63,8 @@ struct PUi : PTextures { virtual void ParameterChanged(const Widget *widget) = 0; void SetFunc(); + + virtual void WidgetGrabbed(const Widget *widget, bool grabbed) {} }; #endif /* PUI_H */