Browse Source

Merge remote-tracking branch 'upstream/master'

Yaroslav Tsarko 9 years ago
parent
commit
9b89489ffd

+ 26 - 1
CHANGELOG.md

@@ -1,5 +1,30 @@
 # Changelog
-
+- 2016/09/29 (1.157)- Fixed deduction of basic type in non `<stdint.h>` compilation
+- 2016/09/29 (1.156)- Fixed edit widget UTF-8 text cursor drawing bug
+- 2016/09/28 (1.156)- Fixed edit widget UTF-8 text appending/inserting/removing
+- 2016/09/28 (1.156)- Fixed drawing bug inside edit widgets which offset all text
+                        text in every edit widget if one of them is scrolled.
+- 2016/09/28 (1.155)- Fixed small bug in edit widgets if not active. The wrong
+                        text length is passed. It should have been in bytes but
+                        was passed as glyphes.
+- 2016/09/20 (1.154)- Fixed color button size calculation
+- 2016/09/20 (1.153)- Fixed some `nk_vsnprintf` behavior bugs and removed
+                        `<stdio.h>` again from `NK_INCLUDE_STANDARD_VARARGS`.
+- 2016/09/18 (1.152)- C89 does not support vsnprintf only C99 and newer as well
+                        as C++11 and newer. In addition to use vsnprintf you have
+                        to include <stdio.h>. So just defining `NK_INCLUDE_STD_VAR_ARGS`
+                        is not enough. That behavior is now fixed. By default if
+                        both varargs as well as stdio is selected I try to use
+                        vsnprintf if not possible I will revert to vsprintf. If
+                        varargs but not stdio was defined I will use my own function.
+- 2016/09/15 (1.151)- Fixed panel `close` behavior for deeper panel levels
+- 2016/09/15 (1.151)- Fixed C++ errors and wrong argument to `nk_panel_get_xxxx`
+- 2016/09/13 (1.15) - !BREAKING! Fixed nonblocking popup behavior in menu, combo,
+                        and contextual which prevented closing in y-direction if
+                        popup did not reach max height.
+                        In addition the height parameter was changed into vec2
+                        for width and height to have more control over the popup size.
+- 2016/09/13 (1.15) - Cleaned up and extended type selection
 - 2016/09/13 (1.141)- Fixed slider behavior hopefully for the last time. This time
                         all calculation are correct so no more hackery.
 - 2016/09/13 (1.141)- Internal change to divide window/panel flags into panel flags and types.

+ 10 - 9
Readme.md

@@ -59,19 +59,18 @@ float value = 0.6f;
 int i =  20;
 
 struct nk_panel layout;
-nk_begin(&ctx, &layout, "Show", nk_rect(50, 50, 220, 220),
-    NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE);
-{
+if (nk_begin(&ctx, &layout, "Show", nk_rect(50, 50, 220, 220),
+    NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
     /* fixed widget pixel width */
     nk_layout_row_static(&ctx, 30, 80, 1);
-    if (nk_button_text(&ctx, "button", NK_BUTTON_DEFAULT)) {
+    if (nk_button_label(&ctx, "button")) {
         /* event handling */
     }
 
     /* fixed widget window ratio width */
     nk_layout_row_dynamic(&ctx, 30, 2);
-    if (nk_option(&ctx, "easy", op == EASY)) op = EASY;
-    if (nk_option(&ctx, "hard", op == HARD)) op = HARD;
+    if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY;
+    if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD;
 
     /* custom widget pixel width */
     nk_layout_row_begin(&ctx, NK_STATIC, 30, 2);
@@ -83,18 +82,20 @@ nk_begin(&ctx, &layout, "Show", nk_rect(50, 50, 220, 220),
     }
     nk_layout_row_end(&ctx);
 }
-nk_end(ctx);
+nk_end(&ctx);
 ```
 ![example](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png)
 
 ## Bindings:
-Java: https://github.com/glegris/nuklear4j
+Java: https://github.com/glegris/nuklear4j  
+Golang: https://github.com/golang-ui/nuklear  
+Rust: https://github.com/snuk182/nuklear-rust
 
 ## Credits:
 Developed by Micha Mettke and every direct or indirect contributor to the GitHub.
 
 
-Embeds `stb_texedit`, `stb_truetype` and `stb_rectpack` by Sean Barret (public domain)
+Embeds `stb_texedit`, `stb_truetype` and `stb_rectpack` by Sean Barret (public domain)  
 Embeds `ProggyClean.ttf` font by Tristan Grimmer (MIT license).
 
 

+ 1 - 1
demo/d3d11/main.c

@@ -231,7 +231,7 @@ int main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, &combo, background, 400)) {
+            if (nk_combo_begin_color(ctx, &combo, background, nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 background = nk_color_picker(ctx, background, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);

+ 1 - 1
demo/glfw_opengl2/main.c

@@ -127,7 +127,7 @@ int main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, &combo, background, 400)) {
+            if (nk_combo_begin_color(ctx, &combo, background, nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 background = nk_color_picker(ctx, background, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);

+ 1 - 1
demo/glfw_opengl3/main.c

@@ -141,7 +141,7 @@ int main(void)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, &combo, background, 400)) {
+            if (nk_combo_begin_color(ctx, &combo, background, nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 background = nk_color_picker(ctx, background, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);

+ 10 - 11
demo/overview.c

@@ -41,7 +41,7 @@ overview(struct nk_context *ctx)
             nk_menubar_begin(ctx);
             nk_layout_row_begin(ctx, NK_STATIC, 25, 2);
             nk_layout_row_push(ctx, 45);
-            if (nk_menu_begin_label(ctx, &menu, "MENU", NK_TEXT_LEFT, 120))
+            if (nk_menu_begin_label(ctx, &menu, "MENU", NK_TEXT_LEFT, nk_vec2(120, 200)))
             {
                 static size_t prog = 40;
                 static int slider = 10;
@@ -276,10 +276,10 @@ overview(struct nk_context *ctx)
 
                 /* default combobox */
                 nk_layout_row_static(ctx, 25, 200, 1);
-                current_weapon = nk_combo(ctx, weapons, LEN(weapons), current_weapon, 25, 200);
+                current_weapon = nk_combo(ctx, weapons, LEN(weapons), current_weapon, 25, nk_vec2(200,200));
 
                 /* slider color combobox */
-                if (nk_combo_begin_color(ctx, &combo, combo_color, 200)) {
+                if (nk_combo_begin_color(ctx, &combo, combo_color, nk_vec2(200,200))) {
                     float ratios[] = {0.15f, 0.85f};
                     nk_layout_row(ctx, NK_DYNAMIC, 30, 2, ratios);
                     nk_label(ctx, "R:", NK_TEXT_LEFT);
@@ -294,7 +294,7 @@ overview(struct nk_context *ctx)
                 }
 
                 /* complex color combobox */
-                if (nk_combo_begin_color(ctx, &combo, combo_color2, 400)) {
+                if (nk_combo_begin_color(ctx, &combo, combo_color2, nk_vec2(200,400))) {
                     enum color_mode {COL_RGB, COL_HSV};
                     static int col_mode = COL_RGB;
                     #ifndef DEMO_DO_NOT_USE_COLOR_PICKER
@@ -327,7 +327,7 @@ overview(struct nk_context *ctx)
                 /* progressbar combobox */
                 sum = prog_a + prog_b + prog_c + prog_d;
                 sprintf(buffer, "%lu", sum);
-                if (nk_combo_begin_label(ctx, &combo, buffer, 200)) {
+                if (nk_combo_begin_label(ctx, &combo, buffer, nk_vec2(200,200))) {
                     nk_layout_row_dynamic(ctx, 30, 1);
                     nk_progress(ctx, &prog_a, 100, NK_MODIFIABLE);
                     nk_progress(ctx, &prog_b, 100, NK_MODIFIABLE);
@@ -339,7 +339,7 @@ overview(struct nk_context *ctx)
                 /* checkbox combobox */
                 sum = (size_t)(check_values[0] + check_values[1] + check_values[2] + check_values[3] + check_values[4]);
                 sprintf(buffer, "%lu", sum);
-                if (nk_combo_begin_label(ctx, &combo, buffer, 200)) {
+                if (nk_combo_begin_label(ctx, &combo, buffer, nk_vec2(200,200))) {
                     nk_layout_row_dynamic(ctx, 30, 1);
                     nk_checkbox_label(ctx, weapons[0], &check_values[0]);
                     nk_checkbox_label(ctx, weapons[1], &check_values[1]);
@@ -350,7 +350,7 @@ overview(struct nk_context *ctx)
 
                 /* complex text combobox */
                 sprintf(buffer, "%.2f, %.2f, %.2f", position[0], position[1],position[2]);
-                if (nk_combo_begin_label(ctx, &combo, buffer, 200)) {
+                if (nk_combo_begin_label(ctx, &combo, buffer, nk_vec2(200,200))) {
                     nk_layout_row_dynamic(ctx, 25, 1);
                     nk_property_float(ctx, "#X:", -1024.0f, &position[0], 1024.0f, 1,0.5f);
                     nk_property_float(ctx, "#Y:", -1024.0f, &position[1], 1024.0f, 1,0.5f);
@@ -360,7 +360,7 @@ overview(struct nk_context *ctx)
 
                 /* chart combobox */
                 sprintf(buffer, "%.1f", chart_selection);
-                if (nk_combo_begin_label(ctx, &combo, buffer, 250)) {
+                if (nk_combo_begin_label(ctx, &combo, buffer, nk_vec2(200,250))) {
                     size_t i = 0;
                     static const float values[]={26.0f,13.0f,30.0f,15.0f,25.0f,10.0f,20.0f,40.0f, 12.0f, 8.0f, 22.0f, 28.0f, 5.0f};
                     nk_layout_row_dynamic(ctx, 150, 1);
@@ -393,7 +393,7 @@ overview(struct nk_context *ctx)
 
                     /* time combobox */
                     sprintf(buffer, "%02d:%02d:%02d", sel_time.tm_hour, sel_time.tm_min, sel_time.tm_sec);
-                    if (nk_combo_begin_label(ctx, &combo, buffer, 250)) {
+                    if (nk_combo_begin_label(ctx, &combo, buffer, nk_vec2(200,250))) {
                         time_selected = 1;
                         nk_layout_row_dynamic(ctx, 25, 1);
                         sel_time.tm_sec = nk_propertyi(ctx, "#S:", 0, sel_time.tm_sec, 60, 1, 1);
@@ -403,9 +403,8 @@ overview(struct nk_context *ctx)
                     }
 
                     /* date combobox */
-                    nk_layout_row_static(ctx, 25, 350, 1);
                     sprintf(buffer, "%02d-%02d-%02d", sel_date.tm_mday, sel_date.tm_mon+1, sel_date.tm_year+1900);
-                    if (nk_combo_begin_label(ctx, &combo, buffer, 400))
+                    if (nk_combo_begin_label(ctx, &combo, buffer, nk_vec2(350,400)))
                     {
                         int i = 0;
                         const char *month[] = {"January", "February", "March", "Apil", "May", "June", "July", "August", "September", "Ocotober", "November", "December"};

+ 1 - 1
demo/sdl_opengl2/main.c

@@ -138,7 +138,7 @@ main(int argc, char* argv[])
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, &combo, background, 400)) {
+            if (nk_combo_begin_color(ctx, &combo, background, nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 background = nk_color_picker(ctx, background, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);

+ 1 - 1
demo/sdl_opengl3/main.c

@@ -146,7 +146,7 @@ main(int argc, char* argv[])
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, &combo, background, 400)) {
+            if (nk_combo_begin_color(ctx, &combo, background, nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 background = nk_color_picker(ctx, background, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);

+ 1 - 1
demo/x11_opengl2/main.c

@@ -274,7 +274,7 @@ int main(int argc, char **argv)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, &combo, background, 400)) {
+            if (nk_combo_begin_color(ctx, &combo, background, nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 background = nk_color_picker(ctx, background, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);

+ 1 - 1
demo/x11_opengl3/main.c

@@ -271,7 +271,7 @@ int main(int argc, char **argv)
             nk_layout_row_dynamic(ctx, 20, 1);
             nk_label(ctx, "background:", NK_TEXT_LEFT);
             nk_layout_row_dynamic(ctx, 25, 1);
-            if (nk_combo_begin_color(ctx, &combo, background, 400)) {
+            if (nk_combo_begin_color(ctx, &combo, background, nk_vec2(nk_widget_width(ctx),400))) {
                 nk_layout_row_dynamic(ctx, 120, 1);
                 background = nk_color_picker(ctx, background, NK_RGBA);
                 nk_layout_row_dynamic(ctx, 25, 1);

+ 4 - 5
example/extended.c

@@ -207,8 +207,7 @@ grid_demo(struct nk_context *ctx, struct media *media)
         nk_label(ctx, "Checkbox:", NK_TEXT_RIGHT);
         nk_checkbox_label(ctx, "Check me", &check);
         nk_label(ctx, "Combobox:", NK_TEXT_RIGHT);
-
-        if (nk_combo_begin_label(ctx, &combo, items[selected_item], 200)) {
+        if (nk_combo_begin_label(ctx, &combo, items[selected_item], nk_vec2(nk_widget_width(ctx), 200))) {
             nk_layout_row_dynamic(ctx, 25, 1);
             for (i = 0; i < 3; ++i)
                 if (nk_combo_item_label(ctx, items[i], NK_TEXT_LEFT))
@@ -272,7 +271,7 @@ button_demo(struct nk_context *ctx, struct media *media)
     {
         /* toolbar */
         nk_layout_row_static(ctx, 40, 40, 4);
-        if (nk_menu_begin_image(ctx, &menu, "Music", media->play, 120))
+        if (nk_menu_begin_image(ctx, &menu, "Music", media->play, nk_vec2(110,120)))
         {
             /* settings */
             nk_layout_row_dynamic(ctx, 25, 1);
@@ -421,7 +420,7 @@ basic_demo(struct nk_context *ctx, struct media *media)
      *------------------------------------------------*/
     ui_header(ctx, media, "Combo box");
     ui_widget(ctx, media, 40);
-    if (nk_combo_begin_label(ctx, &combo, items[selected_item], 200)) {
+    if (nk_combo_begin_label(ctx, &combo, items[selected_item], nk_vec2(nk_widget_width(ctx), 200))) {
         nk_layout_row_dynamic(ctx, 35, 1);
         for (i = 0; i < 3; ++i)
             if (nk_combo_item_label(ctx, items[i], NK_TEXT_LEFT))
@@ -430,7 +429,7 @@ basic_demo(struct nk_context *ctx, struct media *media)
     }
 
     ui_widget(ctx, media, 40);
-    if (nk_combo_begin_image_label(ctx, &combo, items[selected_icon], media->images[selected_icon], 200)) {
+    if (nk_combo_begin_image_label(ctx, &combo, items[selected_icon], media->images[selected_icon], nk_vec2(nk_widget_width(ctx), 200))) {
         nk_layout_row_dynamic(ctx, 35, 1);
         for (i = 0; i < 3; ++i)
             if (nk_combo_item_image_label(ctx, media->images[i], items[i], NK_TEXT_RIGHT))

+ 1 - 1
example/skinning.c

@@ -769,7 +769,7 @@ int main(int argc, char *argv[])
             nk_layout_row_dynamic(&ctx, 25, 1);
             nk_edit_string(&ctx, NK_EDIT_FIELD, field_buffer, &field_len, 64, nk_filter_default);
             nk_property_float(&ctx, "#X:", -1024.0f, &pos, 1024.0f, 1, 1);
-            current_weapon = nk_combo(&ctx, weapons, LEN(weapons), current_weapon, 25, 200);
+            current_weapon = nk_combo(&ctx, weapons, LEN(weapons), current_weapon, 25, nk_vec2(nk_widget_width(&ctx),200));
 
             nk_layout_row_dynamic(&ctx, 100, 1);
             if (nk_chart_begin_colored(&ctx, NK_CHART_LINES, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) {

File diff suppressed because it is too large
+ 594 - 176
nuklear.h


Some files were not shown because too many files changed in this diff