aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2021-01-05 23:34:50 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2021-01-05 23:34:50 +0100
commitd8b51d0833f7b3a2d84de0c047e9ee2ac0c35404 (patch)
tree944bae4c4c386cd5190f303e6d81a101d248e010
parent14ad396b324d618767b9bb60685d2eb097e808cd (diff)
downloadsherlock.lv2-d8b51d0833f7b3a2d84de0c047e9ee2ac0c35404.tar.xz
ui: add support for ui:scaleFactor.
-rw-r--r--VERSION2
-rw-r--r--sherlock.h1
-rw-r--r--sherlock_nk.c34
-rw-r--r--sherlock_nk.h2
-rw-r--r--sherlock_ui.ttl10
5 files changed, 44 insertions, 5 deletions
diff --git a/VERSION b/VERSION
index b639189..010e590 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.25.25
+0.25.51
diff --git a/sherlock.h b/sherlock.h
index db0eb45..2f6c981 100644
--- a/sherlock.h
+++ b/sherlock.h
@@ -30,6 +30,7 @@
#include "lv2/lv2plug.in/ns/ext/patch/patch.h"
#include "lv2/lv2plug.in/ns/ext/log/log.h"
#include "lv2/lv2plug.in/ns/ext/log/logger.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/extensions/units/units.h"
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
diff --git a/sherlock_nk.c b/sherlock_nk.c
index 05d1b08..8ca249a 100644
--- a/sherlock_nk.c
+++ b/sherlock_nk.c
@@ -181,7 +181,7 @@ _post_redisplay(plughandle_t *handle)
float
_get_scale (plughandle_t *handle)
{
- return nk_pugl_get_scale(&handle->win);
+ return handle->scale;
}
static int
@@ -283,16 +283,29 @@ instantiate(const LV2UI_Descriptor *descriptor __attribute__((unused)),
void *parent = NULL;
LV2UI_Resize *host_resize = NULL;
+ LV2_Options_Option *opts = NULL;
for(int i=0; features[i]; i++)
{
if(!strcmp(features[i]->URI, LV2_URID__map))
+ {
handle->map = features[i]->data;
+ }
else if(!strcmp(features[i]->URI, LV2_URID__unmap))
+ {
handle->unmap = features[i]->data;
+ }
else if(!strcmp(features[i]->URI, LV2_UI__parent))
+ {
parent = features[i]->data;
+ }
else if(!strcmp(features[i]->URI, LV2_UI__resize))
+ {
host_resize = features[i]->data;
+ }
+ else if(!strcmp(features[i]->URI, LV2_OPTIONS__options))
+ {
+ opts = features[i]->data;
+ }
}
if(!handle->map || !handle->unmap)
@@ -364,6 +377,25 @@ instantiate(const LV2UI_Descriptor *descriptor __attribute__((unused)),
cfg->font.size = 13;
*(intptr_t *)widget = nk_pugl_init(&handle->win);
+
+ const LV2_URID ui_scaleFactor = handle->map->map(handle->map->handle,
+ LV2_UI__scaleFactor);
+
+ for(LV2_Options_Option *opt = opts;
+ opt && (opt->key != 0) && (opt->value != NULL);
+ opt++)
+ {
+ if( (opt->key == ui_scaleFactor) && (opt->type == handle->forge.Float) )
+ {
+ handle->scale = *(float*)opt->value;
+ }
+ }
+
+ if(handle->scale == 0.f)
+ {
+ handle->scale = nk_pugl_get_scale(&handle->win);
+ }
+
nk_pugl_show(&handle->win);
_clear(handle);
diff --git a/sherlock_nk.h b/sherlock_nk.h
index 5a222ca..009d353 100644
--- a/sherlock_nk.h
+++ b/sherlock_nk.h
@@ -69,6 +69,8 @@ struct _plughandle_t {
LV2_URID event_transfer;
LV2_OSC_URID osc_urid;
+ float scale;
+
PROPS_T(props, MAX_NPROPS);
struct {
LV2_URID overwrite;
diff --git a/sherlock_ui.ttl b/sherlock_ui.ttl
index 5e735f3..becfea0 100644
--- a/sherlock_ui.ttl
+++ b/sherlock_ui.ttl
@@ -19,6 +19,7 @@
@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
@prefix urid: <http://lv2plug.in/ns/ext/urid#> .
@prefix patch: <http://lv2plug.in/ns/ext/patch#> .
+@prefix opts: <http://lv2plug.in/ns/ext/options#> .
@prefix sherlock: <http://open-music-kontrollers.ch/lv2/sherlock#> .
@@ -33,7 +34,8 @@ sherlock:atom_inspector_4_nk
] ;
lv2:extensionData ui:idleInterface, ui:resize ;
lv2:optionalFeature ui:resize ;
- lv2:requiredFeature ui:idleInterface, urid:map, urid:unmap .
+ opts:supportedOption ui:scaleFactor ;
+ lv2:requiredFeature ui:idleInterface, urid:map, urid:unmap, opts:options .
# MIDI Inspector UI
sherlock:midi_inspector_4_nk
@@ -46,7 +48,8 @@ sherlock:midi_inspector_4_nk
] ;
lv2:extensionData ui:idleInterface, ui:resize ;
lv2:optionalFeature ui:resize ;
- lv2:requiredFeature ui:idleInterface, urid:map, urid:unmap .
+ opts:supportedOption ui:scaleFactor ;
+ lv2:requiredFeature ui:idleInterface, urid:map, urid:unmap, opts:options .
# OSC Inspector UI
sherlock:osc_inspector_4_nk
@@ -59,4 +62,5 @@ sherlock:osc_inspector_4_nk
] ;
lv2:extensionData ui:idleInterface, ui:resize ;
lv2:optionalFeature ui:resize ;
- lv2:requiredFeature ui:idleInterface, urid:map, urid:unmap .
+ opts:supportedOption ui:scaleFactor ;
+ lv2:requiredFeature ui:idleInterface, urid:map, urid:unmap, opts:options .