Compare commits

..

No commits in common. "8976c54698c442f3bc0e778129a106f58bdbee91" and "ee9771b96a430e03267fab9736615e61dfdc7bad" have entirely different histories.

4 changed files with 28 additions and 140 deletions

View File

@ -125,11 +125,15 @@
{{=it.tibia.lv2.ttlURI(it.lv2.ui.uri)}} {{=it.tibia.lv2.ttlURI(it.lv2.ui.uri)}}
a ui:@UI_TYPE@ ; a ui:@UI_TYPE@ ;
ui:binary <{{=it.product.bundleName}}@DLL_SUFFIX@> ; ui:binary <{{=it.product.bundleName}}@DLL_SUFFIX@> ;
lv2:extensionData ui:resize ;
{{?!it.product.ui.userResizable}} {{?!it.product.ui.userResizable}}
lv2:optionalFeature ui:noUserResize ; # doesn't work as lv2:requiredFeature, don't ask me why lv2:optionalFeature ui:noUserResize ; # doesn't work as lv2:requiredFeature, don't ask me why
{{?!it.product.ui.selfResizable}} {{?!it.product.ui.selfResizable}}
lv2:optionalFeature ui:fixedSize ; lv2:optionalFeature ui:fixedSize ;
{{?}} {{?}}
{{?}}
{{?it.product.ui.selfResizable}}
lv2:optionalFeature ui:resize ;
{{?}} {{?}}
lv2:requiredFeature ui:idleInterface ; lv2:requiredFeature ui:idleInterface ;
lv2:extensionData ui:idleInterface . lv2:extensionData ui:idleInterface .

View File

@ -31,12 +31,9 @@ typedef struct {
typedef struct { typedef struct {
void *handle; void *handle;
const char *format; const char *format;
const char *(*get_bindir)(void *handle); const char *(*get_bindir)(void *handle);
const char *(*get_datadir)(void *handle); const char *(*get_datadir)(void *handle);
void (*set_parameter_begin)(void *handle, size_t index);
void (*set_parameter)(void *handle, size_t index, float value); void (*set_parameter)(void *handle, size_t index, float value);
void (*set_parameter_end) (void *handle, size_t index);
} plugin_ui_callbacks; } plugin_ui_callbacks;
#include "data.h" #include "data.h"
@ -378,8 +375,6 @@ typedef struct {
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0 # if DATA_PRODUCT_CONTROL_INPUTS_N > 0
LV2UI_Write_Function write; LV2UI_Write_Function write;
LV2UI_Controller controller; LV2UI_Controller controller;
char has_touch;
LV2UI_Touch touch;
# endif # endif
} ui_instance; } ui_instance;
@ -396,33 +391,26 @@ static const char * ui_get_bundle_path_cb(void *handle) {
} }
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0 # if DATA_PRODUCT_CONTROL_INPUTS_N > 0
static void ui_set_parameter_begin_cb(void *handle, size_t index) {
ui_instance *instance = (ui_instance *)handle;
if (instance->has_touch) {
index = index_to_param[index];
instance->touch.touch(instance->touch.handle, index, true);
}
}
static void ui_set_parameter_cb(void *handle, size_t index, float value) { static void ui_set_parameter_cb(void *handle, size_t index, float value) {
ui_instance *instance = (ui_instance *)handle; ui_instance *instance = (ui_instance *)handle;
index = index_to_param[index]; index = index_to_param[index];
value = adjust_param(index - CONTROL_INPUT_INDEX_OFFSET, value); value = adjust_param(index - CONTROL_INPUT_INDEX_OFFSET, value);
instance->write(instance->controller, index, sizeof(float), 0, &value); instance->write(instance->controller, index, sizeof(float), 0, &value);
} }
static void ui_set_parameter_end_cb(void *handle, size_t index) {
ui_instance *instance = (ui_instance *)handle;
if (instance->has_touch) {
index = index_to_param[index];
instance->touch.touch(instance->touch.handle, index, false);
}
}
# endif # endif
static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const char * plugin_uri, const char * bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget * widget, const LV2_Feature * const * features) { static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const char * plugin_uri, const char * bundle_path, LV2UI_Write_Function write_function, LV2UI_Controller controller, LV2UI_Widget * widget, const LV2_Feature * const * features) {
(void)descriptor; (void)descriptor;
(void)plugin_uri; (void)plugin_uri;
(void)bundle_path;
char has_parent = 0;
void *parent = NULL;
for (size_t i = 0; features[i] != NULL; i++)
if (!strcmp(features[i]->URI, LV2_UI__parent)) {
has_parent = 1;
parent = features[i]->data;
}
ui_instance *instance = malloc(sizeof(ui_instance)); ui_instance *instance = malloc(sizeof(ui_instance));
if (instance == NULL) if (instance == NULL)
@ -432,33 +420,15 @@ static LV2UI_Handle ui_instantiate(const LV2UI_Descriptor * descriptor, const ch
if (instance->bundle_path == NULL) if (instance->bundle_path == NULL)
goto err_bundle_path; goto err_bundle_path;
char has_parent = 0;
void *parent = NULL;
instance->has_touch = 0;
for (size_t i = 0; features[i] != NULL; i++) {
if (!strcmp(features[i]->URI, LV2_UI__parent)) {
has_parent = 1;
parent = features[i]->data;
}
if (!strcmp(features[i]->URI, LV2_UI__touch)) {
instance->has_touch = 1;
instance->touch = *((LV2UI_Touch *)features[i]->data);
}
}
plugin_ui_callbacks cbs = { plugin_ui_callbacks cbs = {
/* .handle = */ (void *)instance, /* .handle = */ (void *)instance,
/* .format = */ "lv2", /* .format = */ "lv2",
/* .get_bindir = */ ui_get_bundle_path_cb, /* .get_bindir = */ ui_get_bundle_path_cb,
/* .get_datadir = */ ui_get_bundle_path_cb, /* .get_datadir = */ ui_get_bundle_path_cb,
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0 # if DATA_PRODUCT_CONTROL_INPUTS_N > 0
/* .set_parameter_begin = */ ui_set_parameter_begin_cb, /* .set_parameter = */ ui_set_parameter_cb
/* .set_parameter = */ ui_set_parameter_cb,
/* .set_parameter_end = */ ui_set_parameter_end_cb
# else # else
/* .set_parameter_begin = */ NULL, /* .set_parameter = */ NULL
/* .set_parameter = */ NULL,
/* .set_parameter_end = */ NULL
# endif # endif
}; };
# if DATA_PRODUCT_CONTROL_INPUTS_N > 0 # if DATA_PRODUCT_CONTROL_INPUTS_N > 0

View File

@ -33,9 +33,7 @@ typedef struct {
const char *format; const char *format;
const char *(*get_bindir)(void *handle); const char *(*get_bindir)(void *handle);
const char *(*get_datadir)(void *handle); const char *(*get_datadir)(void *handle);
void (*set_parameter_begin)(void *handle, size_t index);
void (*set_parameter)(void *handle, size_t index, float value); void (*set_parameter)(void *handle, size_t index, float value);
void (*set_parameter_end)(void *handle, size_t index);
} plugin_ui_callbacks; } plugin_ui_callbacks;
#pragma GCC diagnostic push #pragma GCC diagnostic push
@ -1124,18 +1122,6 @@ static void plugViewUpdateAllParameters(plugView *view) {
plugin_ui_set_parameter(view->ui, parameterData[i].index, view->ctrl->parameters[i]); plugin_ui_set_parameter(view->ui, parameterData[i].index, view->ctrl->parameters[i]);
} }
static void plugViewSetParameterBeginCb(void *handle, size_t index) {
TRACE("set parameter begin cb\n");
# ifdef DATA_PARAM_LATENCY_INDEX
if (index == DATA_PARAM_LATENCY_INDEX)
return;
index = index >= DATA_PARAM_LATENCY_INDEX ? index - 1 : index;
# endif
plugView *v = (plugView *)handle;
v->ctrl->componentHandler->lpVtbl->beginEdit(v->ctrl->componentHandler, parameterInfo[index].id);
}
static void plugViewSetParameterCb(void *handle, size_t index, float value) { static void plugViewSetParameterCb(void *handle, size_t index, float value) {
TRACE("set parameter cb\n"); TRACE("set parameter cb\n");
@ -1146,21 +1132,10 @@ static void plugViewSetParameterCb(void *handle, size_t index, float value) {
# endif # endif
plugView *v = (plugView *)handle; plugView *v = (plugView *)handle;
v->ctrl->parameters[index] = parameterAdjust(index, value); // let Reaper find the updated value v->ctrl->parameters[index] = parameterAdjust(index, value); // let Reaper find the updated value
v->ctrl->componentHandler->lpVtbl->beginEdit(v->ctrl->componentHandler, parameterInfo[index].id);
v->ctrl->componentHandler->lpVtbl->performEdit(v->ctrl->componentHandler, parameterInfo[index].id, parameterUnmap(index, v->ctrl->parameters[index])); v->ctrl->componentHandler->lpVtbl->performEdit(v->ctrl->componentHandler, parameterInfo[index].id, parameterUnmap(index, v->ctrl->parameters[index]));
}
static void plugViewSetParameterEndCb(void *handle, size_t index) {
TRACE("set parameter end cb\n");
# ifdef DATA_PARAM_LATENCY_INDEX
if (index == DATA_PARAM_LATENCY_INDEX)
return;
index = index >= DATA_PARAM_LATENCY_INDEX ? index - 1 : index;
# endif
plugView *v = (plugView *)handle;
v->ctrl->componentHandler->lpVtbl->endEdit(v->ctrl->componentHandler, parameterInfo[index].id); v->ctrl->componentHandler->lpVtbl->endEdit(v->ctrl->componentHandler, parameterInfo[index].id);
} }
# endif # endif
# ifdef __APPLE__ # ifdef __APPLE__
@ -1196,13 +1171,9 @@ static Steinberg_tresult plugViewAttached(void* thisInterface, void* parent, Ste
/* .get_bindir = */ get_bindir_cb, /* .get_bindir = */ get_bindir_cb,
/* .get_datadir = */ get_datadir_cb, /* .get_datadir = */ get_datadir_cb,
# if DATA_PRODUCT_PARAMETERS_N > 0 # if DATA_PRODUCT_PARAMETERS_N > 0
/* .set_parameter_begin = */ plugViewSetParameterBeginCb, /* .set_parameter = */ plugViewSetParameterCb
/* .set_parameter = */ plugViewSetParameterCb,
/* .set_parameter_end = */ plugViewSetParameterEndCb
# else # else
/* .set_parameter_begin = */ NULL, /* .set_parameter = */ NULL
/* .set_parameter = */ NULL,
/* .set_parameter_end = */ NULL
# endif # endif
}; };
v->ui = plugin_ui_create(1, parent, &cbs); v->ui = plugin_ui_create(1, parent, &cbs);

View File

@ -40,8 +40,6 @@ typedef struct {
char bypass; char bypass;
float y_z1; float y_z1;
int param_down;
plugin_ui_callbacks cbs; plugin_ui_callbacks cbs;
} plugin_ui; } plugin_ui;
@ -146,7 +144,7 @@ static PuglStatus plugin_ui_on_event(PuglView *view, const PuglEvent *event) {
puglPostRedisplay(instance->view); puglPostRedisplay(instance->view);
} }
break; break;
case PUGL_BUTTON_PRESS: case PUGL_BUTTON_RELEASE:
{ {
plugin_ui *instance = (plugin_ui *)puglGetHandle(view); plugin_ui *instance = (plugin_ui *)puglGetHandle(view);
const PuglButtonEvent *ev = (const PuglButtonEvent *)event; const PuglButtonEvent *ev = (const PuglButtonEvent *)event;
@ -157,79 +155,25 @@ static PuglStatus plugin_ui_on_event(PuglView *view, const PuglEvent *event) {
if (ev->x >= x + 0.1 * w && ev->x <= x + 0.9 * w if (ev->x >= x + 0.1 * w && ev->x <= x + 0.9 * w
&& ev->y >= y + 0.15 * h && ev->y <= y + 0.25 * h) { && ev->y >= y + 0.15 * h && ev->y <= y + 0.25 * h) {
instance->param_down = 0;
instance->gain = (float)((ev->x - (x + 0.1 * w)) / (0.8 * w)); instance->gain = (float)((ev->x - (x + 0.1 * w)) / (0.8 * w));
instance->cbs.set_parameter_begin(instance->cbs.handle, 0);
instance->cbs.set_parameter(instance->cbs.handle, 0, -60.f + 80.f * instance->gain); instance->cbs.set_parameter(instance->cbs.handle, 0, -60.f + 80.f * instance->gain);
puglPostRedisplay(instance->view); puglPostRedisplay(instance->view);
} else if (ev->x >= x + 0.1 * w && ev->x <= x + 0.9 * w } else if (ev->x >= x + 0.1 * w && ev->x <= x + 0.9 * w
&& ev->y >= y + 0.3 * h && ev->y <= y + 0.4 * h) { && ev->y >= y + 0.3 * h && ev->y <= y + 0.4 * h) {
instance->param_down = 1;
instance->delay = (float)((ev->x - (x + 0.1 * w)) / (0.8 * w)); instance->delay = (float)((ev->x - (x + 0.1 * w)) / (0.8 * w));
instance->cbs.set_parameter_begin(instance->cbs.handle, 1);
instance->cbs.set_parameter(instance->cbs.handle, 1, 1000.f * instance->delay); instance->cbs.set_parameter(instance->cbs.handle, 1, 1000.f * instance->delay);
puglPostRedisplay(instance->view); puglPostRedisplay(instance->view);
} else if (ev->x >= x + 0.1 * w && ev->x <= x + 0.9 * w } else if (ev->x >= x + 0.1 * w && ev->x <= x + 0.9 * w
&& ev->y >= y + 0.45 * h && ev->y <= y + 0.55 * h) { && ev->y >= y + 0.45 * h && ev->y <= y + 0.55 * h) {
instance->param_down = 2;
instance->cutoff = (float)((ev->x - (x + 0.1 * w)) / (0.8 * w)); instance->cutoff = (float)((ev->x - (x + 0.1 * w)) / (0.8 * w));
instance->cbs.set_parameter_begin(instance->cbs.handle, 2);
instance->cbs.set_parameter(instance->cbs.handle, 2, (632.4555320336746f * instance->cutoff + 20.653108640674372f) / (1.0326554320337158f - instance->cutoff)); instance->cbs.set_parameter(instance->cbs.handle, 2, (632.4555320336746f * instance->cutoff + 20.653108640674372f) / (1.0326554320337158f - instance->cutoff));
puglPostRedisplay(instance->view); puglPostRedisplay(instance->view);
} else if (ev->x >= x + 0.4 * w && ev->x <= x + 0.6 * w } else if (ev->x >= x + 0.4 * w && ev->x <= x + 0.6 * w
&& ev->y >= y + 0.6 * h && ev->y <= y + 0.7 * h) {
instance->param_down = 3;
}
}
break;
case PUGL_MOTION:
{
plugin_ui *instance = (plugin_ui *)puglGetHandle(view);
const PuglMotionEvent *ev = (const PuglMotionEvent *)event;
double x = instance->x;
double w = instance->w;
float v = ev->x < x + 0.1 * w ? 0.f : (ev->x > x + 0.9 * w ? 1.f : (float)((ev->x - (x + 0.1 * w)) / (0.8 * w)));
switch (instance->param_down) {
case 0:
instance->gain = v;
instance->cbs.set_parameter(instance->cbs.handle, 0, -60.f + 80.f * instance->gain);
puglPostRedisplay(instance->view);
break;
case 1:
instance->delay = v;
instance->cbs.set_parameter(instance->cbs.handle, 1, 1000.f * instance->delay);
puglPostRedisplay(instance->view);
break;
case 2:
instance->cutoff = v;
instance->cbs.set_parameter(instance->cbs.handle, 2, (632.4555320336746f * instance->cutoff + 20.653108640674372f) / (1.0326554320337158f - instance->cutoff));
puglPostRedisplay(instance->view);
break;
}
}
break;
case PUGL_BUTTON_RELEASE:
{
plugin_ui *instance = (plugin_ui *)puglGetHandle(view);
const PuglButtonEvent *ev = (const PuglButtonEvent *)event;
double x = instance->x;
double y = instance->y;
double w = instance->w;
double h = instance->h;
if (instance->param_down == 3)
if (ev->x >= x + 0.4 * w && ev->x <= x + 0.6 * w
&& ev->y >= y + 0.6 * h && ev->y <= y + 0.7 * h) { && ev->y >= y + 0.6 * h && ev->y <= y + 0.7 * h) {
instance->bypass = !instance->bypass; instance->bypass = !instance->bypass;
instance->cbs.set_parameter(instance->cbs.handle, 3, instance->bypass ? 1.f : 0.f); instance->cbs.set_parameter(instance->cbs.handle, 3, instance->bypass ? 1.f : 0.f);
puglPostRedisplay(instance->view); puglPostRedisplay(instance->view);
} }
if (instance->param_down != -1) {
instance->cbs.set_parameter_end(instance->cbs.handle, instance->param_down);
instance->param_down = -1;
}
} }
break; break;
case PUGL_EXPOSE: case PUGL_EXPOSE:
@ -249,7 +193,6 @@ static plugin_ui *plugin_ui_create(char has_parent, void *parent, plugin_ui_call
plugin_ui *instance = malloc(sizeof(plugin_ui)); plugin_ui *instance = malloc(sizeof(plugin_ui));
if (instance == NULL) if (instance == NULL)
return NULL; return NULL;
instance->param_down = -1;
instance->world = puglNewWorld(PUGL_MODULE, 0); instance->world = puglNewWorld(PUGL_MODULE, 0);
instance->view = puglNewView(instance->world); instance->view = puglNewView(instance->world);
puglSetSizeHint(instance->view, PUGL_DEFAULT_SIZE, WIDTH, HEIGHT); puglSetSizeHint(instance->view, PUGL_DEFAULT_SIZE, WIDTH, HEIGHT);