Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

demo: Fix overview's nk_bool usage #607

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions demo/common/overview.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ static int
overview(struct nk_context *ctx)
{
/* window flags */
static int show_menu = nk_true;
static nk_bool show_menu = nk_true;
static nk_flags window_flags = NK_WINDOW_TITLE|NK_WINDOW_BORDER|NK_WINDOW_SCALABLE|NK_WINDOW_MOVABLE|NK_WINDOW_MINIMIZABLE;
nk_flags actual_window_flags;

/* popups */
static enum nk_style_header_align header_align = NK_HEADER_RIGHT;
static int show_app_about = nk_false;
static nk_bool show_app_about = nk_false;

ctx->style.window.header.align = header_align;

Expand All @@ -25,7 +25,7 @@ overview(struct nk_context *ctx)
enum menu_states {MENU_DEFAULT, MENU_WINDOWS};
static nk_size mprog = 60;
static int mslider = 10;
static int mcheck = nk_true;
static nk_bool mcheck = nk_true;
nk_menubar_begin(ctx);

/* menu #1 */
Expand All @@ -35,7 +35,7 @@ overview(struct nk_context *ctx)
{
static size_t prog = 40;
static int slider = 10;
static int check = nk_true;
static nk_bool check = nk_true;
nk_layout_row_dynamic(ctx, 25, 1);
if (nk_menu_item_label(ctx, "Hide", NK_TEXT_LEFT))
show_menu = nk_false;
Expand Down Expand Up @@ -141,10 +141,10 @@ overview(struct nk_context *ctx)
if (nk_tree_push(ctx, NK_TREE_TAB, "Widgets", NK_MINIMIZED))
{
enum options {A,B,C};
static int checkbox_left_text_left;
static int checkbox_centered_text_right;
static int checkbox_right_text_right;
static int checkbox_right_text_left;
static nk_bool checkbox_left_text_left;
static nk_bool checkbox_centered_text_right;
static nk_bool checkbox_right_text_right;
static nk_bool checkbox_right_text_left;
static int option_left;
static int option_right;
if (nk_tree_push(ctx, NK_TREE_NODE, "Text", NK_MINIMIZED))
Expand Down Expand Up @@ -261,15 +261,15 @@ overview(struct nk_context *ctx)

if (nk_tree_push(ctx, NK_TREE_NODE, "Inactive", NK_MINIMIZED))
{
static int inactive = 1;
static nk_bool inactive = 1;
nk_layout_row_dynamic(ctx, 30, 1);
nk_checkbox_label(ctx, "Inactive", &inactive);

nk_layout_row_static(ctx, 30, 80, 1);
if (inactive) {
nk_widget_disable_begin(ctx);
}

if (nk_button_label(ctx, "button"))
fprintf(stdout, "button pressed\n");

Expand All @@ -282,7 +282,7 @@ overview(struct nk_context *ctx)
{
if (nk_tree_push(ctx, NK_TREE_NODE, "List", NK_MINIMIZED))
{
static int selected[4] = {nk_false, nk_false, nk_true, nk_false};
static nk_bool selected[4] = {nk_false, nk_false, nk_true, nk_false};
nk_layout_row_static(ctx, 18, 100, 1);
nk_selectable_label(ctx, "Selectable", NK_TEXT_LEFT, &selected[0]);
nk_selectable_label(ctx, "Selectable", NK_TEXT_LEFT, &selected[1]);
Expand All @@ -294,7 +294,7 @@ overview(struct nk_context *ctx)
if (nk_tree_push(ctx, NK_TREE_NODE, "Grid", NK_MINIMIZED))
{
int i;
static int selected[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
static nk_bool selected[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
nk_layout_row_static(ctx, 50, 50, 4);
for (i = 0; i < 16; ++i) {
if (nk_selectable_label(ctx, "Z", NK_TEXT_CENTERED, &selected[i])) {
Expand Down Expand Up @@ -341,7 +341,7 @@ overview(struct nk_context *ctx)
*/
static float chart_selection = 8.0f;
static int current_weapon = 0;
static int check_values[5];
static nk_bool check_values[5];
static float position[3];
static struct nk_color combo_color = {130, 50, 50, 255};
static struct nk_colorf combo_color2 = {0.509f, 0.705f, 0.2f, 1.0f};
Expand Down Expand Up @@ -602,7 +602,7 @@ overview(struct nk_context *ctx)
}
nk_tree_pop(ctx);
}

if (nk_tree_push(ctx, NK_TREE_NODE, "Horizontal Rule", NK_MINIMIZED))
{
nk_layout_row_dynamic(ctx, 12, 1);
Expand Down Expand Up @@ -713,8 +713,8 @@ overview(struct nk_context *ctx)
if (nk_tree_push(ctx, NK_TREE_TAB, "Popup", NK_MINIMIZED))
{
static struct nk_color color = {255,0,0, 255};
static int select[4];
static int popup_active;
static nk_bool select[4];
static nk_bool popup_active;
const struct nk_input *in = &ctx->input;
struct nk_rect bounds;

Expand Down Expand Up @@ -883,9 +883,9 @@ overview(struct nk_context *ctx)

if (nk_tree_push(ctx, NK_TREE_NODE, "Group", NK_MINIMIZED))
{
static int group_titlebar = nk_false;
static int group_border = nk_true;
static int group_no_scrollbar = nk_false;
static nk_bool group_titlebar = nk_false;
static nk_bool group_border = nk_true;
static nk_bool group_no_scrollbar = nk_false;
static int group_width = 320;
static int group_height = 200;

Expand All @@ -911,7 +911,7 @@ overview(struct nk_context *ctx)
nk_layout_row_static(ctx, (float)group_height, group_width, 2);
if (nk_group_begin(ctx, "Group", group_flags)) {
int i = 0;
static int selected[16];
static nk_bool selected[16];
nk_layout_row_static(ctx, 18, 100, 1);
for (i = 0; i < 16; ++i)
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
Expand All @@ -921,19 +921,20 @@ overview(struct nk_context *ctx)
}
if (nk_tree_push(ctx, NK_TREE_NODE, "Tree", NK_MINIMIZED))
{
static int root_selected = 0;
int sel = root_selected;
static nk_bool root_selected = 0;
nk_bool sel = root_selected;
if (nk_tree_element_push(ctx, NK_TREE_NODE, "Root", NK_MINIMIZED, &sel)) {
static int selected[8];
int i = 0, node_select = selected[0];
static nk_bool selected[8];
int i = 0;
nk_bool node_select = selected[0];
if (sel != root_selected) {
root_selected = sel;
for (i = 0; i < 8; ++i)
selected[i] = sel;
}
if (nk_tree_element_push(ctx, NK_TREE_NODE, "Node", NK_MINIMIZED, &node_select)) {
int j = 0;
static int sel_nodes[4];
static nk_bool sel_nodes[4];
if (node_select != selected[0]) {
selected[0] = node_select;
for (i = 0; i < 4; ++i)
Expand Down Expand Up @@ -1061,7 +1062,7 @@ overview(struct nk_context *ctx)
nk_layout_space_begin(ctx, NK_STATIC, 500, 64);
nk_layout_space_push(ctx, nk_rect(0,0,150,500));
if (nk_group_begin(ctx, "Group_left", NK_WINDOW_BORDER)) {
static int selected[32];
static nk_bool selected[32];
nk_layout_row_static(ctx, 18, 100, 1);
for (i = 0; i < 32; ++i)
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
Expand Down Expand Up @@ -1094,7 +1095,7 @@ overview(struct nk_context *ctx)

nk_layout_space_push(ctx, nk_rect(320,0,150,150));
if (nk_group_begin(ctx, "Group_right_top", NK_WINDOW_BORDER)) {
static int selected[4];
static nk_bool selected[4];
nk_layout_row_static(ctx, 18, 100, 1);
for (i = 0; i < 4; ++i)
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
Expand All @@ -1103,7 +1104,7 @@ overview(struct nk_context *ctx)

nk_layout_space_push(ctx, nk_rect(320,160,150,150));
if (nk_group_begin(ctx, "Group_right_center", NK_WINDOW_BORDER)) {
static int selected[4];
static nk_bool selected[4];
nk_layout_row_static(ctx, 18, 100, 1);
for (i = 0; i < 4; ++i)
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
Expand All @@ -1112,7 +1113,7 @@ overview(struct nk_context *ctx)

nk_layout_space_push(ctx, nk_rect(320,320,150,150));
if (nk_group_begin(ctx, "Group_right_bottom", NK_WINDOW_BORDER)) {
static int selected[4];
static nk_bool selected[4];
nk_layout_row_static(ctx, 18, 100, 1);
for (i = 0; i < 4; ++i)
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
Expand Down Expand Up @@ -1307,4 +1308,3 @@ overview(struct nk_context *ctx)
nk_end(ctx);
return !nk_window_is_closed(ctx, "Overview");
}