aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2021-07-14 19:11:39 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2021-07-14 19:11:39 +0200
commit8acc1a8d4a83c0eaf873547c3b47c4915e9d6f8f (patch)
tree1190353b4e4451ac16992a1ada67b1b479610518
parent39bad8ff88a4c3980e00e9758e5d06775843d375 (diff)
downloadpatchmatrix-8acc1a8d4a83c0eaf873547c3b47c4915e9d6f8f.tar.xz
properly clip client node names.
-rw-r--r--VERSION2
-rw-r--r--patchmatrix_nk.c20
2 files changed, 16 insertions, 6 deletions
diff --git a/VERSION b/VERSION
index 0c17dbf..88ad9a3 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.25.13
+0.25.15
diff --git a/patchmatrix_nk.c b/patchmatrix_nk.c
index 54c4f25..65c9f97 100644
--- a/patchmatrix_nk.c
+++ b/patchmatrix_nk.c
@@ -723,6 +723,7 @@ node_editor_client(struct nk_context *ctx, app_t *app, client_t *client)
const enum nk_widget_layout_states states = nk_widget(&body, ctx);
if(states != NK_WIDGET_INVALID)
{
+ const struct nk_rect old_clip = canvas->clip;
struct nk_style_button *style = &ctx->style.button;
const struct nk_user_font *font = ctx->style.font;
@@ -740,18 +741,23 @@ node_editor_client(struct nk_context *ctx, app_t *app, client_t *client)
const float fh = font->height;
const float fy = body.y + (body.h - fh)/2;
+ const float dx = 4.f;
+ const float dw = 1.5*fh;
+ const float ww = body.w - 2*(dx + dw);
{
const char *client_name = client->pretty_name ? client->pretty_name : client->name;
const size_t client_name_len = strlen(client_name);
- const float fw = font->width(font->userdata, font->height, client_name, client_name_len);
+ const float fw = NK_MIN(font->width(font->userdata, font->height, client_name, client_name_len), ww);
const struct nk_rect body2 = {
.x = body.x + (body.w - fw)/2,
.y = fy,
.w = fw,
.h = fh
};
+ nk_push_scissor(canvas, body2);
nk_draw_text(canvas, body2, client_name, client_name_len, font,
style->normal.data.color, style->text_normal);
+ nk_push_scissor(canvas, old_clip);
}
const unsigned nsources = _client_num_sources(client, app->type);
@@ -760,35 +766,39 @@ node_editor_client(struct nk_context *ctx, app_t *app, client_t *client)
if(nsources)
{
char nums [32];
- snprintf(nums, 32, "%u", nsources);
+ snprintf(nums, 32, "%02u", nsources);
const size_t nums_len = strlen(nums);
const float fw = font->width(font->userdata, font->height, nums, nums_len);
const struct nk_rect body2 = {
- .x = body.x + body.w - fw - 4.f,
+ .x = body.x + body.w - fw - dx,
.y = fy,
.w = fw,
.h = fh
};
+ nk_push_scissor(canvas, body2);
nk_draw_text(canvas, body2, nums, nums_len, font,
style->normal.data.color, style->text_normal);
+ nk_push_scissor(canvas, old_clip);
}
if(nsinks)
{
char nums [32];
- snprintf(nums, 32, "%u", nsinks);
+ snprintf(nums, 32, "%02u", nsinks);
const size_t nums_len = strlen(nums);
const float fw = font->width(font->userdata, font->height, nums, nums_len);
const struct nk_rect body2 = {
- .x = body.x + 4.f,
+ .x = body.x + dx,
.y = fy,
.w = fw,
.h = fh
};
+ nk_push_scissor(canvas, body2);
nk_draw_text(canvas, body2, nums, nums_len, font,
style->normal.data.color, style->text_normal);
+ nk_push_scissor(canvas, old_clip);
}
}