aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-11-20 23:26:49 +0100
committerDavid Robillard <d@drobilla.net>2020-02-16 22:22:59 +0100
commit01f07c9eb85ef2586d3ae5ea5f65113ac303bbcf (patch)
treed5b3502e388b4ba3cb8f2177b8e678f4c6fe08ae
parenta7a8d43cd191aa0e613164b9fae56165ae9b1f81 (diff)
downloadlv2-ui-request-parameter.tar.xz
WIP: Add feature to request parameter from from UIui-request-parameter
-rw-r--r--lv2/core/meta.ttl2
-rw-r--r--lv2/ui/ui.h72
-rw-r--r--lv2/ui/ui.ttl8
-rw-r--r--plugins/eg-sampler.lv2/sampler.ttl1
-rw-r--r--plugins/eg-sampler.lv2/sampler_ui.c32
-rw-r--r--wscript2
6 files changed, 108 insertions, 9 deletions
diff --git a/lv2/core/meta.ttl b/lv2/core/meta.ttl
index 22aa976..40175f8 100644
--- a/lv2/core/meta.ttl
+++ b/lv2/core/meta.ttl
@@ -36,7 +36,7 @@ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH R
meta:kfoltman ,
meta:paniq ;
doap:release [
- doap:revision "1.17.0" ;
+ doap:revision "1.17.1" ;
doap:created "2019-03-27" ;
dcs:blame <http://drobilla.net/drobilla#me> ;
dcs:changeset [
diff --git a/lv2/ui/ui.h b/lv2/ui/ui.h
index 450a41e..8705ddb 100644
--- a/lv2/ui/ui.h
+++ b/lv2/ui/ui.h
@@ -29,6 +29,7 @@
#define LV2_UI_H
#include "lv2/core/lv2.h"
+#include "lv2/urid/urid.h"
#include <stdbool.h>
#include <stdint.h>
@@ -58,6 +59,7 @@
#define LV2_UI__portNotification LV2_UI_PREFIX "portNotification" ///< http://lv2plug.in/ns/extensions/ui#portNotification
#define LV2_UI__portSubscribe LV2_UI_PREFIX "portSubscribe" ///< http://lv2plug.in/ns/extensions/ui#portSubscribe
#define LV2_UI__protocol LV2_UI_PREFIX "protocol" ///< http://lv2plug.in/ns/extensions/ui#protocol
+#define LV2_UI__requestParameter LV2_UI_PREFIX "requestParameter" ///< http://lv2plug.in/ns/extensions/ui#requestParameter
#define LV2_UI__floatProtocol LV2_UI_PREFIX "floatProtocol" ///< http://lv2plug.in/ns/extensions/ui#floatProtocol
#define LV2_UI__peakProtocol LV2_UI_PREFIX "peakProtocol" ///< http://lv2plug.in/ns/extensions/ui#peakProtocol
#define LV2_UI__resize LV2_UI_PREFIX "resize" ///< http://lv2plug.in/ns/extensions/ui#resize
@@ -342,6 +344,76 @@ typedef struct _LV2UI_Touch {
bool grabbed);
} LV2UI_Touch;
+/** A status code for LV2UI_Request_Parameter::request. */
+typedef enum {
+ /**
+ Completed successfully.
+
+ The host will set the parameter later if the user choses a new value.
+ */
+ LV2UI_REQUEST_PARAMETER_SUCCESS,
+
+ /**
+ Parameter already being requested.
+
+ The host is already requesting a parameter from the user (for example, a
+ dialog is visible), or the UI is otherwise busy and can not make this
+ request.
+ */
+ LV2UI_REQUEST_PARAMETER_BUSY,
+
+ /**
+ Unknown parameter.
+
+ The host is not aware of this parameter, and is not able to set a new
+ value for it.
+ */
+ LV2UI_REQUEST_PARAMETER_ERR_UNKNOWN,
+
+ /**
+ Unsupported parameter.
+
+ The host knows about this parameter, but does not support requesting a
+ new value for it from the user. This is likely because the host does
+ not have UI support for choosing a value with the appropriate type.
+ */
+ LV2UI_REQUEST_PARAMETER_ERR_UNSUPPORTED
+} LV2UI_Request_Parameter_Status;
+
+/**
+ A feature to request a new parameter value from the host.
+*/
+typedef struct _LV2UI_Request_Parameter {
+ /**
+ Pointer to opaque data which must be passed to request().
+ */
+ LV2UI_Feature_Handle handle;
+
+ /**
+ Request a value for a parameter from the host.
+
+ The main use case for this is a UI requesting a file path from the host,
+ but conceptually it can be used to request any parameter value.
+
+ This function returns immediately, and the return value indicates
+ whether the host can fulfill the request. The host may notify the
+ plugin about any new parameter value, for example when a file is
+ selected by the user, via the usual mechanism. Typically, the host will
+ send a message (using the atom and path extensions) to the plugin that
+ sets the new parameter value, and the plugin will notify the UI via a
+ message as usual for any other parameter change.
+
+ The host can determine details about the property, like the value type,
+ from the plugin data.
+
+ @param handle The handle field of this struct.
+ @param key The URID of the parameter.
+ @return 0 on success, non-zero on error.
+ */
+ LV2UI_Request_Parameter_Status (*request)(LV2UI_Feature_Handle handle,
+ LV2_URID key);
+} LV2UI_Request_Parameter;
+
/**
UI Idle Interface (LV2_UI__idleInterface)
diff --git a/lv2/ui/ui.ttl b/lv2/ui/ui.ttl
index ecebbf4..aa98596 100644
--- a/lv2/ui/ui.ttl
+++ b/lv2/ui/ui.ttl
@@ -309,6 +309,14 @@ plugin UI. This feature corresponds to the LV2UI_Touch struct, which
should be passed with the URI LV2_UI__touch.</p>
""" .
+ui:requestParameter
+ a lv2:Feature ;
+ lv2:documentation """
+<p>A feature to request a parameter value from the user via the host. This
+feature corresponds to the LV2UI_Request_Parameter struct, which should be
+passed with the URI LV2_UI__requestParameter.</p>
+""" .
+
ui:idleInterface
a lv2:Feature ,
lv2:ExtensionData ;
diff --git a/plugins/eg-sampler.lv2/sampler.ttl b/plugins/eg-sampler.lv2/sampler.ttl
index 960276a..4bab670 100644
--- a/plugins/eg-sampler.lv2/sampler.ttl
+++ b/plugins/eg-sampler.lv2/sampler.ttl
@@ -64,6 +64,7 @@
<http://lv2plug.in/plugins/eg-sampler#ui>
a ui:GtkUI ;
lv2:requiredFeature urid:map ;
+ lv2:optionalFeature ui:requestParameter ;
lv2:extensionData ui:showInterface ;
ui:portNotification [
ui:plugin <http://lv2plug.in/plugins/eg-sampler> ;
diff --git a/plugins/eg-sampler.lv2/sampler_ui.c b/plugins/eg-sampler.lv2/sampler_ui.c
index 89bca2f..cf4ccbd 100644
--- a/plugins/eg-sampler.lv2/sampler_ui.c
+++ b/plugins/eg-sampler.lv2/sampler_ui.c
@@ -47,11 +47,12 @@
#define MIN_CANVAS_H 80
typedef struct {
- LV2_Atom_Forge forge;
- LV2_URID_Map* map;
- LV2_Log_Logger logger;
- SamplerURIs uris;
- PeaksReceiver precv;
+ LV2_Atom_Forge forge;
+ LV2_URID_Map* map;
+ LV2UI_Request_Parameter* request_parameter;
+ LV2_Log_Logger logger;
+ SamplerURIs uris;
+ PeaksReceiver precv;
LV2UI_Write_Function write;
LV2UI_Controller controller;
@@ -59,6 +60,7 @@ typedef struct {
GtkWidget* box;
GtkWidget* play_button;
GtkWidget* file_button;
+ GtkWidget* request_file_button;
GtkWidget* button_box;
GtkWidget* canvas;
GtkWidget* window; /* For optional show interface. */
@@ -91,6 +93,15 @@ on_file_set(GtkFileChooserButton* widget, void* handle)
}
static void
+on_request_file(GtkButton* widget, void* handle)
+{
+ SamplerUI* ui = (SamplerUI*)handle;
+
+ ui->request_parameter->request(ui->request_parameter->handle,
+ ui->uris.eg_sample);
+}
+
+static void
on_play_clicked(GtkFileChooserButton* widget, void* handle)
{
SamplerUI* ui = (SamplerUI*)handle;
@@ -220,8 +231,9 @@ instantiate(const LV2UI_Descriptor* descriptor,
// Get host features
const char* missing = lv2_features_query(
features,
- LV2_LOG__log, &ui->logger.log, false,
- LV2_URID__map, &ui->map, true,
+ LV2_LOG__log, &ui->logger.log , false,
+ LV2_URID__map, &ui->map, true,
+ LV2_UI__requestParameter, &ui->request_parameter, false,
NULL);
lv2_log_logger_set_map(&ui->logger, ui->map);
if (missing) {
@@ -242,16 +254,21 @@ instantiate(const LV2UI_Descriptor* descriptor,
ui->button_box = gtk_hbox_new(FALSE, 4);
ui->file_button = gtk_file_chooser_button_new(
"Load Sample", GTK_FILE_CHOOSER_ACTION_OPEN);
+ ui->request_file_button = gtk_button_new_with_label("Request Sample");
gtk_widget_set_size_request(ui->canvas, MIN_CANVAS_W, MIN_CANVAS_H);
gtk_container_set_border_width(GTK_CONTAINER(ui->box), 4);
gtk_box_pack_start(GTK_BOX(ui->box), ui->canvas, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(ui->box), ui->button_box, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(ui->button_box), ui->play_button, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(ui->button_box), ui->request_file_button, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(ui->button_box), ui->file_button, TRUE, TRUE, 0);
g_signal_connect(ui->file_button, "file-set",
G_CALLBACK(on_file_set), ui);
+ g_signal_connect(ui->request_file_button, "clicked",
+ G_CALLBACK(on_request_file), ui);
+
g_signal_connect(ui->play_button, "clicked",
G_CALLBACK(on_play_clicked), ui);
@@ -283,6 +300,7 @@ cleanup(LV2UI_Handle handle)
gtk_widget_destroy(ui->canvas);
gtk_widget_destroy(ui->button_box);
gtk_widget_destroy(ui->file_button);
+ gtk_widget_destroy(ui->request_file_button);
free(ui);
}
diff --git a/wscript b/wscript
index 678e9b0..4186c98 100644
--- a/wscript
+++ b/wscript
@@ -9,7 +9,7 @@ from waflib.extras import autowaf as autowaf
# Mandatory waf variables
APPNAME = 'lv2' # Package name for waf dist
-VERSION = '1.17.0' # Package version for waf dist
+VERSION = '1.17.1' # Package version for waf dist
top = '.' # Source directory
out = 'build' # Build directory