aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2021-04-14 09:37:19 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2021-04-14 09:37:19 +0200
commitaf686ba542c717494eebc0509e228e05f96c1b33 (patch)
tree901353259b96b29fe46bf8959f3fe31b5d0fd67a
parent98e4595c1b0a6697f8ce287052e9b30b871cafaf (diff)
downloadnuk.lv2-af686ba542c717494eebc0509e228e05f96c1b33.tar.xz
nk: use new scale API.
-rw-r--r--VERSION2
-rw-r--r--nuk.h1
-rw-r--r--nuk_ui.c45
-rw-r--r--nuk_ui.ttl3
4 files changed, 43 insertions, 8 deletions
diff --git a/VERSION b/VERSION
index e19092c..b42347d 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.3009
+0.1.3015
diff --git a/nuk.h b/nuk.h
index f2c31d5..9dced4a 100644
--- a/nuk.h
+++ b/nuk.h
@@ -23,6 +23,7 @@
#include "lv2/lv2plug.in/ns/ext/log/log.h"
#include "lv2/lv2plug.in/ns/ext/log/logger.h"
#include "lv2/lv2plug.in/ns/ext/patch/patch.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
diff --git a/nuk_ui.c b/nuk_ui.c
index 0adb0f3..00cff2f 100644
--- a/nuk_ui.c
+++ b/nuk_ui.c
@@ -45,6 +45,8 @@ struct _plughandle_t {
LV2_Log_Log *log;
LV2_Log_Logger logger;
+ float scale;
+
nk_pugl_window_t win;
struct {
struct nk_image audio;
@@ -217,7 +219,7 @@ _expose(struct nk_context *ctx, struct nk_rect wbounds, void *data)
#ifdef SHOW_OVERVIEW
overview(ctx);
#else
- const float widget_h = 20 * nk_pugl_get_scale(&handle->win);
+ const float widget_h = 20 * handle->scale;
const char *window_name = "Nuk";
if(nk_begin(ctx, window_name, wbounds, NK_WINDOW_CLOSABLE | NK_WINDOW_NO_SCROLLBAR))
@@ -500,16 +502,29 @@ instantiate(const LV2UI_Descriptor *descriptor,
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_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_LOG__log))
+ {
handle->log = features[i]->data;
+ }
+ else if(!strcmp(features[i]->URI, LV2_OPTIONS__options))
+ {
+ opts = features[i]->data;
+ }
}
if(!parent)
@@ -535,13 +550,31 @@ instantiate(const LV2UI_Descriptor *descriptor,
handle->controller = controller;
handle->writer = write_function;
+ 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();
+ }
+
nk_pugl_config_t *cfg = &handle->win.cfg;
#ifdef SHOW_OVERVIEW
- cfg->width = 800;
- cfg->height = 800;
+ cfg->width = 800 * handle->scale;
+ cfg->height = 800 * handle->;
#else
- cfg->width = 1440;
- cfg->height = 720;
+ cfg->width = 1440 * handle->scale;
+ cfg->height = 720 * handle->scale;
#endif
cfg->resizable = true;
cfg->ignore = false;
@@ -554,7 +587,7 @@ instantiate(const LV2UI_Descriptor *descriptor,
if(asprintf(&cfg->font.face, "%sCousine-Regular.ttf", bundle_path) == -1)
cfg->font.face = NULL;
- cfg->font.size = 16;
+ cfg->font.size = 16 * handle->scale;
*(intptr_t *)widget = nk_pugl_init(&handle->win);
nk_pugl_show(&handle->win);
diff --git a/nuk_ui.ttl b/nuk_ui.ttl
index b0945cf..f21b43d 100644
--- a/nuk_ui.ttl
+++ b/nuk_ui.ttl
@@ -27,6 +27,7 @@ nuk:nuk_ui
lv2:symbol "notify" ;
ui:protocol atom:eventTransfer
] ;
- lv2:requiredFeature ui:idleInterface, urid:map, ui:parent ;
+ lv2:requiredFeature ui:idleInterface, urid:map, opts:options, ui:parent ;
lv2:optionalFeature log:log, ui:resize ;
+ opts:supportedOption ui:scaleFactor ;
lv2:extensionData ui:idleInterface, ui:resize .