From cc57b775657649b207c6451d8333aeb1e58486ca Mon Sep 17 00:00:00 2001 From: Joseph Werle Date: Sat, 18 Jun 2016 13:46:55 -0400 Subject: [PATCH 1/6] make clib friendly --- package.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..edff924 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "nuklear", + "version": "1.0.0", + "repo": "vurtun/nuklear", + "description": "A small ANSI C gui toolkit", + "keywords": ["gl", "ui", "toolkit"], + "src": ["nuklear.h"] +} From 76ba0b23748dd80301cc2c25f44d19b72086d0ef Mon Sep 17 00:00:00 2001 From: vurtun Date: Mon, 20 Jun 2016 20:01:24 +0200 Subject: [PATCH 2/6] Fixed alignment bug after buffer reallocation Previously if a dynamic back buffer is full and reallocated then the current allocation alignment will be alignet at the direct memory address instead of memory address minus size. This is now fixed and alignment should work correctly. --- nuklear.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuklear.h b/nuklear.h index 93badc4..b1a2d67 100644 --- a/nuklear.h +++ b/nuklear.h @@ -4384,7 +4384,7 @@ nk_buffer_alloc(struct nk_buffer *b, enum nk_buffer_allocation_type type, /* align newly allocated pointer */ if (type == NK_BUFFER_FRONT) unaligned = nk_ptr_add(void, b->memory.ptr, b->allocated); - else unaligned = nk_ptr_add(void, b->memory.ptr, b->size); + else unaligned = nk_ptr_add(void, b->memory.ptr, b->size - size); memory = nk_buffer_align(unaligned, align, &alignment, type); } From 1b4ea1195458876e9f62fea5c36966537009ecdd Mon Sep 17 00:00:00 2001 From: mogud Date: Thu, 23 Jun 2016 14:12:11 +0800 Subject: [PATCH 3/6] fix macro nk_tree_image_push_id: params error --- nuklear.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nuklear.h b/nuklear.h index b1a2d67..fbf2ad6 100644 --- a/nuklear.h +++ b/nuklear.h @@ -591,7 +591,7 @@ NK_API void nk_group_end(struct nk_context*); #define nk_tree_push_id(ctx, type, title, state, id) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id) NK_API int nk_tree_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed); #define nk_tree_image_push(ctx, type, img, title, state) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__) -#define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, img, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id) +#define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id) NK_API int nk_tree_image_push_hashed(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed); NK_API void nk_tree_pop(struct nk_context*); From af451ebee299948065fdd3e468212b3a830af9d7 Mon Sep 17 00:00:00 2001 From: Anthony Pesch Date: Thu, 23 Jun 2016 22:49:10 -0700 Subject: [PATCH 4/6] Make panels use the max of the scaler size or scrollbar y size when calculating their height Make horizontal scrollbars use the scrollbar y size when calculating their position --- nuklear.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/nuklear.h b/nuklear.h index b1a2d67..7a1b188 100644 --- a/nuklear.h +++ b/nuklear.h @@ -15633,10 +15633,16 @@ nk_panel_begin(struct nk_context *ctx, const char *title) } /* calculate window footer height */ - if (!(win->flags & NK_WINDOW_NONBLOCK) && - (!(win->flags & NK_WINDOW_NO_SCROLLBAR) || (win->flags & NK_WINDOW_SCALABLE))) - layout->footer_h = scaler_size.y + style->window.footer_padding.y; - else layout->footer_h = 0; + layout->footer_h = 0; + + if (!(win->flags & NK_WINDOW_NONBLOCK)) { + if (!(win->flags & NK_WINDOW_NO_SCROLLBAR)) { + layout->footer_h = scrollbar_size.y + style->window.footer_padding.y; + } + if (win->flags & NK_WINDOW_SCALABLE) { + layout->footer_h = NK_MAX(layout->footer_h, scaler_size.y + style->window.footer_padding.y); + } + } /* calculate the window size */ if (!(win->flags & NK_WINDOW_NO_SCROLLBAR)) @@ -15968,19 +15974,19 @@ nk_panel_end(struct nk_context *ctx) nk_flags state = 0; bounds.x = layout->bounds.x + window_padding.x; if (layout->flags & NK_WINDOW_SUB) { - bounds.h = scrollbar_size.x; + bounds.h = scrollbar_size.y; bounds.y = (layout->flags & NK_WINDOW_BORDER) ? layout->bounds.y + layout->border : layout->bounds.y; bounds.y += layout->header_h + layout->menu.h + layout->height; bounds.w = layout->width; } else if (layout->flags & NK_WINDOW_DYNAMIC) { - bounds.h = NK_MIN(scrollbar_size.x, layout->footer_h); + bounds.h = NK_MIN(scrollbar_size.y, layout->footer_h); bounds.w = layout->bounds.w; bounds.y = footer.y; } else { - bounds.h = NK_MIN(scrollbar_size.x, layout->footer_h); + bounds.h = NK_MIN(scrollbar_size.y, layout->footer_h); bounds.y = layout->bounds.y + window->bounds.h; - bounds.y -= NK_MAX(layout->footer_h, scrollbar_size.x); + bounds.y -= NK_MAX(layout->footer_h, scrollbar_size.y); bounds.w = layout->width - 2 * window_padding.x; } scroll_offset = layout->offset->x; From 4d390a9c463b956189f0e2c9cbad563bc5cac90d Mon Sep 17 00:00:00 2001 From: vurtun Date: Sat, 25 Jun 2016 10:38:34 +0200 Subject: [PATCH 5/6] Fixed some code style issues Enforced the correct code style and tab index width of 4 instead of 2. --- nuklear.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/nuklear.h b/nuklear.h index 8920e83..1c37572 100644 --- a/nuklear.h +++ b/nuklear.h @@ -15634,14 +15634,11 @@ nk_panel_begin(struct nk_context *ctx, const char *title) /* calculate window footer height */ layout->footer_h = 0; - if (!(win->flags & NK_WINDOW_NONBLOCK)) { - if (!(win->flags & NK_WINDOW_NO_SCROLLBAR)) { - layout->footer_h = scrollbar_size.y + style->window.footer_padding.y; - } - if (win->flags & NK_WINDOW_SCALABLE) { - layout->footer_h = NK_MAX(layout->footer_h, scaler_size.y + style->window.footer_padding.y); - } + if (!(win->flags & NK_WINDOW_NO_SCROLLBAR)) + layout->footer_h = scrollbar_size.y + style->window.footer_padding.y; + if (win->flags & NK_WINDOW_SCALABLE) + layout->footer_h = NK_MAX(layout->footer_h, scaler_size.y + style->window.footer_padding.y); } /* calculate the window size */ @@ -15743,13 +15740,13 @@ nk_panel_begin(struct nk_context *ctx, const char *title) int text_len = nk_strlen(title); struct nk_rect label = {0,0,0,0}; float t = font->width(font->userdata, font->height, title, text_len); + text.padding = nk_vec2(0,0); label.x = header.x + style->window.header.padding.x; label.x += style->window.header.label_padding.x; label.y = header.y + style->window.header.label_padding.y; label.h = font->height + 2 * style->window.header.label_padding.y; label.w = t + 2 * style->window.header.spacing.x; - text.padding = nk_vec2(0,0); nk_widget_text(out, label,(const char*)title, text_len, &text, NK_TEXT_LEFT, font); } From 605d59bf8ee672b12e6c36990b27202b61811efb Mon Sep 17 00:00:00 2001 From: vurtun Date: Wed, 29 Jun 2016 06:54:29 +0200 Subject: [PATCH 6/6] Fixed #173 draw list clearing bug --- nuklear.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nuklear.h b/nuklear.h index 1c37572..d9877c4 100644 --- a/nuklear.h +++ b/nuklear.h @@ -5525,9 +5525,9 @@ nk_draw_list_clear(struct nk_draw_list *list) if (!list) return; if (list->buffer) nk_buffer_clear(list->buffer); - if (list->elements) - nk_buffer_clear(list->vertices); if (list->vertices) + nk_buffer_clear(list->vertices); + if (list->elements) nk_buffer_clear(list->elements); list->element_count = 0;