shithub: neindaw

Download patch

ref: 97b55a85c79a702579882a75a8ea47d5c1d00636
parent: abebab3746b86e330baed2e96b62f018da3a680c
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Jan 1 09:40:35 EST 2020

a few cfg ui fixes

--- a/cfg/cfg.c
+++ b/cfg/cfg.c
@@ -143,11 +143,13 @@
 		if (nk_begin_titled(&nk, "daw/cfg", "daw/cfg", nk_rect(0, 0, Dx(screen->r), Dy(screen->r)), 0)) {
 			static int d = 20;
 			nk_layout_row_template_begin(&nk, 0);
-			nk_layout_row_template_push_dynamic(&nk);
-			nk_layout_row_template_push_dynamic(&nk);
+			nk_layout_row_template_push_static(&nk, stringwidth(display->defaultfont, "Some kind of slider?"));
+			nk_layout_row_template_push_variable(&nk, 100);
+			nk_layout_row_template_push_static(&nk, stringwidth(display->defaultfont, "Button")*2);
 			nk_layout_row_template_end(&nk);
-			nk_label(&nk, "Some kind of slider:", NK_TEXT_LEFT);
+			nk_label(&nk, "Some kind of slider?", NK_TEXT_LEFT);
 			nk_slider_int(&nk, 0, &d, 100, 1);
+			nk_button_label(&nk, "Button");
 		}
 		nk_end(&nk);
 
--- a/cfg/nk.c
+++ b/cfg/nk.c
@@ -98,11 +98,11 @@
 	oldcmdslen = ctx->memory.allocated;
 	memmove(oldcmds, cmds, oldcmdslen);
 
-	rect.min = screen->r.min;
-	p = rect.min;
-	sp = p;
-
 	nk_foreach(cmd, ctx) {
+		rect.min = screen->r.min;
+		p = rect.min;
+		sp = p;
+
 		switch (cmd->type) {
 		case NK_COMMAND_NOP:
 			break;
@@ -158,8 +158,8 @@
 		case NK_COMMAND_CIRCLE:
 			{
 				const struct nk_command_circle *c = (void*)cmd;
-				p.x += c->x + c->w/4;
-				p.y += c->y - c->h/4;
+				p.x += c->x + c->w/2;
+				p.y += c->y + c->h/2;
 				ellipse(screen, p, c->w/2, c->h/2, THICK(c->line_thickness), nk_color_p9(c->color), ZP);
 			}
 			break;
@@ -166,8 +166,8 @@
 		case NK_COMMAND_CIRCLE_FILLED:
 			{
 				const struct nk_command_circle_filled *c = (void*)cmd;
-				p.x += c->x + c->w/4;
-				p.y += c->y - c->h/4;
+				p.x += c->x + c->w/2;
+				p.y += c->y + c->h/2;
 				fillellipse(screen, p, c->w/2, c->h/2, nk_color_p9(c->color), ZP);
 			}
 			break;
--- a/cfg/nuklear.h
+++ b/cfg/nuklear.h
@@ -17944,7 +17944,7 @@
                             layout->bounds.w, layout->row.columns);
         float var_width = (NK_MAX(space-min_fixed_width,0.0f)) / (float)variable_count;
         int enough_space = var_width >= max_variable_width;
-        if (!enough_space)
+        if (!enough_space && min_variable_count > 0)
             var_width = (NK_MAX(space-total_fixed_width,0)) / (float)min_variable_count;
         for (i = 0; i < layout->row.columns; ++i) {
             float *width = &layout->row.templates[i];