Separated color_factor for button into text and background

Tree node button background looked out of place when disabled, so I made the background not be affected by being disabled.
This commit is contained in:
Yukyduky 2023-10-29 10:08:29 +01:00
parent b1fcf9244f
commit 4545d184d3
6 changed files with 227 additions and 147 deletions

View File

@ -180,6 +180,7 @@ overview(struct nk_context *ctx)
nk_layout_row_static(ctx, 30, 100, 2);
nk_button_symbol_label(ctx, NK_SYMBOL_TRIANGLE_LEFT, "prev", NK_TEXT_RIGHT);
nk_button_symbol_label(ctx, NK_SYMBOL_TRIANGLE_RIGHT, "next", NK_TEXT_LEFT);
nk_tree_pop(ctx);
}
@ -259,7 +260,6 @@ overview(struct nk_context *ctx)
nk_tree_pop(ctx);
}
if (nk_tree_push(ctx, NK_TREE_NODE, "Selectable", NK_MINIMIZED))
{
if (nk_tree_push(ctx, NK_TREE_NODE, "List", NK_MINIMIZED))

186
nuklear.h
View File

@ -4919,6 +4919,7 @@ struct nk_style_button {
struct nk_style_item hover;
struct nk_style_item active;
struct nk_color border_color;
float color_factor_background;
/* text */
struct nk_color text_background;
@ -4926,6 +4927,7 @@ struct nk_style_button {
struct nk_color text_hover;
struct nk_color text_active;
nk_flags text_alignment;
float color_factor_text;
/* properties */
float border;
@ -4933,7 +4935,6 @@ struct nk_style_button {
struct nk_vec2 padding;
struct nk_vec2 image_padding;
struct nk_vec2 touch_padding;
float color_factor;
float disabled_factor;
/* optional user callbacks */
@ -18288,25 +18289,26 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
/* default button */
button = &style->button;
nk_zero_struct(*button);
button->normal = nk_style_item_color(table[NK_COLOR_BUTTON]);
button->hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]);
button->active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]);
button->border_color = table[NK_COLOR_BORDER];
button->text_background = table[NK_COLOR_BUTTON];
button->text_normal = table[NK_COLOR_TEXT];
button->text_hover = table[NK_COLOR_TEXT];
button->text_active = table[NK_COLOR_TEXT];
button->padding = nk_vec2(2.0f,2.0f);
button->image_padding = nk_vec2(0.0f,0.0f);
button->touch_padding = nk_vec2(0.0f, 0.0f);
button->userdata = nk_handle_ptr(0);
button->text_alignment = NK_TEXT_CENTERED;
button->border = 1.0f;
button->rounding = 4.0f;
button->color_factor = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
button->normal = nk_style_item_color(table[NK_COLOR_BUTTON]);
button->hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]);
button->active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]);
button->border_color = table[NK_COLOR_BORDER];
button->text_background = table[NK_COLOR_BUTTON];
button->text_normal = table[NK_COLOR_TEXT];
button->text_hover = table[NK_COLOR_TEXT];
button->text_active = table[NK_COLOR_TEXT];
button->padding = nk_vec2(2.0f,2.0f);
button->image_padding = nk_vec2(0.0f,0.0f);
button->touch_padding = nk_vec2(0.0f, 0.0f);
button->userdata = nk_handle_ptr(0);
button->text_alignment = NK_TEXT_CENTERED;
button->border = 1.0f;
button->rounding = 4.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
/* contextual button */
button = &style->contextual_button;
@ -18325,7 +18327,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -18347,7 +18350,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 1.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -18462,7 +18466,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 1.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -18532,7 +18537,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 1.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -18606,7 +18612,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -18687,7 +18694,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -18724,7 +18732,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -18747,7 +18756,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -18786,7 +18796,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -18808,7 +18819,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -23336,36 +23348,50 @@ nk_widget_disable_begin(struct nk_context* ctx)
win->widgets_disabled = nk_true;
style->button.color_factor = style->button.disabled_factor;
style->button.color_factor_text = style->button.disabled_factor;
style->button.color_factor_background = style->button.disabled_factor;
style->chart.color_factor = style->chart.disabled_factor;
style->checkbox.color_factor = style->checkbox.disabled_factor;
style->combo.color_factor = style->combo.disabled_factor;
style->combo.button.color_factor = style->combo.button.disabled_factor;
style->contextual_button.color_factor = style->contextual_button.disabled_factor;
style->combo.button.color_factor_text = style->combo.button.disabled_factor;
style->combo.button.color_factor_background = style->combo.button.disabled_factor;
style->contextual_button.color_factor_text = style->contextual_button.disabled_factor;
style->contextual_button.color_factor_background = style->contextual_button.disabled_factor;
style->edit.color_factor = style->edit.disabled_factor;
style->edit.scrollbar.color_factor = style->edit.scrollbar.disabled_factor;
style->menu_button.color_factor = style->menu_button.disabled_factor;
style->menu_button.color_factor_text = style->menu_button.disabled_factor;
style->menu_button.color_factor_background = style->menu_button.disabled_factor;
style->option.color_factor = style->option.disabled_factor;
style->progress.color_factor = style->progress.disabled_factor;
style->property.color_factor = style->property.disabled_factor;
style->property.inc_button.color_factor = style->property.inc_button.disabled_factor;
style->property.dec_button.color_factor = style->property.dec_button.disabled_factor;
style->property.inc_button.color_factor_text = style->property.inc_button.disabled_factor;
style->property.inc_button.color_factor_background = style->property.inc_button.disabled_factor;
style->property.dec_button.color_factor_text = style->property.dec_button.disabled_factor;
style->property.dec_button.color_factor_background = style->property.dec_button.disabled_factor;
style->property.edit.color_factor = style->property.edit.disabled_factor;
style->scrollh.color_factor = style->scrollh.disabled_factor;
style->scrollh.inc_button.color_factor = style->scrollh.inc_button.disabled_factor;
style->scrollh.dec_button.color_factor = style->scrollh.dec_button.disabled_factor;
style->scrollh.inc_button.color_factor_text = style->scrollh.inc_button.disabled_factor;
style->scrollh.inc_button.color_factor_background = style->scrollh.inc_button.disabled_factor;
style->scrollh.dec_button.color_factor_text = style->scrollh.dec_button.disabled_factor;
style->scrollh.dec_button.color_factor_background = style->scrollh.dec_button.disabled_factor;
style->scrollv.color_factor = style->scrollv.disabled_factor;
style->scrollv.inc_button.color_factor = style->scrollv.inc_button.disabled_factor;
style->scrollv.dec_button.color_factor = style->scrollv.dec_button.disabled_factor;
style->scrollv.inc_button.color_factor_text = style->scrollv.inc_button.disabled_factor;
style->scrollv.inc_button.color_factor_background = style->scrollv.inc_button.disabled_factor;
style->scrollv.dec_button.color_factor_text = style->scrollv.dec_button.disabled_factor;
style->scrollv.dec_button.color_factor_background = style->scrollv.dec_button.disabled_factor;
style->selectable.color_factor = style->selectable.disabled_factor;
style->slider.color_factor = style->slider.disabled_factor;
style->slider.inc_button.color_factor = style->slider.inc_button.disabled_factor;
style->slider.dec_button.color_factor = style->slider.dec_button.disabled_factor;
style->slider.inc_button.color_factor_text = style->slider.inc_button.disabled_factor;
style->slider.inc_button.color_factor_background = style->slider.inc_button.disabled_factor;
style->slider.dec_button.color_factor_text = style->slider.dec_button.disabled_factor;
style->slider.dec_button.color_factor_background = style->slider.dec_button.disabled_factor;
style->tab.color_factor = style->tab.disabled_factor;
style->tab.node_maximize_button.color_factor = style->tab.node_maximize_button.disabled_factor;
style->tab.node_minimize_button.color_factor = style->tab.node_minimize_button.disabled_factor;
style->tab.tab_maximize_button.color_factor = style->tab.tab_maximize_button.disabled_factor;
style->tab.tab_minimize_button.color_factor = style->tab.tab_minimize_button.disabled_factor;
style->tab.node_maximize_button.color_factor_text = style->tab.node_maximize_button.disabled_factor;
style->tab.node_minimize_button.color_factor_text = style->tab.node_minimize_button.disabled_factor;
style->tab.tab_maximize_button.color_factor_text = style->tab.tab_maximize_button.disabled_factor;
style->tab.tab_maximize_button.color_factor_background = style->tab.tab_maximize_button.disabled_factor;
style->tab.tab_minimize_button.color_factor_text = style->tab.tab_minimize_button.disabled_factor;
style->tab.tab_minimize_button.color_factor_background = style->tab.tab_minimize_button.disabled_factor;
style->text.color_factor = style->text.disabled_factor;
}
NK_API void
@ -23385,36 +23411,50 @@ nk_widget_disable_end(struct nk_context* ctx)
win->widgets_disabled = nk_false;
style->button.color_factor = 1.0f;
style->button.color_factor_text = 1.0f;
style->button.color_factor_background = 1.0f;
style->chart.color_factor = 1.0f;
style->checkbox.color_factor = 1.0f;
style->combo.color_factor = 1.0f;
style->combo.button.color_factor = 1.0f;
style->contextual_button.color_factor = 1.0f;
style->combo.button.color_factor_text = 1.0f;
style->combo.button.color_factor_background = 1.0f;
style->contextual_button.color_factor_text = 1.0f;
style->contextual_button.color_factor_background = 1.0f;
style->edit.color_factor = 1.0f;
style->edit.scrollbar.color_factor = 1.0f;
style->menu_button.color_factor = 1.0f;
style->menu_button.color_factor_text = 1.0f;
style->menu_button.color_factor_background = 1.0f;
style->option.color_factor = 1.0f;
style->progress.color_factor = 1.0f;
style->property.color_factor = 1.0f;
style->property.inc_button.color_factor = 1.0f;
style->property.dec_button.color_factor = 1.0f;
style->property.inc_button.color_factor_text = 1.0f;
style->property.inc_button.color_factor_background = 1.0f;
style->property.dec_button.color_factor_text = 1.0f;
style->property.dec_button.color_factor_background = 1.0f;
style->property.edit.color_factor = 1.0f;
style->scrollh.color_factor = 1.0f;
style->scrollh.inc_button.color_factor = 1.0f;
style->scrollh.dec_button.color_factor = 1.0f;
style->scrollh.inc_button.color_factor_text = 1.0f;
style->scrollh.inc_button.color_factor_background = 1.0f;
style->scrollh.dec_button.color_factor_text = 1.0f;
style->scrollh.dec_button.color_factor_background = 1.0f;
style->scrollv.color_factor = 1.0f;
style->scrollv.inc_button.color_factor = 1.0f;
style->scrollv.dec_button.color_factor = 1.0f;
style->scrollv.inc_button.color_factor_text = 1.0f;
style->scrollv.inc_button.color_factor_background = 1.0f;
style->scrollv.dec_button.color_factor_text = 1.0f;
style->scrollv.dec_button.color_factor_background = 1.0f;
style->selectable.color_factor = 1.0f;
style->slider.color_factor = 1.0f;
style->slider.inc_button.color_factor = 1.0f;
style->slider.dec_button.color_factor = 1.0f;
style->slider.inc_button.color_factor_text = 1.0f;
style->slider.inc_button.color_factor_background = 1.0f;
style->slider.dec_button.color_factor_text = 1.0f;
style->slider.dec_button.color_factor_background = 1.0f;
style->tab.color_factor = 1.0f;
style->tab.node_maximize_button.color_factor = 1.0f;
style->tab.node_minimize_button.color_factor = 1.0f;
style->tab.tab_maximize_button.color_factor = 1.0f;
style->tab.tab_minimize_button.color_factor = 1.0f;
style->tab.node_maximize_button.color_factor_text = 1.0f;
style->tab.node_minimize_button.color_factor_text = 1.0f;
style->tab.tab_maximize_button.color_factor_text = 1.0f;
style->tab.tab_maximize_button.color_factor_background = 1.0f;
style->tab.tab_minimize_button.color_factor_text = 1.0f;
style->tab.tab_minimize_button.color_factor_background = 1.0f;
style->text.color_factor = 1.0f;
}
@ -24060,14 +24100,14 @@ nk_draw_button(struct nk_command_buffer *out,
switch (background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor_background));
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor_background));
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, *bounds, style->rounding, nk_rgb_factor(background->data.color, style->color_factor));
nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor));
nk_fill_rect(out, *bounds, style->rounding, nk_rgb_factor(background->data.color, style->color_factor_background));
nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor_background));
break;
}
return background;
@ -24117,7 +24157,7 @@ nk_draw_button_text(struct nk_command_buffer *out,
text.text = style->text_active;
else text.text = style->text_normal;
text.text = nk_rgb_factor(text.text, style->color_factor);
text.text = nk_rgb_factor(text.text, style->color_factor_text);
text.padding = nk_vec2(0,0);
nk_widget_text(out, *content, txt, len, &text, text_alignment, font);
@ -24167,7 +24207,7 @@ nk_draw_button_symbol(struct nk_command_buffer *out,
sym = style->text_active;
else sym = style->text_normal;
sym = nk_rgb_factor(sym, style->color_factor);
sym = nk_rgb_factor(sym, style->color_factor_text);
nk_draw_symbol(out, type, *content, bg, sym, 1, font);
}
NK_LIB nk_bool
@ -24199,7 +24239,7 @@ nk_draw_button_image(struct nk_command_buffer *out,
nk_flags state, const struct nk_style_button *style, const struct nk_image *img)
{
nk_draw_button(out, bounds, state, style);
nk_draw_image(out, *content, img, nk_rgb_factor(nk_white, style->color_factor));
nk_draw_image(out, *content, img, nk_rgb_factor(nk_white, style->color_factor_background));
}
NK_LIB nk_bool
nk_do_button_image(nk_flags *state,
@ -24256,8 +24296,8 @@ nk_draw_button_text_symbol(struct nk_command_buffer *out,
text.text = style->text_normal;
}
sym = nk_rgb_factor(sym, style->color_factor);
text.text = nk_rgb_factor(text.text, style->color_factor);
sym = nk_rgb_factor(sym, style->color_factor_text);
text.text = nk_rgb_factor(text.text, style->color_factor_text);
text.padding = nk_vec2(0,0);
nk_draw_symbol(out, type, *symbol, style->text_background, sym, 0, font);
nk_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font);
@ -24315,10 +24355,10 @@ nk_draw_button_text_image(struct nk_command_buffer *out,
text.text = style->text_active;
else text.text = style->text_normal;
text.text = nk_rgb_factor(text.text, style->color_factor);
text.text = nk_rgb_factor(text.text, style->color_factor_text);
text.padding = nk_vec2(0, 0);
nk_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font);
nk_draw_image(out, *image, img, nk_rgb_factor(nk_white, style->color_factor));
nk_draw_image(out, *image, img, nk_rgb_factor(nk_white, style->color_factor_background));
}
NK_LIB nk_bool
nk_do_button_text_image(nk_flags *state,

View File

@ -4697,6 +4697,7 @@ struct nk_style_button {
struct nk_style_item hover;
struct nk_style_item active;
struct nk_color border_color;
float color_factor_background;
/* text */
struct nk_color text_background;
@ -4704,6 +4705,7 @@ struct nk_style_button {
struct nk_color text_hover;
struct nk_color text_active;
nk_flags text_alignment;
float color_factor_text;
/* properties */
float border;
@ -4711,7 +4713,6 @@ struct nk_style_button {
struct nk_vec2 padding;
struct nk_vec2 image_padding;
struct nk_vec2 touch_padding;
float color_factor;
float disabled_factor;
/* optional user callbacks */

View File

@ -100,14 +100,14 @@ nk_draw_button(struct nk_command_buffer *out,
switch (background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor_background));
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor_background));
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, *bounds, style->rounding, nk_rgb_factor(background->data.color, style->color_factor));
nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor));
nk_fill_rect(out, *bounds, style->rounding, nk_rgb_factor(background->data.color, style->color_factor_background));
nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor_background));
break;
}
return background;
@ -157,7 +157,7 @@ nk_draw_button_text(struct nk_command_buffer *out,
text.text = style->text_active;
else text.text = style->text_normal;
text.text = nk_rgb_factor(text.text, style->color_factor);
text.text = nk_rgb_factor(text.text, style->color_factor_text);
text.padding = nk_vec2(0,0);
nk_widget_text(out, *content, txt, len, &text, text_alignment, font);
@ -207,7 +207,7 @@ nk_draw_button_symbol(struct nk_command_buffer *out,
sym = style->text_active;
else sym = style->text_normal;
sym = nk_rgb_factor(sym, style->color_factor);
sym = nk_rgb_factor(sym, style->color_factor_text);
nk_draw_symbol(out, type, *content, bg, sym, 1, font);
}
NK_LIB nk_bool
@ -239,7 +239,7 @@ nk_draw_button_image(struct nk_command_buffer *out,
nk_flags state, const struct nk_style_button *style, const struct nk_image *img)
{
nk_draw_button(out, bounds, state, style);
nk_draw_image(out, *content, img, nk_rgb_factor(nk_white, style->color_factor));
nk_draw_image(out, *content, img, nk_rgb_factor(nk_white, style->color_factor_background));
}
NK_LIB nk_bool
nk_do_button_image(nk_flags *state,
@ -296,8 +296,8 @@ nk_draw_button_text_symbol(struct nk_command_buffer *out,
text.text = style->text_normal;
}
sym = nk_rgb_factor(sym, style->color_factor);
text.text = nk_rgb_factor(text.text, style->color_factor);
sym = nk_rgb_factor(sym, style->color_factor_text);
text.text = nk_rgb_factor(text.text, style->color_factor_text);
text.padding = nk_vec2(0,0);
nk_draw_symbol(out, type, *symbol, style->text_background, sym, 0, font);
nk_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font);
@ -355,10 +355,10 @@ nk_draw_button_text_image(struct nk_command_buffer *out,
text.text = style->text_active;
else text.text = style->text_normal;
text.text = nk_rgb_factor(text.text, style->color_factor);
text.text = nk_rgb_factor(text.text, style->color_factor_text);
text.padding = nk_vec2(0, 0);
nk_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font);
nk_draw_image(out, *image, img, nk_rgb_factor(nk_white, style->color_factor));
nk_draw_image(out, *image, img, nk_rgb_factor(nk_white, style->color_factor_background));
}
NK_LIB nk_bool
nk_do_button_text_image(nk_flags *state,

View File

@ -119,25 +119,26 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
/* default button */
button = &style->button;
nk_zero_struct(*button);
button->normal = nk_style_item_color(table[NK_COLOR_BUTTON]);
button->hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]);
button->active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]);
button->border_color = table[NK_COLOR_BORDER];
button->text_background = table[NK_COLOR_BUTTON];
button->text_normal = table[NK_COLOR_TEXT];
button->text_hover = table[NK_COLOR_TEXT];
button->text_active = table[NK_COLOR_TEXT];
button->padding = nk_vec2(2.0f,2.0f);
button->image_padding = nk_vec2(0.0f,0.0f);
button->touch_padding = nk_vec2(0.0f, 0.0f);
button->userdata = nk_handle_ptr(0);
button->text_alignment = NK_TEXT_CENTERED;
button->border = 1.0f;
button->rounding = 4.0f;
button->color_factor = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
button->normal = nk_style_item_color(table[NK_COLOR_BUTTON]);
button->hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]);
button->active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]);
button->border_color = table[NK_COLOR_BORDER];
button->text_background = table[NK_COLOR_BUTTON];
button->text_normal = table[NK_COLOR_TEXT];
button->text_hover = table[NK_COLOR_TEXT];
button->text_active = table[NK_COLOR_TEXT];
button->padding = nk_vec2(2.0f,2.0f);
button->image_padding = nk_vec2(0.0f,0.0f);
button->touch_padding = nk_vec2(0.0f, 0.0f);
button->userdata = nk_handle_ptr(0);
button->text_alignment = NK_TEXT_CENTERED;
button->border = 1.0f;
button->rounding = 4.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
/* contextual button */
button = &style->contextual_button;
@ -156,7 +157,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -178,7 +180,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 1.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -293,7 +296,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 1.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -363,7 +367,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 1.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -437,7 +442,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -518,7 +524,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -555,7 +562,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -578,7 +586,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -617,7 +626,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;
@ -639,7 +649,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
button->text_alignment = NK_TEXT_CENTERED;
button->border = 0.0f;
button->rounding = 0.0f;
button->color_factor = 1.0f;
button->color_factor_text = 1.0f;
button->color_factor_background = 1.0f;
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
button->draw_begin = 0;
button->draw_end = 0;

View File

@ -246,36 +246,50 @@ nk_widget_disable_begin(struct nk_context* ctx)
win->widgets_disabled = nk_true;
style->button.color_factor = style->button.disabled_factor;
style->button.color_factor_text = style->button.disabled_factor;
style->button.color_factor_background = style->button.disabled_factor;
style->chart.color_factor = style->chart.disabled_factor;
style->checkbox.color_factor = style->checkbox.disabled_factor;
style->combo.color_factor = style->combo.disabled_factor;
style->combo.button.color_factor = style->combo.button.disabled_factor;
style->contextual_button.color_factor = style->contextual_button.disabled_factor;
style->combo.button.color_factor_text = style->combo.button.disabled_factor;
style->combo.button.color_factor_background = style->combo.button.disabled_factor;
style->contextual_button.color_factor_text = style->contextual_button.disabled_factor;
style->contextual_button.color_factor_background = style->contextual_button.disabled_factor;
style->edit.color_factor = style->edit.disabled_factor;
style->edit.scrollbar.color_factor = style->edit.scrollbar.disabled_factor;
style->menu_button.color_factor = style->menu_button.disabled_factor;
style->menu_button.color_factor_text = style->menu_button.disabled_factor;
style->menu_button.color_factor_background = style->menu_button.disabled_factor;
style->option.color_factor = style->option.disabled_factor;
style->progress.color_factor = style->progress.disabled_factor;
style->property.color_factor = style->property.disabled_factor;
style->property.inc_button.color_factor = style->property.inc_button.disabled_factor;
style->property.dec_button.color_factor = style->property.dec_button.disabled_factor;
style->property.inc_button.color_factor_text = style->property.inc_button.disabled_factor;
style->property.inc_button.color_factor_background = style->property.inc_button.disabled_factor;
style->property.dec_button.color_factor_text = style->property.dec_button.disabled_factor;
style->property.dec_button.color_factor_background = style->property.dec_button.disabled_factor;
style->property.edit.color_factor = style->property.edit.disabled_factor;
style->scrollh.color_factor = style->scrollh.disabled_factor;
style->scrollh.inc_button.color_factor = style->scrollh.inc_button.disabled_factor;
style->scrollh.dec_button.color_factor = style->scrollh.dec_button.disabled_factor;
style->scrollh.inc_button.color_factor_text = style->scrollh.inc_button.disabled_factor;
style->scrollh.inc_button.color_factor_background = style->scrollh.inc_button.disabled_factor;
style->scrollh.dec_button.color_factor_text = style->scrollh.dec_button.disabled_factor;
style->scrollh.dec_button.color_factor_background = style->scrollh.dec_button.disabled_factor;
style->scrollv.color_factor = style->scrollv.disabled_factor;
style->scrollv.inc_button.color_factor = style->scrollv.inc_button.disabled_factor;
style->scrollv.dec_button.color_factor = style->scrollv.dec_button.disabled_factor;
style->scrollv.inc_button.color_factor_text = style->scrollv.inc_button.disabled_factor;
style->scrollv.inc_button.color_factor_background = style->scrollv.inc_button.disabled_factor;
style->scrollv.dec_button.color_factor_text = style->scrollv.dec_button.disabled_factor;
style->scrollv.dec_button.color_factor_background = style->scrollv.dec_button.disabled_factor;
style->selectable.color_factor = style->selectable.disabled_factor;
style->slider.color_factor = style->slider.disabled_factor;
style->slider.inc_button.color_factor = style->slider.inc_button.disabled_factor;
style->slider.dec_button.color_factor = style->slider.dec_button.disabled_factor;
style->slider.inc_button.color_factor_text = style->slider.inc_button.disabled_factor;
style->slider.inc_button.color_factor_background = style->slider.inc_button.disabled_factor;
style->slider.dec_button.color_factor_text = style->slider.dec_button.disabled_factor;
style->slider.dec_button.color_factor_background = style->slider.dec_button.disabled_factor;
style->tab.color_factor = style->tab.disabled_factor;
style->tab.node_maximize_button.color_factor = style->tab.node_maximize_button.disabled_factor;
style->tab.node_minimize_button.color_factor = style->tab.node_minimize_button.disabled_factor;
style->tab.tab_maximize_button.color_factor = style->tab.tab_maximize_button.disabled_factor;
style->tab.tab_minimize_button.color_factor = style->tab.tab_minimize_button.disabled_factor;
style->tab.node_maximize_button.color_factor_text = style->tab.node_maximize_button.disabled_factor;
style->tab.node_minimize_button.color_factor_text = style->tab.node_minimize_button.disabled_factor;
style->tab.tab_maximize_button.color_factor_text = style->tab.tab_maximize_button.disabled_factor;
style->tab.tab_maximize_button.color_factor_background = style->tab.tab_maximize_button.disabled_factor;
style->tab.tab_minimize_button.color_factor_text = style->tab.tab_minimize_button.disabled_factor;
style->tab.tab_minimize_button.color_factor_background = style->tab.tab_minimize_button.disabled_factor;
style->text.color_factor = style->text.disabled_factor;
}
NK_API void
@ -295,35 +309,49 @@ nk_widget_disable_end(struct nk_context* ctx)
win->widgets_disabled = nk_false;
style->button.color_factor = 1.0f;
style->button.color_factor_text = 1.0f;
style->button.color_factor_background = 1.0f;
style->chart.color_factor = 1.0f;
style->checkbox.color_factor = 1.0f;
style->combo.color_factor = 1.0f;
style->combo.button.color_factor = 1.0f;
style->contextual_button.color_factor = 1.0f;
style->combo.button.color_factor_text = 1.0f;
style->combo.button.color_factor_background = 1.0f;
style->contextual_button.color_factor_text = 1.0f;
style->contextual_button.color_factor_background = 1.0f;
style->edit.color_factor = 1.0f;
style->edit.scrollbar.color_factor = 1.0f;
style->menu_button.color_factor = 1.0f;
style->menu_button.color_factor_text = 1.0f;
style->menu_button.color_factor_background = 1.0f;
style->option.color_factor = 1.0f;
style->progress.color_factor = 1.0f;
style->property.color_factor = 1.0f;
style->property.inc_button.color_factor = 1.0f;
style->property.dec_button.color_factor = 1.0f;
style->property.inc_button.color_factor_text = 1.0f;
style->property.inc_button.color_factor_background = 1.0f;
style->property.dec_button.color_factor_text = 1.0f;
style->property.dec_button.color_factor_background = 1.0f;
style->property.edit.color_factor = 1.0f;
style->scrollh.color_factor = 1.0f;
style->scrollh.inc_button.color_factor = 1.0f;
style->scrollh.dec_button.color_factor = 1.0f;
style->scrollh.inc_button.color_factor_text = 1.0f;
style->scrollh.inc_button.color_factor_background = 1.0f;
style->scrollh.dec_button.color_factor_text = 1.0f;
style->scrollh.dec_button.color_factor_background = 1.0f;
style->scrollv.color_factor = 1.0f;
style->scrollv.inc_button.color_factor = 1.0f;
style->scrollv.dec_button.color_factor = 1.0f;
style->scrollv.inc_button.color_factor_text = 1.0f;
style->scrollv.inc_button.color_factor_background = 1.0f;
style->scrollv.dec_button.color_factor_text = 1.0f;
style->scrollv.dec_button.color_factor_background = 1.0f;
style->selectable.color_factor = 1.0f;
style->slider.color_factor = 1.0f;
style->slider.inc_button.color_factor = 1.0f;
style->slider.dec_button.color_factor = 1.0f;
style->slider.inc_button.color_factor_text = 1.0f;
style->slider.inc_button.color_factor_background = 1.0f;
style->slider.dec_button.color_factor_text = 1.0f;
style->slider.dec_button.color_factor_background = 1.0f;
style->tab.color_factor = 1.0f;
style->tab.node_maximize_button.color_factor = 1.0f;
style->tab.node_minimize_button.color_factor = 1.0f;
style->tab.tab_maximize_button.color_factor = 1.0f;
style->tab.tab_minimize_button.color_factor = 1.0f;
style->tab.node_maximize_button.color_factor_text = 1.0f;
style->tab.node_minimize_button.color_factor_text = 1.0f;
style->tab.tab_maximize_button.color_factor_text = 1.0f;
style->tab.tab_maximize_button.color_factor_background = 1.0f;
style->tab.tab_minimize_button.color_factor_text = 1.0f;
style->tab.tab_minimize_button.color_factor_background = 1.0f;
style->text.color_factor = 1.0f;
}