aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2021-01-06 00:05:30 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2021-01-06 00:05:30 +0100
commit6eb496b11fad341db967f0e600cd3fed8f934e18 (patch)
tree8b303c997dde089673369bf0af592a3089963a2d
parent31b61079898a916dd19b4e08d3ed6d1cf65775b9 (diff)
downloadvm.lv2-6eb496b11fad341db967f0e600cd3fed8f934e18.tar.xz
ui: add support for ui:scaleFactor.
-rw-r--r--VERSION2
-rw-r--r--vm_ui.c46
-rw-r--r--vm_ui.ttl4
3 files changed, 42 insertions, 10 deletions
diff --git a/VERSION b/VERSION
index b76fc26..d22656c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.11.23
+0.11.45
diff --git a/vm_ui.c b/vm_ui.c
index b16c9ad..bdbd0dd 100644
--- a/vm_ui.c
+++ b/vm_ui.c
@@ -67,6 +67,8 @@ struct _plughandle_t {
vm_plug_enum_t vm_plug;
+ float scale;
+
LV2_URID atom_eventTransfer;
LV2_URID vm_graph;
LV2_URID vm_sourceFilter;
@@ -513,7 +515,7 @@ _expose(struct nk_context *ctx, struct nk_rect wbounds, void *data)
{
plughandle_t *handle = data;
- handle->dy = 20.f * nk_pugl_get_scale(&handle->win);
+ handle->dy = 20.f * handle->scale;
const float dy = handle->dy;
// mouse sensitivity for dragable property widgets
@@ -1111,17 +1113,29 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
for(int i=0; features[i]; i++)
{
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_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_LOG__log))
+ {
handle->log = features[i]->data;
+ }
else if(!strcmp(features[i]->URI, LV2_OPTIONS__options))
+ {
opts = features[i]->data;
+ }
}
if(!parent)
@@ -1144,19 +1158,29 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
lv2_atom_forge_init(&handle->forge, handle->map);
- const LV2_URID param_sampleRate = handle->map->map(handle->map->handle, LV2_PARAMETERS__sampleRate);
- if(opts)
+ const LV2_URID param_sampleRate = handle->map->map(handle->map->handle,
+ LV2_PARAMETERS__sampleRate);
+ const LV2_URID ui_scaleFactor = handle->map->map(handle->map->handle,
+ LV2_UI__scaleFactor);
+
+ for(LV2_Options_Option *opt = opts;
+ (opt->key != 0) && (opt->value != NULL);
+ opt++)
{
- for(LV2_Options_Option *opt = opts;
- (opt->key != 0) && (opt->value != NULL);
- opt++)
+ if( (opt->key == param_sampleRate) && (opt->type == handle->forge.Float) )
+ {
+ handle->sample_rate = *(const float *)opt->value;
+ }
+ else if( (opt->key == ui_scaleFactor) && (opt->type == handle->forge.Float) )
{
- if( (opt->key == param_sampleRate) && (opt->type == handle->forge.Float) )
- handle->sample_rate = *(const float *)opt->value;
+ handle->scale = *(const float*)opt->value;
}
}
+
if(!handle->sample_rate)
+ {
handle->sample_rate = 48000.f; // fall-back
+ }
vm_api_init(handle->api, handle->map);
@@ -1210,6 +1234,12 @@ instantiate(const LV2UI_Descriptor *descriptor, const char *plugin_uri,
cfg->font.size = 13;
*(intptr_t *)widget = nk_pugl_init(&handle->win);
+
+ if(handle->scale == 0.f)
+ {
+ handle->scale = nk_pugl_get_scale(&handle->win);
+ }
+
nk_pugl_show(&handle->win);
char *icon_path;
diff --git a/vm_ui.ttl b/vm_ui.ttl
index f560cf0..c6cc8cc 100644
--- a/vm_ui.ttl
+++ b/vm_ui.ttl
@@ -20,6 +20,7 @@
@prefix log: <http://lv2plug.in/ns/ext/log#> .
@prefix opts: <http://lv2plug.in/ns/ext/options#> .
@prefix param: <http://lv2plug.in/ns/ext/parameters#> .
+@prefix opts: <http://lv2plug.in/ns/ext/options#> .
@prefix vm: <http://open-music-kontrollers.ch/lv2/vm#> .
@@ -44,7 +45,8 @@ vm:vm_ui
lv2:symbol "notify" ;
ui:protocol atom:eventTransfer
] ;
- lv2:requiredFeature ui:idleInterface, urid:map, urid:unmap ;
+ lv2:requiredFeature ui:idleInterface, urid:map, urid:unmap, opts:options ;
lv2:optionalFeature log:log, ui:resize, opts:options ;
+ opts:supportedOption ui:scaleFactor ;
lv2:extensionData ui:idleInterface, ui:resize ;
opts:supportedOption param:sampleRate .