shithub: microui

Download patch

ref: f5deb63c8db7b61b29d19ad2fc4128bb8d62f603
parent: 0b64933b08bbfa485c7142c97d33ff3d47f83342
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Jan 1 11:47:46 EST 2020

compile as C99

--- a/demo/build.sh
+++ b/demo/build.sh
@@ -1,3 +1,3 @@
 #!/usr/bin/env bash
 gcc common.c sdl2.c renderer_gl.c ../src/microui.c -I../src\
-    -Wall -Wextra -std=c11 -pedantic -lSDL2 -lGL -lm -O3 -g
+    -Wall -Wextra -std=c99 -pedantic -lSDL2 -lGL -lm -O3 -g
--- a/demo/common.c
+++ b/demo/common.c
@@ -37,7 +37,8 @@
     static int show_info = 0;
     if (mu_header(ctx, &show_info, "Window Info")) {
       char buf[64];
-      mu_layout_row(ctx, 2, (int[]) { 54, -1 }, 0);
+      const int widths[] = { 54, -1 };
+      mu_layout_row(ctx, 2, widths, 0);
       mu_label(ctx,"Position:");
       sprintf(buf, "%d, %d", window.rect.x, window.rect.y); mu_label(ctx, buf);
       mu_label(ctx, "Size:");
@@ -47,7 +48,8 @@
     /* labels + buttons */
     static int show_buttons = 1;
     if (mu_header(ctx, &show_buttons, "Test Buttons")) {
-      mu_layout_row(ctx, 3, (int[]) { 86, -110, -1 }, 0);
+      const int widths[] = { 86, -110, -1 };
+      mu_layout_row(ctx, 3, widths, 0);
       mu_label(ctx, "Test buttons 1:");
       if (mu_button(ctx, "Button 1")) { write_log("Pressed button 1"); }
       if (mu_button(ctx, "Button 2")) { write_log("Pressed button 2"); }
@@ -59,7 +61,8 @@
     /* tree */
     static int show_tree = 1;
     if (mu_header(ctx, &show_tree, "Tree and Text")) {
-      mu_layout_row(ctx, 2, (int[]) { 140, -1 }, 0);
+      int widths[] = { 140, -1 };
+      mu_layout_row(ctx, 2, widths, 0);
       mu_layout_begin_column(ctx);
       static int states[8];
       if (mu_begin_treenode(ctx, &states[0], "Test 1")) {
@@ -76,7 +79,8 @@
         mu_end_treenode(ctx);
       }
       if (mu_begin_treenode(ctx, &states[3], "Test 2")) {
-        mu_layout_row(ctx, 2, (int[]) { 54, 54 }, 0);
+        const int widths[] = { 54, 54 };
+        mu_layout_row(ctx, 2, widths, 0);
         if (mu_button(ctx, "Button 3")) { write_log("Pressed button 3"); }
         if (mu_button(ctx, "Button 4")) { write_log("Pressed button 4"); }
         if (mu_button(ctx, "Button 5")) { write_log("Pressed button 5"); }
@@ -93,7 +97,8 @@
       mu_layout_end_column(ctx);
 
       mu_layout_begin_column(ctx);
-      mu_layout_row(ctx, 1, (int[]) { -1 }, 0);
+      widths[0] = -1;
+      mu_layout_row(ctx, 1, widths, 0);
       mu_text(ctx, "Lorem ipsum dolor sit amet, consectetur adipiscing "
         "elit. Maecenas lacinia, sem eu lacinia molestie, mi risus faucibus "
         "ipsum, eu varius magna felis a nulla.");
@@ -103,10 +108,12 @@
     /* background color sliders */
     static int show_sliders = 1;
     if (mu_header(ctx, &show_sliders, "Background Color")) {
-      mu_layout_row(ctx, 2, (int[]) { -78, -1 }, 74);
+      int widths[] = { -78, -1 };
+      mu_layout_row(ctx, 2, widths, 74);
       /* sliders */
       mu_layout_begin_column(ctx);
-      mu_layout_row(ctx, 2, (int[]) { 46, -1 }, 0);
+      widths[0] = 46;
+      mu_layout_row(ctx, 2, widths, 0);
       mu_label(ctx, "Red:");   mu_slider(ctx, &bg[0], 0, 255);
       mu_label(ctx, "Green:"); mu_slider(ctx, &bg[1], 0, 255);
       mu_label(ctx, "Blue:");  mu_slider(ctx, &bg[2], 0, 255);
@@ -134,12 +141,13 @@
   }
 
   if (mu_begin_window(ctx, &window, "Log Window")) {
+    int widths[] = { -1, -1 };
 
     /* output text panel */
     static mu_Container panel;
-    mu_layout_row(ctx, 1, (int[]) { -1 }, -28);
+    mu_layout_row(ctx, 1, widths, -28);
     mu_begin_panel(ctx, &panel);
-    mu_layout_row(ctx, 1, (int[]) { -1 }, -1);
+    mu_layout_row(ctx, 1, widths, -1);
     mu_text(ctx, logbuf);
     mu_end_panel(ctx);
     if (logbuf_updated) {
@@ -150,7 +158,8 @@
     /* input textbox + submit button */
     static char buf[128];
     int submitted = 0;
-    mu_layout_row(ctx, 2, (int[]) { -70, -1 }, 0);
+    widths[0] = -70;
+    mu_layout_row(ctx, 2, widths, 0);
     if (mu_textbox(ctx, buf, sizeof(buf)) & MU_RES_SUBMIT) {
       mu_set_focus(ctx, ctx->last_id);
       submitted = 1;
@@ -206,7 +215,8 @@
 
   if (mu_begin_window(ctx, &window, "Style Editor")) {
     int sw = mu_get_container(ctx)->body.w * 0.14;
-    mu_layout_row(ctx, 6, (int[]) { 80, sw, sw, sw, sw, -1 }, 0);
+    const int widths[] = { 80, sw, sw, sw, sw, -1 };
+    mu_layout_row(ctx, 6, widths, 0);
     for (int i = 0; colors[i].label; i++) {
       mu_label(ctx, colors[i].label);
       uint8_slider(ctx, &ctx->style->colors[i].r, 0, 255);
--- a/src/microui.c
+++ b/src/microui.c
@@ -31,6 +31,7 @@
 #define stderr 2
 #else
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #define unused(x) ((void) (x))
 #endif
--- a/src/microui.h
+++ b/src/microui.h
@@ -8,8 +8,6 @@
 #ifndef MICROUI_H
 #define MICROUI_H
 
-#include <stdlib.h>
-
 #define MU_VERSION "1.02"
 
 #define MU_COMMANDLIST_SIZE     (1024 * 256)