diff options
author | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2021-01-06 00:05:30 +0100 |
---|---|---|
committer | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2021-01-06 00:05:30 +0100 |
commit | 6eb496b11fad341db967f0e600cd3fed8f934e18 (patch) | |
tree | 8b303c997dde089673369bf0af592a3089963a2d | |
parent | 31b61079898a916dd19b4e08d3ed6d1cf65775b9 (diff) | |
download | vm.lv2-6eb496b11fad341db967f0e600cd3fed8f934e18.tar.xz |
ui: add support for ui:scaleFactor.
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | vm_ui.c | 46 | ||||
-rw-r--r-- | vm_ui.ttl | 4 |
3 files changed, 42 insertions, 10 deletions
@@ -1 +1 @@ -0.11.23 +0.11.45 @@ -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; @@ -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 . |