Skip to content

Commit

Permalink
Fixed some bug introduced by last commit and more
Browse files Browse the repository at this point in the history
This commit fixed some bugs from the last commit as well as some general
changes and fixes of some old bugs. For overview of all changes please
look inside `CHANGELOG.md`.
  • Loading branch information
vurtun committed Aug 31, 2016
1 parent 82e3592 commit 550a2b0
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 204 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Changelog

- 2016/08/29 (1.11) - Removed some internal complexity and overly complex code
- 2016/08/30 (1.12) - Removed mouse dragging from SDL demo since it does not work correctly
- 2016/08/30 (1.12) - Tweaked some default styling variables
- 2016/08/30 (1.12) - Hopefully fixed drawing bug in slider, in general I would
refrain from using slider with a big number of steps.
- 2016/08/30 (1.12) - Fixed close and minimize button which would fire even if the
window was in Read Only Mode.
- 2016/08/30 (1.12) - Fixed popup panel padding handling which was previously just
a hack for combo box and menu.
- 2016/08/30 (1.12) - Removed `NK_WINDOW_DYNAMIC` flag from public API since
it is bugged and causes issues in window selection.
- 2016/08/30 (1.12) - Removed scaler size. The size of the scaler is now
determined by the scrollbar size
- 2016/08/30 (1.12) - Fixed some drawing bugs caused by changes from 1.11
- 2016/08/30 (1.12) - Fixed overlapping minimized window selection
- 2016/08/30 (1.11) - Removed some internal complexity and overly complex code
handling panel padding and panel border.
- 2016/08/29 (1.10) - Added additional height parameter to `nk_combobox_xxx`
- 2016/08/29 (1.10) - Fixed drawing bug in dynamic popups
Expand Down
23 changes: 9 additions & 14 deletions demo/overview.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ overview(struct nk_context *ctx)
static int no_scrollbar = nk_false;
static nk_flags window_flags = 0;
static int minimizable = nk_true;
static int close = nk_true;

/* popups */
static enum nk_style_header_align header_align = NK_HEADER_RIGHT;
Expand All @@ -28,9 +27,8 @@ overview(struct nk_context *ctx)
if (movable) window_flags |= NK_WINDOW_MOVABLE;
if (no_scrollbar) window_flags |= NK_WINDOW_NO_SCROLLBAR;
if (minimizable) window_flags |= NK_WINDOW_MINIMIZABLE;
if (close) window_flags |= NK_WINDOW_CLOSABLE;

if (nk_begin(ctx, &layout, "Overview", nk_rect(10, 10, 400, 750), window_flags))
if (nk_begin(ctx, &layout, "Overview", nk_rect(10, 10, 400, 600), window_flags))
{
if (show_menu)
{
Expand Down Expand Up @@ -90,7 +88,6 @@ overview(struct nk_context *ctx)
nk_checkbox_label(ctx, "Movable", &movable);
nk_checkbox_label(ctx, "No Scrollbar", &no_scrollbar);
nk_checkbox_label(ctx, "Minimizable", &minimizable);
nk_checkbox_label(ctx, "Closable", &close);
nk_tree_pop(ctx);
}

Expand Down Expand Up @@ -129,7 +126,7 @@ overview(struct nk_context *ctx)
nk_button_set_behavior(ctx, NK_BUTTON_DEFAULT);
nk_button_color(ctx, nk_rgb(0,0,255));

nk_layout_row_static(ctx, 20, 20, 8);
nk_layout_row_static(ctx, 25, 25, 8);
nk_button_symbol(ctx, NK_SYMBOL_CIRCLE);
nk_button_symbol(ctx, NK_SYMBOL_CIRCLE_FILLED);
nk_button_symbol(ctx, NK_SYMBOL_RECT);
Expand Down Expand Up @@ -697,8 +694,8 @@ overview(struct nk_context *ctx)

if (popup_active)
{
static struct nk_rect s = {20, 100, 220, 150};
if (nk_popup_begin(ctx, &menu, NK_POPUP_STATIC, "Error", NK_WINDOW_DYNAMIC, s))
static struct nk_rect s = {20, 100, 220, 90};
if (nk_popup_begin(ctx, &menu, NK_POPUP_STATIC, "Error", 0, s))
{
nk_layout_row_dynamic(ctx, 25, 1);
nk_label(ctx, "A terrible error as occured", NK_TEXT_LEFT);
Expand Down Expand Up @@ -851,10 +848,8 @@ overview(struct nk_context *ctx)
int i;

/* Header */
item_padding = ctx->style.window.spacing;
rounding = ctx->style.button.rounding;
ctx->style.window.spacing = nk_vec2(0,0);
ctx->style.button.rounding = 0;
nk_style_push_vec2(ctx, &ctx->style.window.spacing, nk_vec2(0,0));
nk_style_push_float(ctx, &ctx->style.button.rounding, 0);
nk_layout_row_begin(ctx, NK_STATIC, 20, 3);
for (i = 0; i < 3; ++i) {
/* make sure button perfectly fits text */
Expand All @@ -870,13 +865,13 @@ overview(struct nk_context *ctx)
ctx->style.button.normal = button_color;
} else current_tab = nk_button_label(ctx, names[i]) ? i: current_tab;
}
ctx->style.button.rounding = rounding;
nk_style_pop_float(ctx);

/* Body */
nk_layout_row_dynamic(ctx, 140, 1);
if (nk_group_begin(ctx, &group, "Notebook", NK_WINDOW_BORDER))
{
ctx->style.window.spacing = item_padding;
nk_style_pop_vec2(ctx);
switch (current_tab) {
case CHART_LINE:
nk_layout_row_dynamic(ctx, 100, 1);
Expand Down Expand Up @@ -919,7 +914,7 @@ overview(struct nk_context *ctx)
break;
}
nk_group_end(ctx);
} else ctx->style.window.spacing = item_padding;
} else nk_style_pop_vec2(ctx);
nk_tree_pop(ctx);
}

Expand Down
8 changes: 4 additions & 4 deletions example/extended.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ grid_demo(struct nk_context *ctx, struct media *media)
nk_style_set_font(ctx, &media->font_20->handle);
if (nk_begin(ctx, &layout, "Grid Demo", nk_rect(600, 350, 275, 250),
NK_WINDOW_TITLE|NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|
NK_WINDOW_BORDER_HEADER|NK_WINDOW_NO_SCROLLBAR))
NK_WINDOW_NO_SCROLLBAR))
{
nk_style_set_font(ctx, &media->font_18->handle);
nk_layout_row_dynamic(ctx, 30, 2);
Expand Down Expand Up @@ -263,7 +263,7 @@ button_demo(struct nk_context *ctx, struct media *media)

nk_style_set_font(ctx, &media->font_20->handle);
nk_begin(ctx, &layout, "Button Demo", nk_rect(50,50,255,610),
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_BORDER_HEADER|NK_WINDOW_TITLE);
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_TITLE);

/*------------------------------------------------
* MENU
Expand Down Expand Up @@ -382,7 +382,7 @@ basic_demo(struct nk_context *ctx, struct media *media)
struct nk_panel combo;
nk_style_set_font(ctx, &media->font_20->handle);
nk_begin(ctx, &layout, "Basic Demo", nk_rect(320, 50, 275, 610),
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_BORDER_HEADER|NK_WINDOW_TITLE);
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_TITLE);

/*------------------------------------------------
* POPUP BUTTON
Expand Down Expand Up @@ -870,7 +870,7 @@ int main(int argc, char *argv[])
/* Draw */
glViewport(0, 0, display_width, display_height);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
device_draw(&device, &ctx, width, height, scale, NK_ANTI_ALIASING_ON);
glfwSwapBuffers(win);
}
Expand Down
2 changes: 1 addition & 1 deletion example/skinning.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,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);
current_weapon = nk_combo(&ctx, weapons, LEN(weapons), current_weapon, 25, 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)) {
Expand Down
Loading

0 comments on commit 550a2b0

Please sign in to comment.