Compare commits

...

2 Commits

Author SHA1 Message Date
Jacob Ahnstedt
0a7b4eec8e Fixed missed removed alignment params 2023-11-28 09:58:43 +01:00
Jacob Ahnstedt
9af3869728 Made the PR not break current API 2023-11-28 09:52:30 +01:00
31 changed files with 358 additions and 158 deletions

View File

@ -1,6 +1,6 @@
{
"name": "nuklear",
"version": "5.0.0",
"version": "4.12.0",
"repo": "Immediate-Mode-UI/Nuklear",
"description": "A small ANSI C gui toolkit",
"keywords": ["gl", "ui", "toolkit"],

View File

@ -165,8 +165,8 @@ int main(void)
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 22, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);
}

View File

@ -43,7 +43,7 @@ overview(struct nk_context *ctx)
show_app_about = nk_true;
nk_progress(ctx, &prog, 100, NK_MODIFIABLE);
nk_slider_int(ctx, 0, &slider, 16, 1);
nk_checkbox_label(ctx, "check", &check, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "check", &check);
nk_menu_end(ctx);
}
/* menu #2 */
@ -102,7 +102,7 @@ overview(struct nk_context *ctx)
nk_layout_row_push(ctx, 70);
nk_progress(ctx, &mprog, 100, NK_MODIFIABLE);
nk_slider_int(ctx, 0, &mslider, 16, 1);
nk_checkbox_label(ctx, "check", &mcheck, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "check", &mcheck);
nk_menubar_end(ctx);
}
@ -123,15 +123,15 @@ overview(struct nk_context *ctx)
/* window flags */
if (nk_tree_push(ctx, NK_TREE_TAB, "Window", NK_MINIMIZED)) {
nk_layout_row_dynamic(ctx, 30, 2);
nk_checkbox_label(ctx, "Menu", &show_menu, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_flags_label(ctx, "Titlebar", &window_flags, NK_WINDOW_TITLE, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_flags_label(ctx, "Border", &window_flags, NK_WINDOW_BORDER, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_flags_label(ctx, "Resizable", &window_flags, NK_WINDOW_SCALABLE, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_flags_label(ctx, "Movable", &window_flags, NK_WINDOW_MOVABLE, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_flags_label(ctx, "No Scrollbar", &window_flags, NK_WINDOW_NO_SCROLLBAR, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_flags_label(ctx, "Minimizable", &window_flags, NK_WINDOW_MINIMIZABLE, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_flags_label(ctx, "Scale Left", &window_flags, NK_WINDOW_SCALE_LEFT, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "Disable widgets", &disable_widgets, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "Menu", &show_menu);
nk_checkbox_flags_label(ctx, "Titlebar", &window_flags, NK_WINDOW_TITLE);
nk_checkbox_flags_label(ctx, "Border", &window_flags, NK_WINDOW_BORDER);
nk_checkbox_flags_label(ctx, "Resizable", &window_flags, NK_WINDOW_SCALABLE);
nk_checkbox_flags_label(ctx, "Movable", &window_flags, NK_WINDOW_MOVABLE);
nk_checkbox_flags_label(ctx, "No Scrollbar", &window_flags, NK_WINDOW_NO_SCROLLBAR);
nk_checkbox_flags_label(ctx, "Minimizable", &window_flags, NK_WINDOW_MINIMIZABLE);
nk_checkbox_flags_label(ctx, "Scale Left", &window_flags, NK_WINDOW_SCALE_LEFT);
nk_checkbox_label(ctx, "Disable widgets", &disable_widgets);
nk_tree_pop(ctx);
}
@ -213,20 +213,20 @@ overview(struct nk_context *ctx)
static const float ratio[] = {120, 150};
nk_layout_row_dynamic(ctx, 0, 1);
nk_checkbox_label(ctx, "CheckLeft TextLeft", &checkbox_left_text_left, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "CheckCenter TextRight", &checkbox_centered_text_right, NK_WIDGET_ALIGN_CENTERED | NK_WIDGET_ALIGN_MIDDLE, NK_TEXT_RIGHT);
nk_checkbox_label(ctx, "CheckRight TextRight", &checkbox_right_text_right, NK_WIDGET_LEFT, NK_TEXT_RIGHT);
nk_checkbox_label(ctx, "CheckRight TextLeft", &checkbox_right_text_left, NK_WIDGET_RIGHT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "CheckLeft TextLeft", &checkbox_left_text_left);
nk_checkbox_label_align(ctx, "CheckCenter TextRight", &checkbox_centered_text_right, NK_WIDGET_ALIGN_CENTERED | NK_WIDGET_ALIGN_MIDDLE, NK_TEXT_RIGHT);
nk_checkbox_label_align(ctx, "CheckRight TextRight", &checkbox_right_text_right, NK_WIDGET_LEFT, NK_TEXT_RIGHT);
nk_checkbox_label_align(ctx, "CheckRight TextLeft", &checkbox_right_text_left, NK_WIDGET_RIGHT, NK_TEXT_LEFT);
nk_layout_row_static(ctx, 30, 80, 3);
option_left = nk_option_label(ctx, "optionA", option_left == A, NK_WIDGET_LEFT, NK_TEXT_LEFT) ? A : option_left;
option_left = nk_option_label(ctx, "optionB", option_left == B, NK_WIDGET_LEFT, NK_TEXT_LEFT) ? B : option_left;
option_left = nk_option_label(ctx, "optionC", option_left == C, NK_WIDGET_LEFT, NK_TEXT_LEFT) ? C : option_left;
option_left = nk_option_label(ctx, "optionA", option_left == A) ? A : option_left;
option_left = nk_option_label(ctx, "optionB", option_left == B) ? B : option_left;
option_left = nk_option_label(ctx, "optionC", option_left == C) ? C : option_left;
nk_layout_row_static(ctx, 30, 80, 3);
option_right = nk_option_label(ctx, "optionA", option_right == A, NK_WIDGET_RIGHT, NK_TEXT_RIGHT) ? A : option_right;
option_right = nk_option_label(ctx, "optionB", option_right == B, NK_WIDGET_RIGHT, NK_TEXT_RIGHT) ? B : option_right;
option_right = nk_option_label(ctx, "optionC", option_right == C, NK_WIDGET_RIGHT, NK_TEXT_RIGHT) ? C : option_right;
option_right = nk_option_label_align(ctx, "optionA", option_right == A, NK_WIDGET_RIGHT, NK_TEXT_RIGHT) ? A : option_right;
option_right = nk_option_label_align(ctx, "optionB", option_right == B, NK_WIDGET_RIGHT, NK_TEXT_RIGHT) ? B : option_right;
option_right = nk_option_label_align(ctx, "optionC", option_right == C, NK_WIDGET_RIGHT, NK_TEXT_RIGHT) ? C : option_right;
nk_layout_row(ctx, NK_STATIC, 30, 2, ratio);
nk_labelf(ctx, NK_TEXT_LEFT, "Slider int");
@ -263,7 +263,7 @@ overview(struct nk_context *ctx)
{
static int inactive = 1;
nk_layout_row_dynamic(ctx, 30, 1);
nk_checkbox_label(ctx, "Inactive", &inactive, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "Inactive", &inactive);
nk_layout_row_static(ctx, 30, 80, 1);
if (inactive) {
@ -379,8 +379,8 @@ overview(struct nk_context *ctx)
#endif
nk_layout_row_dynamic(ctx, 25, 2);
col_mode = nk_option_label(ctx, "RGB", col_mode == COL_RGB, NK_WIDGET_LEFT, NK_TEXT_LEFT) ? COL_RGB : col_mode;
col_mode = nk_option_label(ctx, "HSV", col_mode == COL_HSV, NK_WIDGET_LEFT, NK_TEXT_LEFT) ? COL_HSV : col_mode;
col_mode = nk_option_label(ctx, "RGB", col_mode == COL_RGB) ? COL_RGB : col_mode;
col_mode = nk_option_label(ctx, "HSV", col_mode == COL_HSV) ? COL_HSV : col_mode;
nk_layout_row_dynamic(ctx, 25, 1);
if (col_mode == COL_RGB) {
@ -416,10 +416,10 @@ overview(struct nk_context *ctx)
sprintf(buffer, "%lu", sum);
if (nk_combo_begin_label(ctx, buffer, nk_vec2(200,200))) {
nk_layout_row_dynamic(ctx, 30, 1);
nk_checkbox_label(ctx, weapons[0], &check_values[0], NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, weapons[1], &check_values[1], NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, weapons[2], &check_values[2], NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, weapons[3], &check_values[3], NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, weapons[0], &check_values[0]);
nk_checkbox_label(ctx, weapons[1], &check_values[1]);
nk_checkbox_label(ctx, weapons[2], &check_values[2]);
nk_checkbox_label(ctx, weapons[3], &check_values[3]);
nk_combo_end(ctx);
}
@ -728,7 +728,7 @@ overview(struct nk_context *ctx)
static int slider = 10;
nk_layout_row_dynamic(ctx, 25, 1);
nk_checkbox_label(ctx, "Menu", &show_menu, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "Menu", &show_menu);
nk_progress(ctx, &prog, 100, NK_MODIFIABLE);
nk_slider_int(ctx, 0, &slider, 16, 1);
if (nk_contextual_item_label(ctx, "About", NK_TEXT_CENTERED))
@ -895,9 +895,9 @@ overview(struct nk_context *ctx)
if (group_titlebar) group_flags |= NK_WINDOW_TITLE;
nk_layout_row_dynamic(ctx, 30, 3);
nk_checkbox_label(ctx, "Titlebar", &group_titlebar, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "Border", &group_border, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "No Scrollbar", &group_no_scrollbar, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "Titlebar", &group_titlebar);
nk_checkbox_label(ctx, "Border", &group_border);
nk_checkbox_label(ctx, "No Scrollbar", &group_no_scrollbar);
nk_layout_row_begin(ctx, NK_STATIC, 22, 3);
nk_layout_row_push(ctx, 50);

View File

@ -250,8 +250,8 @@ int main(void)
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 22, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -342,8 +342,8 @@ int main(void)
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 22, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -255,8 +255,8 @@ int main(void)
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 22, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -164,8 +164,8 @@ int main(void)
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 22, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);
}

View File

@ -159,8 +159,8 @@ int main(void)
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 22, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);
}

View File

@ -172,8 +172,8 @@ int main(void)
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -158,8 +158,8 @@ int main(void)
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -168,8 +168,8 @@ int main(void)
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -2148,9 +2148,9 @@ int main(void) {
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT))
if (nk_option_label(ctx, "easy", op == EASY))
op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT))
if (nk_option_label(ctx, "hard", op == HARD))
op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);

View File

@ -216,8 +216,8 @@ int main(int argc, char **argv)
printf("button pressed\n");
}
nk_layout_row_dynamic(&(context->ctx), 40, 2);
if (nk_option_label(&(context->ctx), "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(&(context->ctx), "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(&(context->ctx), "easy", op == EASY)) op = EASY;
if (nk_option_label(&(context->ctx), "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(&(context->ctx), 45, 1);
nk_property_int(&(context->ctx), "Compression:", 0, &property, 100, 10, 1);
}

View File

@ -154,8 +154,8 @@ main(int argc, char *argv[])
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -164,8 +164,8 @@ int main(int argc, char *argv[])
if (nk_button_label(ctx, "button"))
printf("button pressed!\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 22, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -128,8 +128,8 @@ MainLoop(void* loopArg){
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);
}

View File

@ -192,8 +192,8 @@ main(int argc, char *argv[])
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -139,8 +139,8 @@ int main(void)
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -146,8 +146,8 @@ int main(void)
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -533,8 +533,8 @@ int main ()
printf("button pressed\n");
}
nk_layout_row_dynamic(&(nk_wayland_ctx.ctx), 30, 2);
if (nk_option_label(&(nk_wayland_ctx.ctx), "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(&(nk_wayland_ctx.ctx), "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(&(nk_wayland_ctx.ctx), "easy", op == EASY)) op = EASY;
if (nk_option_label(&(nk_wayland_ctx.ctx), "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(&(nk_wayland_ctx.ctx), 25, 1);
nk_property_int(&(nk_wayland_ctx.ctx), "Compression:", 0, &property, 100, 10, 1);
}

View File

@ -192,8 +192,8 @@ main(void)
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);
}

View File

@ -296,8 +296,8 @@ int main(void)
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -293,8 +293,8 @@ int main(void)
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);

View File

@ -229,8 +229,8 @@ main(void)
if (nk_button_label(&rawfb->ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(&rawfb->ctx, 30, 2);
if (nk_option_label(&rawfb->ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(&rawfb->ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(&rawfb->ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(&rawfb->ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(&rawfb->ctx, 25, 1);
nk_property_int(&rawfb->ctx, "Compression:", 0, &property, 100, 10, 1);
}

View File

@ -196,8 +196,8 @@ main(void)
if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");
nk_layout_row_dynamic(ctx, 30, 2);
if (nk_option_label(ctx, "easy", op == EASY, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD, NK_WIDGET_LEFT, NK_TEXT_LEFT)) op = HARD;
if (nk_option_label(ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(ctx, "hard", op == HARD)) op = HARD;
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);
}

View File

@ -201,7 +201,7 @@ grid_demo(struct nk_context *ctx, struct media *media)
nk_label(ctx, "Binary:", NK_TEXT_RIGHT);
nk_edit_string(ctx, NK_EDIT_FIELD, text[2], &text_len[2], 64, nk_filter_binary);
nk_label(ctx, "Checkbox:", NK_TEXT_RIGHT);
nk_checkbox_label(ctx, "Check me", &check, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "Check me", &check);
nk_label(ctx, "Combobox:", NK_TEXT_RIGHT);
if (nk_combo_begin_label(ctx, items[selected_item], nk_vec2(nk_widget_width(ctx), 200))) {
nk_layout_row_dynamic(ctx, 25, 1);
@ -433,9 +433,9 @@ basic_demo(struct nk_context *ctx, struct media *media)
*------------------------------------------------*/
ui_header(ctx, media, "Checkbox");
ui_widget(ctx, media, 30);
nk_checkbox_label(ctx, "Flag 1", &check0, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "Flag 1", &check0);
ui_widget(ctx, media, 30);
nk_checkbox_label(ctx, "Flag 2", &check1, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_checkbox_label(ctx, "Flag 2", &check1);
/*------------------------------------------------
* PROGRESSBAR

View File

@ -754,10 +754,10 @@ int main(int argc, char *argv[])
nk_layout_row_dynamic(&ctx, 20, 1);
nk_label(&ctx, "Label", NK_TEXT_LEFT);
nk_layout_row_dynamic(&ctx, 30, 2);
nk_check_label(&ctx, "inactive", 0, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_check_label(&ctx, "active", 1, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_option_label(&ctx, "active", 1, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_option_label(&ctx, "inactive", 0, NK_WIDGET_LEFT, NK_TEXT_LEFT);
nk_check_label(&ctx, "inactive", 0);
nk_check_label(&ctx, "active", 1);
nk_option_label(&ctx, "active", 1);
nk_option_label(&ctx, "inactive", 0);
nk_layout_row_dynamic(&ctx, 30, 1);
nk_slider_int(&ctx, 0, &slider, 16, 1);

172
nuklear.h
View File

@ -3205,23 +3205,30 @@ NK_API nk_bool nk_button_pop_behavior(struct nk_context*);
* CHECKBOX
*
* ============================================================================= */
NK_API nk_bool nk_check_label(struct nk_context*, const char*, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_check_text(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment);
NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_label(struct nk_context*, const char*, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_text(struct nk_context*, const char*, int, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_check_label(struct nk_context*, const char*, nk_bool active);
NK_API nk_bool nk_check_text(struct nk_context*, const char*, int, nk_bool active);
NK_API nk_bool nk_check_text_align(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value);
NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value);
NK_API nk_bool nk_checkbox_label(struct nk_context*, const char*, nk_bool *active);
NK_API nk_bool nk_checkbox_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_text(struct nk_context*, const char*, int, nk_bool *active);
NK_API nk_bool nk_checkbox_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value);
NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value);
/* =============================================================================
*
* RADIO BUTTON
*
* ============================================================================= */
NK_API nk_bool nk_radio_label(struct nk_context*, const char*, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_radio_text(struct nk_context*, const char*, int, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_option_label(struct nk_context*, const char*, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_option_text(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_radio_label(struct nk_context*, const char*, nk_bool *active);
NK_API nk_bool nk_radio_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_radio_text(struct nk_context*, const char*, int, nk_bool *active);
NK_API nk_bool nk_radio_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_option_label(struct nk_context*, const char*, nk_bool active);
NK_API nk_bool nk_option_label_align(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_option_text(struct nk_context*, const char*, int, nk_bool active);
NK_API nk_bool nk_option_text_align(struct nk_context *ctx, const char *text, int len, nk_bool is_active, nk_flags widget_alignment, nk_flags text_alignment);
/* =============================================================================
*
* SELECTABLE
@ -24894,7 +24901,35 @@ nk_do_toggle(nk_flags *state,
*
* --------------------------------------------------------------*/
NK_API nk_bool
nk_check_text(struct nk_context *ctx, const char *text, int len, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
nk_check_text(struct nk_context *ctx, const char *text, int len, nk_bool active)
{
struct nk_window *win;
struct nk_panel *layout;
const struct nk_input *in;
const struct nk_style *style;
struct nk_rect bounds;
enum nk_widget_layout_states state;
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
NK_ASSERT(ctx->current->layout);
if (!ctx || !ctx->current || !ctx->current->layout)
return active;
win = ctx->current;
style = &ctx->style;
layout = win->layout;
state = nk_widget(&bounds, ctx);
if (!state) return active;
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
nk_do_toggle(&ctx->last_widget_state, &win->buffer, bounds, &active,
text, len, NK_TOGGLE_CHECK, &style->checkbox, in, style->font, NK_WIDGET_LEFT, NK_TEXT_LEFT);
return active;
}
NK_API nk_bool
nk_check_text_align(struct nk_context *ctx, const char *text, int len, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
{
struct nk_window *win;
struct nk_panel *layout;
@ -24923,20 +24958,20 @@ nk_check_text(struct nk_context *ctx, const char *text, int len, nk_bool active,
}
NK_API unsigned int
nk_check_flags_text(struct nk_context *ctx, const char *text, int len,
unsigned int flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment)
unsigned int flags, unsigned int value)
{
int old_active;
NK_ASSERT(ctx);
NK_ASSERT(text);
if (!ctx || !text) return flags;
old_active = (int)((flags & value) & value);
if (nk_check_text(ctx, text, len, old_active, widget_alignment, text_alignment))
if (nk_check_text(ctx, text, len, old_active))
flags |= value;
else flags &= ~value;
return flags;
}
NK_API nk_bool
nk_checkbox_text(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
nk_checkbox_text(struct nk_context *ctx, const char *text, int len, nk_bool *active)
{
int old_val;
NK_ASSERT(ctx);
@ -24944,12 +24979,24 @@ nk_checkbox_text(struct nk_context *ctx, const char *text, int len, nk_bool *act
NK_ASSERT(active);
if (!ctx || !text || !active) return 0;
old_val = *active;
*active = nk_check_text(ctx, text, len, *active, widget_alignment, text_alignment);
*active = nk_check_text(ctx, text, len, *active);
return old_val != *active;
}
NK_API nk_bool
nk_checkbox_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
{
int old_val;
NK_ASSERT(ctx);
NK_ASSERT(text);
NK_ASSERT(active);
if (!ctx || !text || !active) return 0;
old_val = *active;
*active = nk_check_text_align(ctx, text, len, *active, widget_alignment, text_alignment);
return old_val != *active;
}
NK_API nk_bool
nk_checkbox_flags_text(struct nk_context *ctx, const char *text, int len,
unsigned int *flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment)
unsigned int *flags, unsigned int value)
{
nk_bool active;
NK_ASSERT(ctx);
@ -24958,30 +25005,34 @@ nk_checkbox_flags_text(struct nk_context *ctx, const char *text, int len,
if (!ctx || !text || !flags) return 0;
active = (int)((*flags & value) & value);
if (nk_checkbox_text(ctx, text, len, &active, widget_alignment, text_alignment)) {
if (nk_checkbox_text(ctx, text, len, &active)) {
if (active) *flags |= value;
else *flags &= ~value;
return 1;
}
return 0;
}
NK_API nk_bool nk_check_label(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
NK_API nk_bool nk_check_label(struct nk_context *ctx, const char *label, nk_bool active)
{
return nk_check_text(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
return nk_check_text(ctx, label, nk_strlen(label), active);
}
NK_API unsigned int nk_check_flags_label(struct nk_context *ctx, const char *label,
unsigned int flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment)
unsigned int flags, unsigned int value)
{
return nk_check_flags_text(ctx, label, nk_strlen(label), flags, value, widget_alignment, text_alignment);
return nk_check_flags_text(ctx, label, nk_strlen(label), flags, value);
}
NK_API nk_bool nk_checkbox_label(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
NK_API nk_bool nk_checkbox_label(struct nk_context *ctx, const char *label, nk_bool *active)
{
return nk_checkbox_text(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
return nk_checkbox_text(ctx, label, nk_strlen(label), active);
}
NK_API nk_bool nk_checkbox_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
{
return nk_checkbox_text_align(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
}
NK_API nk_bool nk_checkbox_flags_label(struct nk_context *ctx, const char *label,
unsigned int *flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment)
unsigned int *flags, unsigned int value)
{
return nk_checkbox_flags_text(ctx, label, nk_strlen(label), flags, value, widget_alignment, text_alignment);
return nk_checkbox_flags_text(ctx, label, nk_strlen(label), flags, value);
}
/*----------------------------------------------------------------
*
@ -24989,7 +25040,35 @@ NK_API nk_bool nk_checkbox_flags_label(struct nk_context *ctx, const char *label
*
* --------------------------------------------------------------*/
NK_API nk_bool
nk_option_text(struct nk_context *ctx, const char *text, int len, nk_bool is_active, nk_flags widget_alignment, nk_flags text_alignment)
nk_option_text(struct nk_context *ctx, const char *text, int len, nk_bool is_active)
{
struct nk_window *win;
struct nk_panel *layout;
const struct nk_input *in;
const struct nk_style *style;
struct nk_rect bounds;
enum nk_widget_layout_states state;
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
NK_ASSERT(ctx->current->layout);
if (!ctx || !ctx->current || !ctx->current->layout)
return is_active;
win = ctx->current;
style = &ctx->style;
layout = win->layout;
state = nk_widget(&bounds, ctx);
if (!state) return (int)state;
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
nk_do_toggle(&ctx->last_widget_state, &win->buffer, bounds, &is_active,
text, len, NK_TOGGLE_OPTION, &style->option, in, style->font, NK_WIDGET_LEFT, NK_TEXT_LEFT);
return is_active;
}
NK_API nk_bool
nk_option_text_align(struct nk_context *ctx, const char *text, int len, nk_bool is_active, nk_flags widget_alignment, nk_flags text_alignment)
{
struct nk_window *win;
struct nk_panel *layout;
@ -25017,7 +25096,7 @@ nk_option_text(struct nk_context *ctx, const char *text, int len, nk_bool is_act
return is_active;
}
NK_API nk_bool
nk_radio_text(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
nk_radio_text(struct nk_context *ctx, const char *text, int len, nk_bool *active)
{
int old_value;
NK_ASSERT(ctx);
@ -25025,18 +25104,40 @@ nk_radio_text(struct nk_context *ctx, const char *text, int len, nk_bool *active
NK_ASSERT(active);
if (!ctx || !text || !active) return 0;
old_value = *active;
*active = nk_option_text(ctx, text, len, old_value, widget_alignment, text_alignment);
*active = nk_option_text(ctx, text, len, old_value);
return old_value != *active;
}
NK_API nk_bool
nk_option_label(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
nk_radio_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
{
return nk_option_text(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
int old_value;
NK_ASSERT(ctx);
NK_ASSERT(text);
NK_ASSERT(active);
if (!ctx || !text || !active) return 0;
old_value = *active;
*active = nk_option_text_align(ctx, text, len, old_value, widget_alignment, text_alignment);
return old_value != *active;
}
NK_API nk_bool
nk_radio_label(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
nk_option_label(struct nk_context *ctx, const char *label, nk_bool active)
{
return nk_radio_text(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
return nk_option_text(ctx, label, nk_strlen(label), active);
}
NK_API nk_bool
nk_option_label_align(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
{
return nk_option_text_align(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
}
NK_API nk_bool
nk_radio_label(struct nk_context *ctx, const char *label, nk_bool *active)
{
return nk_radio_text(ctx, label, nk_strlen(label), active);
}
NK_API nk_bool
nk_radio_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
{
return nk_radio_text_align(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
}
@ -30022,8 +30123,7 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - [y]: Minor version with non-breaking API and library changes
/// - [z]: Patch version with no direct changes to the API
///
/// - 2023/11/26 (5.0.0) - BREAKING CHANGE: Added alignment to checkboxes and radio buttons. They
/// all now require a widget and text alignment parameter.
/// - 2023/11/26 (4.12.0) - Added an alignment option to checkboxes and radio buttons.
/// - 2023/10/11 (4.11.0) - Added nk_widget_disable_begin() and nk_widget_disable_end()
/// - 2022/12/23 (4.10.6) - Fix incorrect glyph index in nk_font_bake()
/// - 2022/12/17 (4.10.5) - Fix nk_font_bake_pack() using TTC font offset incorrectly

View File

@ -7,8 +7,7 @@
/// - [y]: Minor version with non-breaking API and library changes
/// - [z]: Patch version with no direct changes to the API
///
/// - 2023/11/26 (5.0.0) - BREAKING CHANGE: Added alignment to checkboxes and radio buttons. They
/// all now require a widget and text alignment parameter.
/// - 2023/11/26 (4.12.0) - Added an alignment option to checkboxes and radio buttons.
/// - 2023/10/11 (4.11.0) - Added nk_widget_disable_begin() and nk_widget_disable_end()
/// - 2022/12/23 (4.10.6) - Fix incorrect glyph index in nk_font_bake()
/// - 2022/12/17 (4.10.5) - Fix nk_font_bake_pack() using TTC font offset incorrectly

View File

@ -2983,23 +2983,30 @@ NK_API nk_bool nk_button_pop_behavior(struct nk_context*);
* CHECKBOX
*
* ============================================================================= */
NK_API nk_bool nk_check_label(struct nk_context*, const char*, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_check_text(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment);
NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_label(struct nk_context*, const char*, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_text(struct nk_context*, const char*, int, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_check_label(struct nk_context*, const char*, nk_bool active);
NK_API nk_bool nk_check_text(struct nk_context*, const char*, int, nk_bool active);
NK_API nk_bool nk_check_text_align(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API unsigned nk_check_flags_label(struct nk_context*, const char*, unsigned int flags, unsigned int value);
NK_API unsigned nk_check_flags_text(struct nk_context*, const char*, int, unsigned int flags, unsigned int value);
NK_API nk_bool nk_checkbox_label(struct nk_context*, const char*, nk_bool *active);
NK_API nk_bool nk_checkbox_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_text(struct nk_context*, const char*, int, nk_bool *active);
NK_API nk_bool nk_checkbox_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_checkbox_flags_label(struct nk_context*, const char*, unsigned int *flags, unsigned int value);
NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value);
/* =============================================================================
*
* RADIO BUTTON
*
* ============================================================================= */
NK_API nk_bool nk_radio_label(struct nk_context*, const char*, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_radio_text(struct nk_context*, const char*, int, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_option_label(struct nk_context*, const char*, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_option_text(struct nk_context*, const char*, int, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_radio_label(struct nk_context*, const char*, nk_bool *active);
NK_API nk_bool nk_radio_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_radio_text(struct nk_context*, const char*, int, nk_bool *active);
NK_API nk_bool nk_radio_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_option_label(struct nk_context*, const char*, nk_bool active);
NK_API nk_bool nk_option_label_align(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment);
NK_API nk_bool nk_option_text(struct nk_context*, const char*, int, nk_bool active);
NK_API nk_bool nk_option_text_align(struct nk_context *ctx, const char *text, int len, nk_bool is_active, nk_flags widget_alignment, nk_flags text_alignment);
/* =============================================================================
*
* SELECTABLE

View File

@ -198,7 +198,35 @@ nk_do_toggle(nk_flags *state,
*
* --------------------------------------------------------------*/
NK_API nk_bool
nk_check_text(struct nk_context *ctx, const char *text, int len, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
nk_check_text(struct nk_context *ctx, const char *text, int len, nk_bool active)
{
struct nk_window *win;
struct nk_panel *layout;
const struct nk_input *in;
const struct nk_style *style;
struct nk_rect bounds;
enum nk_widget_layout_states state;
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
NK_ASSERT(ctx->current->layout);
if (!ctx || !ctx->current || !ctx->current->layout)
return active;
win = ctx->current;
style = &ctx->style;
layout = win->layout;
state = nk_widget(&bounds, ctx);
if (!state) return active;
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
nk_do_toggle(&ctx->last_widget_state, &win->buffer, bounds, &active,
text, len, NK_TOGGLE_CHECK, &style->checkbox, in, style->font, NK_WIDGET_LEFT, NK_TEXT_LEFT);
return active;
}
NK_API nk_bool
nk_check_text_align(struct nk_context *ctx, const char *text, int len, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
{
struct nk_window *win;
struct nk_panel *layout;
@ -227,20 +255,20 @@ nk_check_text(struct nk_context *ctx, const char *text, int len, nk_bool active,
}
NK_API unsigned int
nk_check_flags_text(struct nk_context *ctx, const char *text, int len,
unsigned int flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment)
unsigned int flags, unsigned int value)
{
int old_active;
NK_ASSERT(ctx);
NK_ASSERT(text);
if (!ctx || !text) return flags;
old_active = (int)((flags & value) & value);
if (nk_check_text(ctx, text, len, old_active, widget_alignment, text_alignment))
if (nk_check_text(ctx, text, len, old_active))
flags |= value;
else flags &= ~value;
return flags;
}
NK_API nk_bool
nk_checkbox_text(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
nk_checkbox_text(struct nk_context *ctx, const char *text, int len, nk_bool *active)
{
int old_val;
NK_ASSERT(ctx);
@ -248,12 +276,24 @@ nk_checkbox_text(struct nk_context *ctx, const char *text, int len, nk_bool *act
NK_ASSERT(active);
if (!ctx || !text || !active) return 0;
old_val = *active;
*active = nk_check_text(ctx, text, len, *active, widget_alignment, text_alignment);
*active = nk_check_text(ctx, text, len, *active);
return old_val != *active;
}
NK_API nk_bool
nk_checkbox_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
{
int old_val;
NK_ASSERT(ctx);
NK_ASSERT(text);
NK_ASSERT(active);
if (!ctx || !text || !active) return 0;
old_val = *active;
*active = nk_check_text_align(ctx, text, len, *active, widget_alignment, text_alignment);
return old_val != *active;
}
NK_API nk_bool
nk_checkbox_flags_text(struct nk_context *ctx, const char *text, int len,
unsigned int *flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment)
unsigned int *flags, unsigned int value)
{
nk_bool active;
NK_ASSERT(ctx);
@ -262,30 +302,34 @@ nk_checkbox_flags_text(struct nk_context *ctx, const char *text, int len,
if (!ctx || !text || !flags) return 0;
active = (int)((*flags & value) & value);
if (nk_checkbox_text(ctx, text, len, &active, widget_alignment, text_alignment)) {
if (nk_checkbox_text(ctx, text, len, &active)) {
if (active) *flags |= value;
else *flags &= ~value;
return 1;
}
return 0;
}
NK_API nk_bool nk_check_label(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
NK_API nk_bool nk_check_label(struct nk_context *ctx, const char *label, nk_bool active)
{
return nk_check_text(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
return nk_check_text(ctx, label, nk_strlen(label), active);
}
NK_API unsigned int nk_check_flags_label(struct nk_context *ctx, const char *label,
unsigned int flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment)
unsigned int flags, unsigned int value)
{
return nk_check_flags_text(ctx, label, nk_strlen(label), flags, value, widget_alignment, text_alignment);
return nk_check_flags_text(ctx, label, nk_strlen(label), flags, value);
}
NK_API nk_bool nk_checkbox_label(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
NK_API nk_bool nk_checkbox_label(struct nk_context *ctx, const char *label, nk_bool *active)
{
return nk_checkbox_text(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
return nk_checkbox_text(ctx, label, nk_strlen(label), active);
}
NK_API nk_bool nk_checkbox_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
{
return nk_checkbox_text_align(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
}
NK_API nk_bool nk_checkbox_flags_label(struct nk_context *ctx, const char *label,
unsigned int *flags, unsigned int value, nk_flags widget_alignment, nk_flags text_alignment)
unsigned int *flags, unsigned int value)
{
return nk_checkbox_flags_text(ctx, label, nk_strlen(label), flags, value, widget_alignment, text_alignment);
return nk_checkbox_flags_text(ctx, label, nk_strlen(label), flags, value);
}
/*----------------------------------------------------------------
*
@ -293,7 +337,35 @@ NK_API nk_bool nk_checkbox_flags_label(struct nk_context *ctx, const char *label
*
* --------------------------------------------------------------*/
NK_API nk_bool
nk_option_text(struct nk_context *ctx, const char *text, int len, nk_bool is_active, nk_flags widget_alignment, nk_flags text_alignment)
nk_option_text(struct nk_context *ctx, const char *text, int len, nk_bool is_active)
{
struct nk_window *win;
struct nk_panel *layout;
const struct nk_input *in;
const struct nk_style *style;
struct nk_rect bounds;
enum nk_widget_layout_states state;
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
NK_ASSERT(ctx->current->layout);
if (!ctx || !ctx->current || !ctx->current->layout)
return is_active;
win = ctx->current;
style = &ctx->style;
layout = win->layout;
state = nk_widget(&bounds, ctx);
if (!state) return (int)state;
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
nk_do_toggle(&ctx->last_widget_state, &win->buffer, bounds, &is_active,
text, len, NK_TOGGLE_OPTION, &style->option, in, style->font, NK_WIDGET_LEFT, NK_TEXT_LEFT);
return is_active;
}
NK_API nk_bool
nk_option_text_align(struct nk_context *ctx, const char *text, int len, nk_bool is_active, nk_flags widget_alignment, nk_flags text_alignment)
{
struct nk_window *win;
struct nk_panel *layout;
@ -321,7 +393,7 @@ nk_option_text(struct nk_context *ctx, const char *text, int len, nk_bool is_act
return is_active;
}
NK_API nk_bool
nk_radio_text(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
nk_radio_text(struct nk_context *ctx, const char *text, int len, nk_bool *active)
{
int old_value;
NK_ASSERT(ctx);
@ -329,17 +401,39 @@ nk_radio_text(struct nk_context *ctx, const char *text, int len, nk_bool *active
NK_ASSERT(active);
if (!ctx || !text || !active) return 0;
old_value = *active;
*active = nk_option_text(ctx, text, len, old_value, widget_alignment, text_alignment);
*active = nk_option_text(ctx, text, len, old_value);
return old_value != *active;
}
NK_API nk_bool
nk_option_label(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
nk_radio_text_align(struct nk_context *ctx, const char *text, int len, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
{
return nk_option_text(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
int old_value;
NK_ASSERT(ctx);
NK_ASSERT(text);
NK_ASSERT(active);
if (!ctx || !text || !active) return 0;
old_value = *active;
*active = nk_option_text_align(ctx, text, len, old_value, widget_alignment, text_alignment);
return old_value != *active;
}
NK_API nk_bool
nk_radio_label(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
nk_option_label(struct nk_context *ctx, const char *label, nk_bool active)
{
return nk_radio_text(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
return nk_option_text(ctx, label, nk_strlen(label), active);
}
NK_API nk_bool
nk_option_label_align(struct nk_context *ctx, const char *label, nk_bool active, nk_flags widget_alignment, nk_flags text_alignment)
{
return nk_option_text_align(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
}
NK_API nk_bool
nk_radio_label(struct nk_context *ctx, const char *label, nk_bool *active)
{
return nk_radio_text(ctx, label, nk_strlen(label), active);
}
NK_API nk_bool
nk_radio_label_align(struct nk_context *ctx, const char *label, nk_bool *active, nk_flags widget_alignment, nk_flags text_alignment)
{
return nk_radio_text_align(ctx, label, nk_strlen(label), active, widget_alignment, text_alignment);
}