Merge branch 'master' of github.com:Immediate-Mode-UI/Nuklear into patch-1
This commit is contained in:
commit
b4e9e924cf
|
@ -8,14 +8,42 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v4
|
||||||
- name: apt-update
|
- name: apt-update
|
||||||
run: sudo apt-get update -qq
|
run: sudo apt-get update -qq
|
||||||
- name: apt get glfw
|
- name: apt get demo-libs
|
||||||
run: sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libglew-dev
|
run: sudo apt-get install -y --no-install-recommends liballegro5-dev liballegro-image5-dev liballegro-ttf5-dev libglfw3 libglfw3-dev libglew-dev libsdl2-dev libwayland-dev libx11-dev libxft-dev wayland-protocols
|
||||||
- name: build opengl2
|
- name: build allegro5
|
||||||
|
run: make -C demo/allegro5
|
||||||
|
- name: build glfw_opengl2
|
||||||
run: make -C demo/glfw_opengl2
|
run: make -C demo/glfw_opengl2
|
||||||
- name: build opengl3
|
- name: build glfw_opengl3
|
||||||
run: make -C demo/glfw_opengl3
|
run: make -C demo/glfw_opengl3
|
||||||
|
- name: build glfw_opengl4
|
||||||
|
run: make -C demo/glfw_opengl4
|
||||||
|
# - name: build glfw_vulkan
|
||||||
|
# run: make -C demo/glfw_vulkan
|
||||||
|
- name: build sdl_opengl2
|
||||||
|
run: make -C demo/sdl_opengl2
|
||||||
|
- name: build sdl_opengl3
|
||||||
|
run: make -C demo/sdl_opengl3
|
||||||
|
- name: build sdl_opengles2
|
||||||
|
run: make -C demo/sdl_opengles2
|
||||||
|
- name: build sdl_renderer
|
||||||
|
run: make -C demo/sdl_renderer
|
||||||
|
- name: build sdl2surface_rawfb
|
||||||
|
run: make -C demo/sdl2surface_rawfb
|
||||||
|
- name: build wayland_rawfb
|
||||||
|
run: make -C demo/wayland_rawfb
|
||||||
|
- name: build x11
|
||||||
|
run: make -C demo/x11
|
||||||
|
- name: build x11_opengl2
|
||||||
|
run: make -C demo/x11_opengl2
|
||||||
|
- name: build x11_opengl3
|
||||||
|
run: make -C demo/x11_opengl3
|
||||||
|
- name: build x11_rawfb
|
||||||
|
run: make -C demo/x11_rawfb
|
||||||
|
- name: build x11_xft
|
||||||
|
run: make -C demo/x11_xft
|
||||||
- name: build example
|
- name: build example
|
||||||
run: make -C example
|
run: make -C example
|
||||||
|
|
|
@ -9,8 +9,9 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
- uses: butlerlogic/action-autotag@stable
|
- uses: butlerlogic/action-autotag@1.1.2
|
||||||
with:
|
env:
|
||||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
with:
|
||||||
root: clib.json
|
root: clib.json
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "nuklear",
|
"name": "nuklear",
|
||||||
"version": "4.10.7",
|
"version": "4.12.2",
|
||||||
"repo": "Immediate-Mode-UI/Nuklear",
|
"repo": "Immediate-Mode-UI/Nuklear",
|
||||||
"description": "A small ANSI C gui toolkit",
|
"description": "A small ANSI C gui toolkit",
|
||||||
"keywords": ["gl", "ui", "toolkit"],
|
"keywords": ["gl", "ui", "toolkit"],
|
||||||
|
|
|
@ -46,6 +46,7 @@ NK_API void nk_allegro5_font_set_font(NkAllegro5Font *font);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_ALLEGRO5_IMPLEMENTATION
|
#ifdef NK_ALLEGRO5_IMPLEMENTATION
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifndef NK_ALLEGRO5_TEXT_MAX
|
#ifndef NK_ALLEGRO5_TEXT_MAX
|
||||||
#define NK_ALLEGRO5_TEXT_MAX 256
|
#define NK_ALLEGRO5_TEXT_MAX 256
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,16 +2,18 @@ static int
|
||||||
overview(struct nk_context *ctx)
|
overview(struct nk_context *ctx)
|
||||||
{
|
{
|
||||||
/* window flags */
|
/* 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;
|
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;
|
nk_flags actual_window_flags;
|
||||||
|
|
||||||
/* popups */
|
/* popups */
|
||||||
static enum nk_style_header_align header_align = NK_HEADER_RIGHT;
|
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;
|
ctx->style.window.header.align = header_align;
|
||||||
|
|
||||||
|
static nk_bool disable_widgets = nk_false;
|
||||||
|
|
||||||
actual_window_flags = window_flags;
|
actual_window_flags = window_flags;
|
||||||
if (!(actual_window_flags & NK_WINDOW_TITLE))
|
if (!(actual_window_flags & NK_WINDOW_TITLE))
|
||||||
actual_window_flags &= ~(NK_WINDOW_MINIMIZABLE|NK_WINDOW_CLOSABLE);
|
actual_window_flags &= ~(NK_WINDOW_MINIMIZABLE|NK_WINDOW_CLOSABLE);
|
||||||
|
@ -23,7 +25,7 @@ overview(struct nk_context *ctx)
|
||||||
enum menu_states {MENU_DEFAULT, MENU_WINDOWS};
|
enum menu_states {MENU_DEFAULT, MENU_WINDOWS};
|
||||||
static nk_size mprog = 60;
|
static nk_size mprog = 60;
|
||||||
static int mslider = 10;
|
static int mslider = 10;
|
||||||
static int mcheck = nk_true;
|
static nk_bool mcheck = nk_true;
|
||||||
nk_menubar_begin(ctx);
|
nk_menubar_begin(ctx);
|
||||||
|
|
||||||
/* menu #1 */
|
/* menu #1 */
|
||||||
|
@ -33,7 +35,7 @@ overview(struct nk_context *ctx)
|
||||||
{
|
{
|
||||||
static size_t prog = 40;
|
static size_t prog = 40;
|
||||||
static int slider = 10;
|
static int slider = 10;
|
||||||
static int check = nk_true;
|
static nk_bool check = nk_true;
|
||||||
nk_layout_row_dynamic(ctx, 25, 1);
|
nk_layout_row_dynamic(ctx, 25, 1);
|
||||||
if (nk_menu_item_label(ctx, "Hide", NK_TEXT_LEFT))
|
if (nk_menu_item_label(ctx, "Hide", NK_TEXT_LEFT))
|
||||||
show_menu = nk_false;
|
show_menu = nk_false;
|
||||||
|
@ -129,14 +131,22 @@ overview(struct nk_context *ctx)
|
||||||
nk_checkbox_flags_label(ctx, "No Scrollbar", &window_flags, NK_WINDOW_NO_SCROLLBAR);
|
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, "Minimizable", &window_flags, NK_WINDOW_MINIMIZABLE);
|
||||||
nk_checkbox_flags_label(ctx, "Scale Left", &window_flags, NK_WINDOW_SCALE_LEFT);
|
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);
|
nk_tree_pop(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (disable_widgets)
|
||||||
|
nk_widget_disable_begin(ctx);
|
||||||
|
|
||||||
if (nk_tree_push(ctx, NK_TREE_TAB, "Widgets", NK_MINIMIZED))
|
if (nk_tree_push(ctx, NK_TREE_TAB, "Widgets", NK_MINIMIZED))
|
||||||
{
|
{
|
||||||
enum options {A,B,C};
|
enum options {A,B,C};
|
||||||
static int checkbox;
|
static nk_bool checkbox_left_text_left;
|
||||||
static int option;
|
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))
|
if (nk_tree_push(ctx, NK_TREE_NODE, "Text", NK_MINIMIZED))
|
||||||
{
|
{
|
||||||
/* Text Widgets */
|
/* Text Widgets */
|
||||||
|
@ -180,6 +190,7 @@ overview(struct nk_context *ctx)
|
||||||
nk_layout_row_static(ctx, 30, 100, 2);
|
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_LEFT, "prev", NK_TEXT_RIGHT);
|
||||||
nk_button_symbol_label(ctx, NK_SYMBOL_TRIANGLE_RIGHT, "next", NK_TEXT_LEFT);
|
nk_button_symbol_label(ctx, NK_SYMBOL_TRIANGLE_RIGHT, "next", NK_TEXT_LEFT);
|
||||||
|
|
||||||
nk_tree_pop(ctx);
|
nk_tree_pop(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,13 +212,21 @@ overview(struct nk_context *ctx)
|
||||||
static int range_int_max = 4096;
|
static int range_int_max = 4096;
|
||||||
static const float ratio[] = {120, 150};
|
static const float ratio[] = {120, 150};
|
||||||
|
|
||||||
nk_layout_row_static(ctx, 30, 100, 1);
|
nk_layout_row_dynamic(ctx, 0, 1);
|
||||||
nk_checkbox_label(ctx, "Checkbox", &checkbox);
|
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);
|
nk_layout_row_static(ctx, 30, 80, 3);
|
||||||
option = nk_option_label(ctx, "optionA", option == A) ? A : option;
|
option_left = nk_option_label(ctx, "optionA", option_left == A) ? A : option_left;
|
||||||
option = nk_option_label(ctx, "optionB", option == B) ? B : option;
|
option_left = nk_option_label(ctx, "optionB", option_left == B) ? B : option_left;
|
||||||
option = nk_option_label(ctx, "optionC", option == C) ? C : option;
|
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_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_layout_row(ctx, NK_STATIC, 30, 2, ratio);
|
||||||
nk_labelf(ctx, NK_TEXT_LEFT, "Slider int");
|
nk_labelf(ctx, NK_TEXT_LEFT, "Slider int");
|
||||||
|
@ -242,35 +261,28 @@ overview(struct nk_context *ctx)
|
||||||
|
|
||||||
if (nk_tree_push(ctx, NK_TREE_NODE, "Inactive", NK_MINIMIZED))
|
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_layout_row_dynamic(ctx, 30, 1);
|
||||||
nk_checkbox_label(ctx, "Inactive", &inactive);
|
nk_checkbox_label(ctx, "Inactive", &inactive);
|
||||||
|
|
||||||
nk_layout_row_static(ctx, 30, 80, 1);
|
nk_layout_row_static(ctx, 30, 80, 1);
|
||||||
if (inactive) {
|
if (inactive) {
|
||||||
struct nk_style_button button;
|
nk_widget_disable_begin(ctx);
|
||||||
button = ctx->style.button;
|
}
|
||||||
ctx->style.button.normal = nk_style_item_color(nk_rgb(40,40,40));
|
|
||||||
ctx->style.button.hover = nk_style_item_color(nk_rgb(40,40,40));
|
if (nk_button_label(ctx, "button"))
|
||||||
ctx->style.button.active = nk_style_item_color(nk_rgb(40,40,40));
|
|
||||||
ctx->style.button.border_color = nk_rgb(60,60,60);
|
|
||||||
ctx->style.button.text_background = nk_rgb(60,60,60);
|
|
||||||
ctx->style.button.text_normal = nk_rgb(60,60,60);
|
|
||||||
ctx->style.button.text_hover = nk_rgb(60,60,60);
|
|
||||||
ctx->style.button.text_active = nk_rgb(60,60,60);
|
|
||||||
nk_button_label(ctx, "button");
|
|
||||||
ctx->style.button = button;
|
|
||||||
} else if (nk_button_label(ctx, "button"))
|
|
||||||
fprintf(stdout, "button pressed\n");
|
fprintf(stdout, "button pressed\n");
|
||||||
|
|
||||||
|
nk_widget_disable_end(ctx);
|
||||||
|
|
||||||
nk_tree_pop(ctx);
|
nk_tree_pop(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (nk_tree_push(ctx, NK_TREE_NODE, "Selectable", NK_MINIMIZED))
|
if (nk_tree_push(ctx, NK_TREE_NODE, "Selectable", NK_MINIMIZED))
|
||||||
{
|
{
|
||||||
if (nk_tree_push(ctx, NK_TREE_NODE, "List", NK_MINIMIZED))
|
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_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[0]);
|
||||||
nk_selectable_label(ctx, "Selectable", NK_TEXT_LEFT, &selected[1]);
|
nk_selectable_label(ctx, "Selectable", NK_TEXT_LEFT, &selected[1]);
|
||||||
|
@ -282,7 +294,7 @@ overview(struct nk_context *ctx)
|
||||||
if (nk_tree_push(ctx, NK_TREE_NODE, "Grid", NK_MINIMIZED))
|
if (nk_tree_push(ctx, NK_TREE_NODE, "Grid", NK_MINIMIZED))
|
||||||
{
|
{
|
||||||
int i;
|
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);
|
nk_layout_row_static(ctx, 50, 50, 4);
|
||||||
for (i = 0; i < 16; ++i) {
|
for (i = 0; i < 16; ++i) {
|
||||||
if (nk_selectable_label(ctx, "Z", NK_TEXT_CENTERED, &selected[i])) {
|
if (nk_selectable_label(ctx, "Z", NK_TEXT_CENTERED, &selected[i])) {
|
||||||
|
@ -329,7 +341,7 @@ overview(struct nk_context *ctx)
|
||||||
*/
|
*/
|
||||||
static float chart_selection = 8.0f;
|
static float chart_selection = 8.0f;
|
||||||
static int current_weapon = 0;
|
static int current_weapon = 0;
|
||||||
static int check_values[5];
|
static nk_bool check_values[5];
|
||||||
static float position[3];
|
static float position[3];
|
||||||
static struct nk_color combo_color = {130, 50, 50, 255};
|
static struct nk_color combo_color = {130, 50, 50, 255};
|
||||||
static struct nk_colorf combo_color2 = {0.509f, 0.705f, 0.2f, 1.0f};
|
static struct nk_colorf combo_color2 = {0.509f, 0.705f, 0.2f, 1.0f};
|
||||||
|
@ -590,7 +602,7 @@ overview(struct nk_context *ctx)
|
||||||
}
|
}
|
||||||
nk_tree_pop(ctx);
|
nk_tree_pop(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nk_tree_push(ctx, NK_TREE_NODE, "Horizontal Rule", NK_MINIMIZED))
|
if (nk_tree_push(ctx, NK_TREE_NODE, "Horizontal Rule", NK_MINIMIZED))
|
||||||
{
|
{
|
||||||
nk_layout_row_dynamic(ctx, 12, 1);
|
nk_layout_row_dynamic(ctx, 12, 1);
|
||||||
|
@ -620,6 +632,7 @@ overview(struct nk_context *ctx)
|
||||||
float id = 0;
|
float id = 0;
|
||||||
static int col_index = -1;
|
static int col_index = -1;
|
||||||
static int line_index = -1;
|
static int line_index = -1;
|
||||||
|
static int show_markers = nk_true;
|
||||||
float step = (2*3.141592654f) / 32;
|
float step = (2*3.141592654f) / 32;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
@ -628,7 +641,10 @@ overview(struct nk_context *ctx)
|
||||||
/* line chart */
|
/* line chart */
|
||||||
id = 0;
|
id = 0;
|
||||||
index = -1;
|
index = -1;
|
||||||
|
nk_layout_row_dynamic(ctx, 15, 1);
|
||||||
|
nk_checkbox_label(ctx, "Show markers", &show_markers);
|
||||||
nk_layout_row_dynamic(ctx, 100, 1);
|
nk_layout_row_dynamic(ctx, 100, 1);
|
||||||
|
ctx->style.chart.show_markers = show_markers;
|
||||||
if (nk_chart_begin(ctx, NK_CHART_LINES, 32, -1.0f, 1.0f)) {
|
if (nk_chart_begin(ctx, NK_CHART_LINES, 32, -1.0f, 1.0f)) {
|
||||||
for (i = 0; i < 32; ++i) {
|
for (i = 0; i < 32; ++i) {
|
||||||
nk_flags res = nk_chart_push(ctx, (float)cos(id));
|
nk_flags res = nk_chart_push(ctx, (float)cos(id));
|
||||||
|
@ -701,8 +717,8 @@ overview(struct nk_context *ctx)
|
||||||
if (nk_tree_push(ctx, NK_TREE_TAB, "Popup", NK_MINIMIZED))
|
if (nk_tree_push(ctx, NK_TREE_TAB, "Popup", NK_MINIMIZED))
|
||||||
{
|
{
|
||||||
static struct nk_color color = {255,0,0, 255};
|
static struct nk_color color = {255,0,0, 255};
|
||||||
static int select[4];
|
static nk_bool select[4];
|
||||||
static int popup_active;
|
static nk_bool popup_active;
|
||||||
const struct nk_input *in = &ctx->input;
|
const struct nk_input *in = &ctx->input;
|
||||||
struct nk_rect bounds;
|
struct nk_rect bounds;
|
||||||
|
|
||||||
|
@ -871,9 +887,9 @@ overview(struct nk_context *ctx)
|
||||||
|
|
||||||
if (nk_tree_push(ctx, NK_TREE_NODE, "Group", NK_MINIMIZED))
|
if (nk_tree_push(ctx, NK_TREE_NODE, "Group", NK_MINIMIZED))
|
||||||
{
|
{
|
||||||
static int group_titlebar = nk_false;
|
static nk_bool group_titlebar = nk_false;
|
||||||
static int group_border = nk_true;
|
static nk_bool group_border = nk_true;
|
||||||
static int group_no_scrollbar = nk_false;
|
static nk_bool group_no_scrollbar = nk_false;
|
||||||
static int group_width = 320;
|
static int group_width = 320;
|
||||||
static int group_height = 200;
|
static int group_height = 200;
|
||||||
|
|
||||||
|
@ -899,7 +915,7 @@ overview(struct nk_context *ctx)
|
||||||
nk_layout_row_static(ctx, (float)group_height, group_width, 2);
|
nk_layout_row_static(ctx, (float)group_height, group_width, 2);
|
||||||
if (nk_group_begin(ctx, "Group", group_flags)) {
|
if (nk_group_begin(ctx, "Group", group_flags)) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
static int selected[16];
|
static nk_bool selected[16];
|
||||||
nk_layout_row_static(ctx, 18, 100, 1);
|
nk_layout_row_static(ctx, 18, 100, 1);
|
||||||
for (i = 0; i < 16; ++i)
|
for (i = 0; i < 16; ++i)
|
||||||
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
|
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
|
||||||
|
@ -909,11 +925,12 @@ overview(struct nk_context *ctx)
|
||||||
}
|
}
|
||||||
if (nk_tree_push(ctx, NK_TREE_NODE, "Tree", NK_MINIMIZED))
|
if (nk_tree_push(ctx, NK_TREE_NODE, "Tree", NK_MINIMIZED))
|
||||||
{
|
{
|
||||||
static int root_selected = 0;
|
static nk_bool root_selected = 0;
|
||||||
int sel = root_selected;
|
nk_bool sel = root_selected;
|
||||||
if (nk_tree_element_push(ctx, NK_TREE_NODE, "Root", NK_MINIMIZED, &sel)) {
|
if (nk_tree_element_push(ctx, NK_TREE_NODE, "Root", NK_MINIMIZED, &sel)) {
|
||||||
static int selected[8];
|
static nk_bool selected[8];
|
||||||
int i = 0, node_select = selected[0];
|
int i = 0;
|
||||||
|
nk_bool node_select = selected[0];
|
||||||
if (sel != root_selected) {
|
if (sel != root_selected) {
|
||||||
root_selected = sel;
|
root_selected = sel;
|
||||||
for (i = 0; i < 8; ++i)
|
for (i = 0; i < 8; ++i)
|
||||||
|
@ -921,7 +938,7 @@ overview(struct nk_context *ctx)
|
||||||
}
|
}
|
||||||
if (nk_tree_element_push(ctx, NK_TREE_NODE, "Node", NK_MINIMIZED, &node_select)) {
|
if (nk_tree_element_push(ctx, NK_TREE_NODE, "Node", NK_MINIMIZED, &node_select)) {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
static int sel_nodes[4];
|
static nk_bool sel_nodes[4];
|
||||||
if (node_select != selected[0]) {
|
if (node_select != selected[0]) {
|
||||||
selected[0] = node_select;
|
selected[0] = node_select;
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
|
@ -1049,7 +1066,7 @@ overview(struct nk_context *ctx)
|
||||||
nk_layout_space_begin(ctx, NK_STATIC, 500, 64);
|
nk_layout_space_begin(ctx, NK_STATIC, 500, 64);
|
||||||
nk_layout_space_push(ctx, nk_rect(0,0,150,500));
|
nk_layout_space_push(ctx, nk_rect(0,0,150,500));
|
||||||
if (nk_group_begin(ctx, "Group_left", NK_WINDOW_BORDER)) {
|
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);
|
nk_layout_row_static(ctx, 18, 100, 1);
|
||||||
for (i = 0; i < 32; ++i)
|
for (i = 0; i < 32; ++i)
|
||||||
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
|
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
|
||||||
|
@ -1082,7 +1099,7 @@ overview(struct nk_context *ctx)
|
||||||
|
|
||||||
nk_layout_space_push(ctx, nk_rect(320,0,150,150));
|
nk_layout_space_push(ctx, nk_rect(320,0,150,150));
|
||||||
if (nk_group_begin(ctx, "Group_right_top", NK_WINDOW_BORDER)) {
|
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);
|
nk_layout_row_static(ctx, 18, 100, 1);
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
|
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
|
||||||
|
@ -1091,7 +1108,7 @@ overview(struct nk_context *ctx)
|
||||||
|
|
||||||
nk_layout_space_push(ctx, nk_rect(320,160,150,150));
|
nk_layout_space_push(ctx, nk_rect(320,160,150,150));
|
||||||
if (nk_group_begin(ctx, "Group_right_center", NK_WINDOW_BORDER)) {
|
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);
|
nk_layout_row_static(ctx, 18, 100, 1);
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
|
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
|
||||||
|
@ -1100,7 +1117,7 @@ overview(struct nk_context *ctx)
|
||||||
|
|
||||||
nk_layout_space_push(ctx, nk_rect(320,320,150,150));
|
nk_layout_space_push(ctx, nk_rect(320,320,150,150));
|
||||||
if (nk_group_begin(ctx, "Group_right_bottom", NK_WINDOW_BORDER)) {
|
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);
|
nk_layout_row_static(ctx, 18, 100, 1);
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
|
nk_selectable_label(ctx, (selected[i]) ? "Selected": "Unselected", NK_TEXT_CENTERED, &selected[i]);
|
||||||
|
@ -1289,8 +1306,9 @@ overview(struct nk_context *ctx)
|
||||||
}
|
}
|
||||||
nk_tree_pop(ctx);
|
nk_tree_pop(ctx);
|
||||||
}
|
}
|
||||||
|
if (disable_widgets)
|
||||||
|
nk_widget_disable_end(ctx);
|
||||||
}
|
}
|
||||||
nk_end(ctx);
|
nk_end(ctx);
|
||||||
return !nk_window_is_closed(ctx, "Overview");
|
return !nk_window_is_closed(ctx, "Overview");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ NK_API void nk_d3d11_shutdown(void);
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
#include <d3d11.h>
|
#include <d3d11.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
|
@ -88,6 +88,7 @@ NK_API void nk_d3d12_shutdown(void);
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
#include <d3d12.h>
|
#include <d3d12.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
|
@ -41,6 +41,7 @@ NK_API void nk_d3d9_shutdown(void);
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ NK_API void nk_gdi_set_font(GdiFont *font);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_GDI_IMPLEMENTATION
|
#ifdef NK_GDI_IMPLEMENTATION
|
||||||
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ NK_API void nk_gdi_set_font(nk_gdi_ctx gdi, GdiFont* font);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_GDI_IMPLEMENTATION
|
#ifdef NK_GDI_IMPLEMENTATION
|
||||||
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,8 @@ NK_API void nk_gflw3_scroll_callback(GLFWwindow *win, double xof
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_GLFW_GL2_IMPLEMENTATION
|
#ifdef NK_GLFW_GL2_IMPLEMENTATION
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifndef NK_GLFW_TEXT_MAX
|
#ifndef NK_GLFW_TEXT_MAX
|
||||||
#define NK_GLFW_TEXT_MAX 256
|
#define NK_GLFW_TEXT_MAX 256
|
||||||
|
|
|
@ -78,6 +78,9 @@ NK_API void nk_glfw3_mouse_button_callback(GLFWwindow *win, int
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_GLFW_GL3_IMPLEMENTATION
|
#ifdef NK_GLFW_GL3_IMPLEMENTATION
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#ifndef NK_GLFW_DOUBLE_CLICK_LO
|
#ifndef NK_GLFW_DOUBLE_CLICK_LO
|
||||||
#define NK_GLFW_DOUBLE_CLICK_LO 0.02
|
#define NK_GLFW_DOUBLE_CLICK_LO 0.02
|
||||||
|
|
|
@ -50,6 +50,9 @@ NK_API void nk_glfw3_destroy_texture(int tex_index);
|
||||||
*/
|
*/
|
||||||
#ifdef NK_GLFW_GL4_IMPLEMENTATION
|
#ifdef NK_GLFW_GL4_IMPLEMENTATION
|
||||||
#undef NK_GLFW_GL4_IMPLEMENTATION
|
#undef NK_GLFW_GL4_IMPLEMENTATION
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#ifndef NK_GLFW_TEXT_MAX
|
#ifndef NK_GLFW_TEXT_MAX
|
||||||
#define NK_GLFW_TEXT_MAX 256
|
#define NK_GLFW_TEXT_MAX 256
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
# same as .editorconfig
|
||||||
|
IndentWidth: 4
|
|
@ -0,0 +1,3 @@
|
||||||
|
src/nuklearshaders/*.spv
|
||||||
|
src/nuklear_glfw_vulkan.h
|
||||||
|
shaders/*.spv
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Install
|
||||||
|
BIN = demo
|
||||||
|
|
||||||
|
# Flags
|
||||||
|
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
|
||||||
|
|
||||||
|
SRC = main.c
|
||||||
|
OBJ = $(SRC:.c=.o)
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
BIN := $(BIN).exe
|
||||||
|
LIBS = -lglfw3 -lvulkan -lm
|
||||||
|
else
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
GLFW3 := $(shell pkg-config --libs glfw3)
|
||||||
|
LIBS = $(GLFW3) -lvulkan -lm
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
$(BIN): shaders/demo.vert.spv shaders/demo.frag.spv
|
||||||
|
@mkdir -p bin
|
||||||
|
rm -f bin/$(BIN) $(OBJS)
|
||||||
|
$(CC) $(SRC) $(CFLAGS) -o bin/$(BIN) $(LIBS)
|
||||||
|
|
||||||
|
shaders/demo.vert.spv: shaders/demo.vert
|
||||||
|
glslc --target-env=vulkan shaders/demo.vert -o shaders/demo.vert.spv
|
||||||
|
|
||||||
|
shaders/demo.frag.spv: shaders/demo.frag
|
||||||
|
glslc --target-env=vulkan shaders/demo.frag -o shaders/demo.frag.spv
|
|
@ -0,0 +1,52 @@
|
||||||
|
# nuklear glfw vulkan
|
||||||
|
|
||||||
|
## Theory of operation
|
||||||
|
|
||||||
|
The nuklear glfw vulkan integration creates an independent graphics pipeline that will render the nuklear UI to separate render targets.
|
||||||
|
The application is responsible to fully manage these render targets. So it must ensure they are properly sized (and resized when requested).
|
||||||
|
|
||||||
|
Furthermore it is assumed that you will have a swap chain in place and the number of nuklear overlay images and number of swap chain images match.
|
||||||
|
|
||||||
|
This is how you can integrate it in your application:
|
||||||
|
|
||||||
|
```
|
||||||
|
/*
|
||||||
|
Setup: overlay_images have been created and their number match with the number
|
||||||
|
of the swap_chain_images of your application. The overlay_images in this
|
||||||
|
example have the same format as your swap_chain images (optional)
|
||||||
|
*/
|
||||||
|
struct nk_context *ctx = nk_glfw3_init(
|
||||||
|
demo.win, demo.device, demo.physical_device, demo.indices.graphics,
|
||||||
|
demo.overlay_image_views, demo.swap_chain_images_len,
|
||||||
|
demo.swap_chain_image_format, NK_GLFW3_INSTALL_CALLBACKS,
|
||||||
|
MAX_VERTEX_BUFFER, MAX_ELEMENT_BUFFER);
|
||||||
|
[...]
|
||||||
|
/*
|
||||||
|
in your draw loop draw you can then render to the overlay image at
|
||||||
|
`image_index`
|
||||||
|
your own application can then wait for the semaphore and produce
|
||||||
|
the swap_chain_image at `image_index`
|
||||||
|
this should simply sample from the overlay_image (see example)
|
||||||
|
*/
|
||||||
|
nk_semaphore semaphore =
|
||||||
|
nk_glfw3_render(demo.graphics_queue, image_index,
|
||||||
|
demo.image_available, NK_ANTI_ALIASING_ON);
|
||||||
|
if (!render(&demo, &bg, nk_semaphore, image_index)) {
|
||||||
|
fprintf(stderr, "render failed\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You must call `nk_glfw3_resize` whenever the size of the overlay_images resize.
|
||||||
|
|
||||||
|
## Using images
|
||||||
|
|
||||||
|
Images can be used by providing a VkImageView as an nk_image_ptr to nuklear:
|
||||||
|
|
||||||
|
```
|
||||||
|
img = nk_image_ptr(demo.demo_texture_image_view);
|
||||||
|
```
|
||||||
|
|
||||||
|
Note that they must have SHADER_READ_OPTIMAL layout
|
||||||
|
|
||||||
|
It is currently not possible to specify how they are being sampled. The nuklear glfw vulkan integration uses a fixed sampler that does linear filtering.
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,12 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_ARB_separate_shader_objects : enable
|
||||||
|
|
||||||
|
layout(binding = 0) uniform sampler2D overlay;
|
||||||
|
|
||||||
|
layout(location = 0) in vec2 inUV;
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 outColor;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
outColor = texture(overlay, inUV);
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_ARB_separate_shader_objects : enable
|
||||||
|
|
||||||
|
layout (location = 0) out vec2 outUV;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
outUV = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
|
||||||
|
gl_Position = vec4(outUV * 2.0f + -1.0f, 0.0f, 1.0f);
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
create_shader_inlined_header: nuklearshaders/nuklear.vert.spv nuklearshaders/nuklear.frag.spv
|
||||||
|
awk -v st='// NUKLEAR_SHADERS_START' -v et='// NUKLEAR_SHADERS_END' -v repl="$$(xxd -i nuklearshaders/nuklear.vert.spv && xxd -i nuklearshaders/nuklear.frag.spv)" '$$0 == st{del=1} $$0 == et{$$0 = repl; del=0} !del' nuklear_glfw_vulkan.in.h > nuklear_glfw_vulkan.h
|
||||||
|
|
||||||
|
nuklearshaders/nuklear.vert.spv: nuklearshaders/nuklear.vert
|
||||||
|
glslc --target-env=vulkan nuklearshaders/nuklear.vert -o nuklearshaders/nuklear.vert.spv
|
||||||
|
|
||||||
|
nuklearshaders/nuklear.frag.spv: nuklearshaders/nuklear.frag
|
||||||
|
glslc --target-env=vulkan nuklearshaders/nuklear.frag -o nuklearshaders/nuklear.frag.spv
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm nuklearshaders/nuklear.vert.spv nuklearshaders/nuklear.frag.spv nuklear_glfw_vulkan.h
|
|
@ -0,0 +1,5 @@
|
||||||
|
Contrary to OpenGL Vulkan needs precompiled shaders in the SPIR-V format which makes it a bit more difficult to inline the shadercode.
|
||||||
|
|
||||||
|
After executing `make` the result should be a self contained `nuklear_glfw_vulkan.h`. Copy the result file to the parent directory and the "release" should be done.
|
||||||
|
|
||||||
|
You will need to have `xxd`, `glslc` and `awk` installed for this.
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,13 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_ARB_separate_shader_objects : enable
|
||||||
|
|
||||||
|
layout(binding = 0, set = 1) uniform sampler2D currentTexture;
|
||||||
|
|
||||||
|
layout(location = 0) in vec4 fragColor;
|
||||||
|
layout(location = 1) in vec2 fragUv;
|
||||||
|
layout(location = 0) out vec4 outColor;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec4 texColor = texture(currentTexture, fragUv);
|
||||||
|
outColor = fragColor * texColor;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
#version 450
|
||||||
|
#extension GL_ARB_separate_shader_objects : enable
|
||||||
|
|
||||||
|
out gl_PerVertex {
|
||||||
|
vec4 gl_Position;
|
||||||
|
};
|
||||||
|
|
||||||
|
layout(binding = 0) uniform UniformBufferObject {
|
||||||
|
mat4 projection;
|
||||||
|
} ubo;
|
||||||
|
|
||||||
|
layout(location = 0) in vec2 position;
|
||||||
|
layout(location = 1) in vec2 uv;
|
||||||
|
layout(location = 2) in uvec4 color;
|
||||||
|
layout(location = 0) out vec4 fragColor;
|
||||||
|
layout(location = 1) out vec2 fragUv;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
gl_Position = ubo.projection * vec4(position, 0.0, 1.0);
|
||||||
|
gl_Position.y = -gl_Position.y;
|
||||||
|
fragColor = vec4(color[0]/255.0, color[1]/255.0, color[2]/255.0, color[3]/255.0);
|
||||||
|
fragUv = uv;
|
||||||
|
}
|
|
@ -49,6 +49,10 @@ void nk_sdlsurface_shutdown(struct sdlsurface_context *sdlsurfa
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_SDLSURFACE_IMPLEMENTATION
|
#ifdef NK_SDLSURFACE_IMPLEMENTATION
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
struct sdlsurface_context {
|
struct sdlsurface_context {
|
||||||
struct nk_context ctx;
|
struct nk_context ctx;
|
||||||
struct nk_rect scissors;
|
struct nk_rect scissors;
|
||||||
|
|
|
@ -139,6 +139,7 @@ main(int argc, char *argv[])
|
||||||
if (evt.type == SDL_QUIT) goto cleanup;
|
if (evt.type == SDL_QUIT) goto cleanup;
|
||||||
nk_sdl_handle_event(&evt);
|
nk_sdl_handle_event(&evt);
|
||||||
}
|
}
|
||||||
|
nk_sdl_handle_grab(); /* optional grabbing behavior */
|
||||||
nk_input_end(ctx);
|
nk_input_end(ctx);
|
||||||
|
|
||||||
/* GUI */
|
/* GUI */
|
||||||
|
|
|
@ -30,6 +30,8 @@ NK_API void nk_sdl_shutdown(void);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_SDL_GL2_IMPLEMENTATION
|
#ifdef NK_SDL_GL2_IMPLEMENTATION
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct nk_sdl_device {
|
struct nk_sdl_device {
|
||||||
struct nk_buffer cmds;
|
struct nk_buffer cmds;
|
||||||
|
@ -231,22 +233,27 @@ nk_sdl_font_stash_end(void)
|
||||||
nk_style_set_font(&sdl.ctx, &sdl.atlas.default_font->handle);
|
nk_style_set_font(&sdl.ctx, &sdl.atlas.default_font->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NK_API void
|
||||||
|
nk_sdl_handle_grab(void)
|
||||||
|
{
|
||||||
|
struct nk_context *ctx = &sdl.ctx;
|
||||||
|
if (ctx->input.mouse.grab) {
|
||||||
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
|
} else if (ctx->input.mouse.ungrab) {
|
||||||
|
/* better support for older SDL by setting mode first; causes an extra mouse motion event */
|
||||||
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
|
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
|
||||||
|
} else if (ctx->input.mouse.grabbed) {
|
||||||
|
ctx->input.mouse.pos.x = ctx->input.mouse.prev.x;
|
||||||
|
ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NK_API int
|
NK_API int
|
||||||
nk_sdl_handle_event(SDL_Event *evt)
|
nk_sdl_handle_event(SDL_Event *evt)
|
||||||
{
|
{
|
||||||
struct nk_context *ctx = &sdl.ctx;
|
struct nk_context *ctx = &sdl.ctx;
|
||||||
|
|
||||||
/* optional grabbing behavior */
|
|
||||||
if (ctx->input.mouse.grab) {
|
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
|
||||||
ctx->input.mouse.grab = 0;
|
|
||||||
} else if (ctx->input.mouse.ungrab) {
|
|
||||||
int x = (int)ctx->input.mouse.prev.x, y = (int)ctx->input.mouse.prev.y;
|
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
|
||||||
SDL_WarpMouseInWindow(sdl.win, x, y);
|
|
||||||
ctx->input.mouse.ungrab = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(evt->type)
|
switch(evt->type)
|
||||||
{
|
{
|
||||||
case SDL_KEYUP: /* KEYUP & KEYDOWN share same routine */
|
case SDL_KEYUP: /* KEYUP & KEYDOWN share same routine */
|
||||||
|
|
|
@ -149,7 +149,9 @@ int main(int argc, char *argv[])
|
||||||
while (SDL_PollEvent(&evt)) {
|
while (SDL_PollEvent(&evt)) {
|
||||||
if (evt.type == SDL_QUIT) goto cleanup;
|
if (evt.type == SDL_QUIT) goto cleanup;
|
||||||
nk_sdl_handle_event(&evt);
|
nk_sdl_handle_event(&evt);
|
||||||
} nk_input_end(ctx);
|
}
|
||||||
|
nk_sdl_handle_grab(); /* optional grabbing behavior */
|
||||||
|
nk_input_end(ctx);
|
||||||
|
|
||||||
/* GUI */
|
/* GUI */
|
||||||
if (nk_begin(ctx, "Demo", nk_rect(50, 50, 230, 250),
|
if (nk_begin(ctx, "Demo", nk_rect(50, 50, 230, 250),
|
||||||
|
|
|
@ -36,6 +36,8 @@ NK_API void nk_sdl_device_create(void);
|
||||||
*/
|
*/
|
||||||
#ifdef NK_SDL_GL3_IMPLEMENTATION
|
#ifdef NK_SDL_GL3_IMPLEMENTATION
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
struct nk_sdl_device {
|
struct nk_sdl_device {
|
||||||
|
@ -340,22 +342,27 @@ nk_sdl_font_stash_end(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NK_API void
|
||||||
|
nk_sdl_handle_grab(void)
|
||||||
|
{
|
||||||
|
struct nk_context *ctx = &sdl.ctx;
|
||||||
|
if (ctx->input.mouse.grab) {
|
||||||
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
|
} else if (ctx->input.mouse.ungrab) {
|
||||||
|
/* better support for older SDL by setting mode first; causes an extra mouse motion event */
|
||||||
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
|
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
|
||||||
|
} else if (ctx->input.mouse.grabbed) {
|
||||||
|
ctx->input.mouse.pos.x = ctx->input.mouse.prev.x;
|
||||||
|
ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NK_API int
|
NK_API int
|
||||||
nk_sdl_handle_event(SDL_Event *evt)
|
nk_sdl_handle_event(SDL_Event *evt)
|
||||||
{
|
{
|
||||||
struct nk_context *ctx = &sdl.ctx;
|
struct nk_context *ctx = &sdl.ctx;
|
||||||
|
|
||||||
/* optional grabbing behavior */
|
|
||||||
if (ctx->input.mouse.grab) {
|
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
|
||||||
ctx->input.mouse.grab = 0;
|
|
||||||
} else if (ctx->input.mouse.ungrab) {
|
|
||||||
int x = (int)ctx->input.mouse.prev.x, y = (int)ctx->input.mouse.prev.y;
|
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
|
||||||
SDL_WarpMouseInWindow(sdl.win, x, y);
|
|
||||||
ctx->input.mouse.ungrab = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(evt->type)
|
switch(evt->type)
|
||||||
{
|
{
|
||||||
case SDL_KEYUP: /* KEYUP & KEYDOWN share same routine */
|
case SDL_KEYUP: /* KEYUP & KEYDOWN share same routine */
|
||||||
|
|
|
@ -92,6 +92,7 @@ MainLoop(void* loopArg){
|
||||||
if (evt.type == SDL_QUIT) running = nk_false;
|
if (evt.type == SDL_QUIT) running = nk_false;
|
||||||
nk_sdl_handle_event(&evt);
|
nk_sdl_handle_event(&evt);
|
||||||
}
|
}
|
||||||
|
nk_sdl_handle_grab(); /* optional grabbing behavior */
|
||||||
nk_input_end(ctx);
|
nk_input_end(ctx);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,8 @@ NK_API void nk_sdl_device_create(void);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_SDL_GLES2_IMPLEMENTATION
|
#ifdef NK_SDL_GLES2_IMPLEMENTATION
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
struct nk_sdl_device {
|
struct nk_sdl_device {
|
||||||
|
@ -341,22 +342,27 @@ nk_sdl_font_stash_end(void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NK_API void
|
||||||
|
nk_sdl_handle_grab(void)
|
||||||
|
{
|
||||||
|
struct nk_context *ctx = &sdl.ctx;
|
||||||
|
if (ctx->input.mouse.grab) {
|
||||||
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
|
} else if (ctx->input.mouse.ungrab) {
|
||||||
|
/* better support for older SDL by setting mode first; causes an extra mouse motion event */
|
||||||
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
|
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
|
||||||
|
} else if (ctx->input.mouse.grabbed) {
|
||||||
|
ctx->input.mouse.pos.x = ctx->input.mouse.prev.x;
|
||||||
|
ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NK_API int
|
NK_API int
|
||||||
nk_sdl_handle_event(SDL_Event *evt)
|
nk_sdl_handle_event(SDL_Event *evt)
|
||||||
{
|
{
|
||||||
struct nk_context *ctx = &sdl.ctx;
|
struct nk_context *ctx = &sdl.ctx;
|
||||||
|
|
||||||
/* optional grabbing behavior */
|
|
||||||
if (ctx->input.mouse.grab) {
|
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
|
||||||
ctx->input.mouse.grab = 0;
|
|
||||||
} else if (ctx->input.mouse.ungrab) {
|
|
||||||
int x = (int)ctx->input.mouse.prev.x, y = (int)ctx->input.mouse.prev.y;
|
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
|
||||||
SDL_WarpMouseInWindow(sdl.win, x, y);
|
|
||||||
ctx->input.mouse.ungrab = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(evt->type)
|
switch(evt->type)
|
||||||
{
|
{
|
||||||
case SDL_KEYUP: /* KEYUP & KEYDOWN share same routine */
|
case SDL_KEYUP: /* KEYUP & KEYDOWN share same routine */
|
||||||
|
|
|
@ -177,6 +177,7 @@ main(int argc, char *argv[])
|
||||||
if (evt.type == SDL_QUIT) goto cleanup;
|
if (evt.type == SDL_QUIT) goto cleanup;
|
||||||
nk_sdl_handle_event(&evt);
|
nk_sdl_handle_event(&evt);
|
||||||
}
|
}
|
||||||
|
nk_sdl_handle_grab(); /* optional grabbing behavior */
|
||||||
nk_input_end(ctx);
|
nk_input_end(ctx);
|
||||||
|
|
||||||
/* GUI */
|
/* GUI */
|
||||||
|
|
|
@ -39,8 +39,8 @@ NK_API void nk_sdl_shutdown(void);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_SDL_RENDERER_IMPLEMENTATION
|
#ifdef NK_SDL_RENDERER_IMPLEMENTATION
|
||||||
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct nk_sdl_device {
|
struct nk_sdl_device {
|
||||||
struct nk_buffer cmds;
|
struct nk_buffer cmds;
|
||||||
|
@ -264,22 +264,27 @@ nk_sdl_font_stash_end(void)
|
||||||
nk_style_set_font(&sdl.ctx, &sdl.atlas.default_font->handle);
|
nk_style_set_font(&sdl.ctx, &sdl.atlas.default_font->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NK_API void
|
||||||
|
nk_sdl_handle_grab(void)
|
||||||
|
{
|
||||||
|
struct nk_context *ctx = &sdl.ctx;
|
||||||
|
if (ctx->input.mouse.grab) {
|
||||||
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
|
} else if (ctx->input.mouse.ungrab) {
|
||||||
|
/* better support for older SDL by setting mode first; causes an extra mouse motion event */
|
||||||
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
|
SDL_WarpMouseInWindow(sdl.win, (int)ctx->input.mouse.prev.x, (int)ctx->input.mouse.prev.y);
|
||||||
|
} else if (ctx->input.mouse.grabbed) {
|
||||||
|
ctx->input.mouse.pos.x = ctx->input.mouse.prev.x;
|
||||||
|
ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NK_API int
|
NK_API int
|
||||||
nk_sdl_handle_event(SDL_Event *evt)
|
nk_sdl_handle_event(SDL_Event *evt)
|
||||||
{
|
{
|
||||||
struct nk_context *ctx = &sdl.ctx;
|
struct nk_context *ctx = &sdl.ctx;
|
||||||
|
|
||||||
/* optional grabbing behavior */
|
|
||||||
if (ctx->input.mouse.grab) {
|
|
||||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
|
||||||
ctx->input.mouse.grab = 0;
|
|
||||||
} else if (ctx->input.mouse.ungrab) {
|
|
||||||
int x = (int)ctx->input.mouse.prev.x, y = (int)ctx->input.mouse.prev.y;
|
|
||||||
SDL_SetRelativeMouseMode(SDL_FALSE);
|
|
||||||
SDL_WarpMouseInWindow(sdl.win, x, y);
|
|
||||||
ctx->input.mouse.ungrab = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(evt->type)
|
switch(evt->type)
|
||||||
{
|
{
|
||||||
case SDL_KEYUP: /* KEYUP & KEYDOWN share same routine */
|
case SDL_KEYUP: /* KEYUP & KEYDOWN share same routine */
|
||||||
|
|
|
@ -6,4 +6,4 @@ This backend provides support for [SFML 2.4](http://www.sfml-dev.org). It will w
|
||||||
|
|
||||||
You have to edit the Makefile provided so that you can build the demo. Edit the SFML_DIR variable to point to your SFML root folder. This will be the folder to which SFML was installed and contains the lib and include folders.
|
You have to edit the Makefile provided so that you can build the demo. Edit the SFML_DIR variable to point to your SFML root folder. This will be the folder to which SFML was installed and contains the lib and include folders.
|
||||||
|
|
||||||
On Linux there is an extra step. You need to install the the udev development files.
|
On Linux there is an extra step. You need to install the udev development files.
|
||||||
|
|
|
@ -31,6 +31,8 @@ NK_API void nk_sfml_shutdown(void);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_SFML_GL2_IMPLEMENTATION
|
#ifdef NK_SFML_GL2_IMPLEMENTATION
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
struct nk_sfml_device {
|
struct nk_sfml_device {
|
||||||
struct nk_buffer cmds;
|
struct nk_buffer cmds;
|
||||||
|
|
|
@ -8,4 +8,4 @@ This backend uses Glad to handle OpenGL extensions. You can download the Glad fi
|
||||||
|
|
||||||
Once SFML and Glad have been installed on your system you have to edit the Makefile provided so that you can build the demo. There are two variables that need to be edited: SFML_DIR and GLAD_DIR. Make these point to your SFML root folder and Glad root folder respectively.
|
Once SFML and Glad have been installed on your system you have to edit the Makefile provided so that you can build the demo. There are two variables that need to be edited: SFML_DIR and GLAD_DIR. Make these point to your SFML root folder and Glad root folder respectively.
|
||||||
|
|
||||||
On Linux there is an extra step. You need to install the the udev development files.
|
On Linux there is an extra step. You need to install the udev development files.
|
||||||
|
|
|
@ -38,7 +38,8 @@ NK_API void nk_sfml_device_destroy(void);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_SFML_GL3_IMPLEMENTATION
|
#ifdef NK_SFML_GL3_IMPLEMENTATION
|
||||||
|
#include <cstring>
|
||||||
|
#include <assert.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct nk_sfml_device {
|
struct nk_sfml_device {
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
#ifndef NK_RAW_WAYLAND_H_
|
#ifndef NK_RAW_WAYLAND_H_
|
||||||
#define NK_RAW_WAYLAND_H_
|
#define NK_RAW_WAYLAND_H_
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define WIDTH 800
|
#define WIDTH 800
|
||||||
#define HEIGHT 600
|
#define HEIGHT 600
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,9 @@ NK_API void nk_xfont_del(Display *dpy, XFont *font);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_XLIB_IMPLEMENTATION
|
#ifdef NK_XLIB_IMPLEMENTATION
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/Xresource.h>
|
#include <X11/Xresource.h>
|
||||||
|
|
|
@ -32,6 +32,7 @@ NK_API void nk_x11_device_destroy(void);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_XLIB_GL3_IMPLEMENTATION
|
#ifdef NK_XLIB_GL3_IMPLEMENTATION
|
||||||
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -55,6 +55,10 @@ NK_API void nk_rawfb_resize_fb(struct rawfb_context *rawfb, voi
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_RAWFB_IMPLEMENTATION
|
#ifdef NK_RAWFB_IMPLEMENTATION
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
struct rawfb_image {
|
struct rawfb_image {
|
||||||
void *pixels;
|
void *pixels;
|
||||||
int w, h, pitch;
|
int w, h, pitch;
|
||||||
|
|
|
@ -49,6 +49,9 @@ NK_API void nk_xlib_shutdown(void);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_XLIBSHM_IMPLEMENTATION
|
#ifdef NK_XLIBSHM_IMPLEMENTATION
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/Xresource.h>
|
#include <X11/Xresource.h>
|
||||||
|
|
|
@ -48,6 +48,9 @@ NK_API void nk_xfont_del(Display *dpy, XFont *font);
|
||||||
* ===============================================================
|
* ===============================================================
|
||||||
*/
|
*/
|
||||||
#ifdef NK_XLIB_IMPLEMENTATION
|
#ifdef NK_XLIB_IMPLEMENTATION
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/Xresource.h>
|
#include <X11/Xresource.h>
|
||||||
|
|
|
@ -886,7 +886,7 @@ NK_WINDOW_NO_INPUT | Prevents window of scaling, moving or getting focu
|
||||||
#### nk_collapse_states
|
#### nk_collapse_states
|
||||||
State | Description
|
State | Description
|
||||||
----------------|-----------------------------------------------------------
|
----------------|-----------------------------------------------------------
|
||||||
__NK_MINIMIZED__| UI section is collased and not visible until maximized
|
__NK_MINIMIZED__| UI section is collapsed and not visible until maximized
|
||||||
__NK_MAXIMIZED__| UI section is extended and visible until minimized
|
__NK_MAXIMIZED__| UI section is extended and visible until minimized
|
||||||
<br /><br />
|
<br /><br />
|
||||||
#### nk_begin
|
#### nk_begin
|
||||||
|
@ -1267,7 +1267,7 @@ Parameter | Description
|
||||||
__ctx__ | Must point to an previously initialized `nk_context` struct
|
__ctx__ | Must point to an previously initialized `nk_context` struct
|
||||||
__name__ | Identifier of the window to either hide or show
|
__name__ | Identifier of the window to either hide or show
|
||||||
__state__ | state with either visible or hidden to modify the window with
|
__state__ | state with either visible or hidden to modify the window with
|
||||||
__cond__ | condition that has to be met to actually commit the visbility state change
|
__cond__ | condition that has to be met to actually commit the visibility state change
|
||||||
### Layouting
|
### Layouting
|
||||||
Layouting in general describes placing widget inside a window with position and size.
|
Layouting in general describes placing widget inside a window with position and size.
|
||||||
While in this particular implementation there are five different APIs for layouting
|
While in this particular implementation there are five different APIs for layouting
|
||||||
|
@ -1306,7 +1306,7 @@ functions should be fine.
|
||||||
if the owning window grows in width. So the number of columns dictates
|
if the owning window grows in width. So the number of columns dictates
|
||||||
the size of each widget dynamically by formula:
|
the size of each widget dynamically by formula:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||||
widget_width = (window_width - padding - spacing) * (1/colum_count)
|
widget_width = (window_width - padding - spacing) * (1/column_count)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
Just like all other layouting APIs if you define more widget than columns this
|
Just like all other layouting APIs if you define more widget than columns this
|
||||||
library will allocate a new row and keep all layouting parameters previously
|
library will allocate a new row and keep all layouting parameters previously
|
||||||
|
@ -2760,7 +2760,7 @@ X...XXXXXXXXXXXXX...X - "
|
||||||
dynamic and static widgets.
|
dynamic and static widgets.
|
||||||
- 2016/12/31 (1.30.0) - Extended scrollbar offset from 16-bit to 32-bit.
|
- 2016/12/31 (1.30.0) - Extended scrollbar offset from 16-bit to 32-bit.
|
||||||
- 2016/12/31 (1.29.2) - Fixed closing window bug of minimized windows.
|
- 2016/12/31 (1.29.2) - Fixed closing window bug of minimized windows.
|
||||||
- 2016/12/03 (1.29.1) - Fixed wrapped text with no seperator and C89 error.
|
- 2016/12/03 (1.29.1) - Fixed wrapped text with no separator and C89 error.
|
||||||
- 2016/12/03 (1.29.0) - Changed text wrapping to process words not characters.
|
- 2016/12/03 (1.29.0) - Changed text wrapping to process words not characters.
|
||||||
- 2016/11/22 (1.28.6) - Fixed window minimized closing bug.
|
- 2016/11/22 (1.28.6) - Fixed window minimized closing bug.
|
||||||
- 2016/11/19 (1.28.5) - Fixed abstract combo box closing behavior.
|
- 2016/11/19 (1.28.5) - Fixed abstract combo box closing behavior.
|
||||||
|
@ -2898,7 +2898,7 @@ X...XXXXXXXXXXXXX...X - "
|
||||||
precision.
|
precision.
|
||||||
- 2016/08/08 (1.07.2) - Fixed compiling error without define `NK_INCLUDE_FIXED_TYPE`.
|
- 2016/08/08 (1.07.2) - Fixed compiling error without define `NK_INCLUDE_FIXED_TYPE`.
|
||||||
- 2016/08/08 (1.07.1) - Fixed possible floating point error inside `nk_widget` leading
|
- 2016/08/08 (1.07.1) - Fixed possible floating point error inside `nk_widget` leading
|
||||||
to wrong wiget width calculation which results in widgets falsely
|
to wrong widget width calculation which results in widgets falsely
|
||||||
becoming tagged as not inside window and cannot be accessed.
|
becoming tagged as not inside window and cannot be accessed.
|
||||||
- 2016/08/08 (1.07.0) - Nuklear now differentiates between hiding a window (NK_WINDOW_HIDDEN) and
|
- 2016/08/08 (1.07.0) - Nuklear now differentiates between hiding a window (NK_WINDOW_HIDDEN) and
|
||||||
closing a window (NK_WINDOW_CLOSED). A window can be hidden/shown
|
closing a window (NK_WINDOW_CLOSED). A window can be hidden/shown
|
||||||
|
|
|
@ -345,7 +345,8 @@ media_init(struct media *media)
|
||||||
static void
|
static void
|
||||||
file_browser_reload_directory_content(struct file_browser *browser, const char *path)
|
file_browser_reload_directory_content(struct file_browser *browser, const char *path)
|
||||||
{
|
{
|
||||||
strncpy(browser->directory, path, MAX_PATH_LEN);
|
const size_t path_len = nk_strlen(path) + 1;
|
||||||
|
NK_MEMCPY(browser->directory, path, MIN(path_len, MAX_PATH_LEN));
|
||||||
browser->directory[MAX_PATH_LEN - 1] = 0;
|
browser->directory[MAX_PATH_LEN - 1] = 0;
|
||||||
dir_free_list(browser->files, browser->file_count);
|
dir_free_list(browser->files, browser->file_count);
|
||||||
dir_free_list(browser->directories, browser->dir_count);
|
dir_free_list(browser->directories, browser->dir_count);
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
/// - [y]: Minor version with non-breaking API and library changes
|
/// - [y]: Minor version with non-breaking API and library changes
|
||||||
/// - [z]: Patch version with no direct changes to the API
|
/// - [z]: Patch version with no direct changes to the API
|
||||||
///
|
///
|
||||||
/// - 2023/11/03 (4.10.7) - Fix null pointer dereference with nk_group and nk_listview scroll offsets
|
/// - 2024/04/04 (4.12.2) - Fix null pointer dereference with nk_group and nk_listview scroll offsets
|
||||||
|
/// - 2024/03/07 (4.12.1) - Fix bitwise operations warnings in C++20
|
||||||
|
/// - 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/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
|
/// - 2022/12/17 (4.10.5) - Fix nk_font_bake_pack() using TTC font offset incorrectly
|
||||||
/// - 2022/10/24 (4.10.4) - Fix nk_str_{append,insert}_str_utf8 always returning 0
|
/// - 2022/10/24 (4.10.4) - Fix nk_str_{append,insert}_str_utf8 always returning 0
|
||||||
|
@ -152,7 +155,7 @@
|
||||||
/// dynamic and static widgets.
|
/// dynamic and static widgets.
|
||||||
/// - 2016/12/31 (1.30.0) - Extended scrollbar offset from 16-bit to 32-bit.
|
/// - 2016/12/31 (1.30.0) - Extended scrollbar offset from 16-bit to 32-bit.
|
||||||
/// - 2016/12/31 (1.29.2) - Fixed closing window bug of minimized windows.
|
/// - 2016/12/31 (1.29.2) - Fixed closing window bug of minimized windows.
|
||||||
/// - 2016/12/03 (1.29.1) - Fixed wrapped text with no seperator and C89 error.
|
/// - 2016/12/03 (1.29.1) - Fixed wrapped text with no separator and C89 error.
|
||||||
/// - 2016/12/03 (1.29.0) - Changed text wrapping to process words not characters.
|
/// - 2016/12/03 (1.29.0) - Changed text wrapping to process words not characters.
|
||||||
/// - 2016/11/22 (1.28.6) - Fixed window minimized closing bug.
|
/// - 2016/11/22 (1.28.6) - Fixed window minimized closing bug.
|
||||||
/// - 2016/11/19 (1.28.5) - Fixed abstract combo box closing behavior.
|
/// - 2016/11/19 (1.28.5) - Fixed abstract combo box closing behavior.
|
||||||
|
@ -290,7 +293,7 @@
|
||||||
/// precision.
|
/// precision.
|
||||||
/// - 2016/08/08 (1.07.2) - Fixed compiling error without define `NK_INCLUDE_FIXED_TYPE`.
|
/// - 2016/08/08 (1.07.2) - Fixed compiling error without define `NK_INCLUDE_FIXED_TYPE`.
|
||||||
/// - 2016/08/08 (1.07.1) - Fixed possible floating point error inside `nk_widget` leading
|
/// - 2016/08/08 (1.07.1) - Fixed possible floating point error inside `nk_widget` leading
|
||||||
/// to wrong wiget width calculation which results in widgets falsely
|
/// to wrong widget width calculation which results in widgets falsely
|
||||||
/// becoming tagged as not inside window and cannot be accessed.
|
/// becoming tagged as not inside window and cannot be accessed.
|
||||||
/// - 2016/08/08 (1.07.0) - Nuklear now differentiates between hiding a window (NK_WINDOW_HIDDEN) and
|
/// - 2016/08/08 (1.07.0) - Nuklear now differentiates between hiding a window (NK_WINDOW_HIDDEN) and
|
||||||
/// closing a window (NK_WINDOW_CLOSED). A window can be hidden/shown
|
/// closing a window (NK_WINDOW_CLOSED). A window can be hidden/shown
|
||||||
|
|
|
@ -1241,7 +1241,7 @@ NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*
|
||||||
/// #### nk_collapse_states
|
/// #### nk_collapse_states
|
||||||
/// State | Description
|
/// State | Description
|
||||||
/// ----------------|-----------------------------------------------------------
|
/// ----------------|-----------------------------------------------------------
|
||||||
/// __NK_MINIMIZED__| UI section is collased and not visible until maximized
|
/// __NK_MINIMIZED__| UI section is collapsed and not visible until maximized
|
||||||
/// __NK_MAXIMIZED__| UI section is extended and visible until minimized
|
/// __NK_MAXIMIZED__| UI section is extended and visible until minimized
|
||||||
/// <br /><br />
|
/// <br /><br />
|
||||||
*/
|
*/
|
||||||
|
@ -1779,11 +1779,11 @@ NK_API void nk_window_show(struct nk_context*, const char *name, enum nk_show_st
|
||||||
/// __ctx__ | Must point to an previously initialized `nk_context` struct
|
/// __ctx__ | Must point to an previously initialized `nk_context` struct
|
||||||
/// __name__ | Identifier of the window to either hide or show
|
/// __name__ | Identifier of the window to either hide or show
|
||||||
/// __state__ | state with either visible or hidden to modify the window with
|
/// __state__ | state with either visible or hidden to modify the window with
|
||||||
/// __cond__ | condition that has to be met to actually commit the visbility state change
|
/// __cond__ | condition that has to be met to actually commit the visibility state change
|
||||||
*/
|
*/
|
||||||
NK_API void nk_window_show_if(struct nk_context*, const char *name, enum nk_show_states, int cond);
|
NK_API void nk_window_show_if(struct nk_context*, const char *name, enum nk_show_states, int cond);
|
||||||
/*/// #### nk_window_show_if
|
/*/// #### nk_window_show_if
|
||||||
/// Line for visual seperation. Draws a line with thickness determined by the current row height.
|
/// Line for visual separation. Draws a line with thickness determined by the current row height.
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||||
/// void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, NK_BOOL rounding)
|
/// void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, NK_BOOL rounding)
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -1847,7 +1847,7 @@ NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk
|
||||||
/// the size of each widget dynamically by formula:
|
/// the size of each widget dynamically by formula:
|
||||||
///
|
///
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
|
||||||
/// widget_width = (window_width - padding - spacing) * (1/colum_count)
|
/// widget_width = (window_width - padding - spacing) * (1/column_count)
|
||||||
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
///
|
///
|
||||||
/// Just like all other layouting APIs if you define more widget than columns this
|
/// Just like all other layouting APIs if you define more widget than columns this
|
||||||
|
@ -2068,6 +2068,21 @@ NK_API void nk_rule_horizontal(struct nk_context *ctx, struct nk_color color, nk
|
||||||
/// nk_layout_space_rect_to_screen | Converts rectangle from nk_layout_space coordinate space into screen space
|
/// nk_layout_space_rect_to_screen | Converts rectangle from nk_layout_space coordinate space into screen space
|
||||||
/// nk_layout_space_rect_to_local | Converts rectangle from screen space into nk_layout_space coordinates
|
/// nk_layout_space_rect_to_local | Converts rectangle from screen space into nk_layout_space coordinates
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
enum nk_widget_align {
|
||||||
|
NK_WIDGET_ALIGN_LEFT = 0x01,
|
||||||
|
NK_WIDGET_ALIGN_CENTERED = 0x02,
|
||||||
|
NK_WIDGET_ALIGN_RIGHT = 0x04,
|
||||||
|
NK_WIDGET_ALIGN_TOP = 0x08,
|
||||||
|
NK_WIDGET_ALIGN_MIDDLE = 0x10,
|
||||||
|
NK_WIDGET_ALIGN_BOTTOM = 0x20
|
||||||
|
};
|
||||||
|
enum nk_widget_alignment {
|
||||||
|
NK_WIDGET_LEFT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_LEFT,
|
||||||
|
NK_WIDGET_CENTERED = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_CENTERED,
|
||||||
|
NK_WIDGET_RIGHT = NK_WIDGET_ALIGN_MIDDLE|NK_WIDGET_ALIGN_RIGHT
|
||||||
|
};
|
||||||
|
|
||||||
/*/// #### nk_layout_set_min_row_height
|
/*/// #### nk_layout_set_min_row_height
|
||||||
/// Sets the currently used minimum row height.
|
/// Sets the currently used minimum row height.
|
||||||
/// !!! WARNING
|
/// !!! WARNING
|
||||||
|
@ -2867,7 +2882,8 @@ NK_API void nk_list_view_end(struct nk_list_view*);
|
||||||
enum nk_widget_layout_states {
|
enum nk_widget_layout_states {
|
||||||
NK_WIDGET_INVALID, /* The widget cannot be seen and is completely out of view */
|
NK_WIDGET_INVALID, /* The widget cannot be seen and is completely out of view */
|
||||||
NK_WIDGET_VALID, /* The widget is completely inside the window and can be updated and drawn */
|
NK_WIDGET_VALID, /* The widget is completely inside the window and can be updated and drawn */
|
||||||
NK_WIDGET_ROM /* The widget is partially visible and cannot be updated */
|
NK_WIDGET_ROM, /* The widget is partially visible and cannot be updated */
|
||||||
|
NK_WIDGET_DISABLED /* The widget is manually disabled and acts like NK_WIDGET_ROM */
|
||||||
};
|
};
|
||||||
enum nk_widget_states {
|
enum nk_widget_states {
|
||||||
NK_WIDGET_STATE_MODIFIED = NK_FLAG(1),
|
NK_WIDGET_STATE_MODIFIED = NK_FLAG(1),
|
||||||
|
@ -2890,6 +2906,8 @@ NK_API nk_bool nk_widget_is_hovered(struct nk_context*);
|
||||||
NK_API nk_bool nk_widget_is_mouse_clicked(struct nk_context*, enum nk_buttons);
|
NK_API nk_bool nk_widget_is_mouse_clicked(struct nk_context*, enum nk_buttons);
|
||||||
NK_API nk_bool nk_widget_has_mouse_click_down(struct nk_context*, enum nk_buttons, nk_bool down);
|
NK_API nk_bool nk_widget_has_mouse_click_down(struct nk_context*, enum nk_buttons, nk_bool down);
|
||||||
NK_API void nk_spacing(struct nk_context*, int cols);
|
NK_API void nk_spacing(struct nk_context*, int cols);
|
||||||
|
NK_API void nk_widget_disable_begin(struct nk_context* ctx);
|
||||||
|
NK_API void nk_widget_disable_end(struct nk_context* ctx);
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
*
|
*
|
||||||
* TEXT
|
* TEXT
|
||||||
|
@ -2967,10 +2985,13 @@ NK_API nk_bool nk_button_pop_behavior(struct nk_context*);
|
||||||
* ============================================================================= */
|
* ============================================================================= */
|
||||||
NK_API nk_bool nk_check_label(struct nk_context*, const char*, nk_bool active);
|
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(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_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 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(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(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_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);
|
NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsigned int *flags, unsigned int value);
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
|
@ -2979,9 +3000,13 @@ NK_API nk_bool nk_checkbox_flags_text(struct nk_context*, const char*, int, unsi
|
||||||
*
|
*
|
||||||
* ============================================================================= */
|
* ============================================================================= */
|
||||||
NK_API nk_bool nk_radio_label(struct nk_context*, const char*, nk_bool *active);
|
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(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(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(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
|
* SELECTABLE
|
||||||
|
@ -3384,6 +3409,9 @@ NK_API void nk_menu_end(struct nk_context*);
|
||||||
* STYLE
|
* STYLE
|
||||||
*
|
*
|
||||||
* ============================================================================= */
|
* ============================================================================= */
|
||||||
|
|
||||||
|
#define NK_WIDGET_DISABLED_FACTOR 0.5f
|
||||||
|
|
||||||
enum nk_style_colors {
|
enum nk_style_colors {
|
||||||
NK_COLOR_TEXT,
|
NK_COLOR_TEXT,
|
||||||
NK_COLOR_WINDOW,
|
NK_COLOR_WINDOW,
|
||||||
|
@ -3460,6 +3488,7 @@ NK_API struct nk_color nk_rgb_f(float r, float g, float b);
|
||||||
NK_API struct nk_color nk_rgb_fv(const float *rgb);
|
NK_API struct nk_color nk_rgb_fv(const float *rgb);
|
||||||
NK_API struct nk_color nk_rgb_cf(struct nk_colorf c);
|
NK_API struct nk_color nk_rgb_cf(struct nk_colorf c);
|
||||||
NK_API struct nk_color nk_rgb_hex(const char *rgb);
|
NK_API struct nk_color nk_rgb_hex(const char *rgb);
|
||||||
|
NK_API struct nk_color nk_rgb_factor(struct nk_color col, const float factor);
|
||||||
|
|
||||||
NK_API struct nk_color nk_rgba(int r, int g, int b, int a);
|
NK_API struct nk_color nk_rgba(int r, int g, int b, int a);
|
||||||
NK_API struct nk_color nk_rgba_u32(nk_uint);
|
NK_API struct nk_color nk_rgba_u32(nk_uint);
|
||||||
|
@ -4680,6 +4709,8 @@ struct nk_style_item {
|
||||||
struct nk_style_text {
|
struct nk_style_text {
|
||||||
struct nk_color color;
|
struct nk_color color;
|
||||||
struct nk_vec2 padding;
|
struct nk_vec2 padding;
|
||||||
|
float color_factor;
|
||||||
|
float disabled_factor;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nk_style_button {
|
struct nk_style_button {
|
||||||
|
@ -4688,6 +4719,7 @@ struct nk_style_button {
|
||||||
struct nk_style_item hover;
|
struct nk_style_item hover;
|
||||||
struct nk_style_item active;
|
struct nk_style_item active;
|
||||||
struct nk_color border_color;
|
struct nk_color border_color;
|
||||||
|
float color_factor_background;
|
||||||
|
|
||||||
/* text */
|
/* text */
|
||||||
struct nk_color text_background;
|
struct nk_color text_background;
|
||||||
|
@ -4695,6 +4727,7 @@ struct nk_style_button {
|
||||||
struct nk_color text_hover;
|
struct nk_color text_hover;
|
||||||
struct nk_color text_active;
|
struct nk_color text_active;
|
||||||
nk_flags text_alignment;
|
nk_flags text_alignment;
|
||||||
|
float color_factor_text;
|
||||||
|
|
||||||
/* properties */
|
/* properties */
|
||||||
float border;
|
float border;
|
||||||
|
@ -4702,6 +4735,7 @@ struct nk_style_button {
|
||||||
struct nk_vec2 padding;
|
struct nk_vec2 padding;
|
||||||
struct nk_vec2 image_padding;
|
struct nk_vec2 image_padding;
|
||||||
struct nk_vec2 touch_padding;
|
struct nk_vec2 touch_padding;
|
||||||
|
float disabled_factor;
|
||||||
|
|
||||||
/* optional user callbacks */
|
/* optional user callbacks */
|
||||||
nk_handle userdata;
|
nk_handle userdata;
|
||||||
|
@ -4732,6 +4766,8 @@ struct nk_style_toggle {
|
||||||
struct nk_vec2 touch_padding;
|
struct nk_vec2 touch_padding;
|
||||||
float spacing;
|
float spacing;
|
||||||
float border;
|
float border;
|
||||||
|
float color_factor;
|
||||||
|
float disabled_factor;
|
||||||
|
|
||||||
/* optional user callbacks */
|
/* optional user callbacks */
|
||||||
nk_handle userdata;
|
nk_handle userdata;
|
||||||
|
@ -4767,6 +4803,8 @@ struct nk_style_selectable {
|
||||||
struct nk_vec2 padding;
|
struct nk_vec2 padding;
|
||||||
struct nk_vec2 touch_padding;
|
struct nk_vec2 touch_padding;
|
||||||
struct nk_vec2 image_padding;
|
struct nk_vec2 image_padding;
|
||||||
|
float color_factor;
|
||||||
|
float disabled_factor;
|
||||||
|
|
||||||
/* optional user callbacks */
|
/* optional user callbacks */
|
||||||
nk_handle userdata;
|
nk_handle userdata;
|
||||||
|
@ -4799,6 +4837,8 @@ struct nk_style_slider {
|
||||||
struct nk_vec2 padding;
|
struct nk_vec2 padding;
|
||||||
struct nk_vec2 spacing;
|
struct nk_vec2 spacing;
|
||||||
struct nk_vec2 cursor_size;
|
struct nk_vec2 cursor_size;
|
||||||
|
float color_factor;
|
||||||
|
float disabled_factor;
|
||||||
|
|
||||||
/* optional buttons */
|
/* optional buttons */
|
||||||
int show_buttons;
|
int show_buttons;
|
||||||
|
@ -4832,6 +4872,8 @@ struct nk_style_progress {
|
||||||
float cursor_border;
|
float cursor_border;
|
||||||
float cursor_rounding;
|
float cursor_rounding;
|
||||||
struct nk_vec2 padding;
|
struct nk_vec2 padding;
|
||||||
|
float color_factor;
|
||||||
|
float disabled_factor;
|
||||||
|
|
||||||
/* optional user callbacks */
|
/* optional user callbacks */
|
||||||
nk_handle userdata;
|
nk_handle userdata;
|
||||||
|
@ -4858,6 +4900,8 @@ struct nk_style_scrollbar {
|
||||||
float border_cursor;
|
float border_cursor;
|
||||||
float rounding_cursor;
|
float rounding_cursor;
|
||||||
struct nk_vec2 padding;
|
struct nk_vec2 padding;
|
||||||
|
float color_factor;
|
||||||
|
float disabled_factor;
|
||||||
|
|
||||||
/* optional buttons */
|
/* optional buttons */
|
||||||
int show_buttons;
|
int show_buttons;
|
||||||
|
@ -4904,6 +4948,8 @@ struct nk_style_edit {
|
||||||
struct nk_vec2 scrollbar_size;
|
struct nk_vec2 scrollbar_size;
|
||||||
struct nk_vec2 padding;
|
struct nk_vec2 padding;
|
||||||
float row_padding;
|
float row_padding;
|
||||||
|
float color_factor;
|
||||||
|
float disabled_factor;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nk_style_property {
|
struct nk_style_property {
|
||||||
|
@ -4926,6 +4972,8 @@ struct nk_style_property {
|
||||||
float border;
|
float border;
|
||||||
float rounding;
|
float rounding;
|
||||||
struct nk_vec2 padding;
|
struct nk_vec2 padding;
|
||||||
|
float color_factor;
|
||||||
|
float disabled_factor;
|
||||||
|
|
||||||
struct nk_style_edit edit;
|
struct nk_style_edit edit;
|
||||||
struct nk_style_button inc_button;
|
struct nk_style_button inc_button;
|
||||||
|
@ -4948,6 +4996,9 @@ struct nk_style_chart {
|
||||||
float border;
|
float border;
|
||||||
float rounding;
|
float rounding;
|
||||||
struct nk_vec2 padding;
|
struct nk_vec2 padding;
|
||||||
|
float color_factor;
|
||||||
|
float disabled_factor;
|
||||||
|
nk_bool show_markers;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nk_style_combo {
|
struct nk_style_combo {
|
||||||
|
@ -4979,6 +5030,8 @@ struct nk_style_combo {
|
||||||
struct nk_vec2 content_padding;
|
struct nk_vec2 content_padding;
|
||||||
struct nk_vec2 button_padding;
|
struct nk_vec2 button_padding;
|
||||||
struct nk_vec2 spacing;
|
struct nk_vec2 spacing;
|
||||||
|
float color_factor;
|
||||||
|
float disabled_factor;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nk_style_tab {
|
struct nk_style_tab {
|
||||||
|
@ -5001,6 +5054,8 @@ struct nk_style_tab {
|
||||||
float indent;
|
float indent;
|
||||||
struct nk_vec2 padding;
|
struct nk_vec2 padding;
|
||||||
struct nk_vec2 spacing;
|
struct nk_vec2 spacing;
|
||||||
|
float color_factor;
|
||||||
|
float disabled_factor;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum nk_style_header_align {
|
enum nk_style_header_align {
|
||||||
|
@ -5134,6 +5189,7 @@ struct nk_chart_slot {
|
||||||
int count;
|
int count;
|
||||||
struct nk_vec2 last;
|
struct nk_vec2 last;
|
||||||
int index;
|
int index;
|
||||||
|
nk_bool show_markers;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nk_chart {
|
struct nk_chart {
|
||||||
|
@ -5283,6 +5339,7 @@ struct nk_window {
|
||||||
struct nk_popup_state popup;
|
struct nk_popup_state popup;
|
||||||
struct nk_edit_state edit;
|
struct nk_edit_state edit;
|
||||||
unsigned int scrolled;
|
unsigned int scrolled;
|
||||||
|
nk_bool widgets_disabled;
|
||||||
|
|
||||||
struct nk_table *tables;
|
struct nk_table *tables;
|
||||||
unsigned int table_count;
|
unsigned int table_count;
|
||||||
|
|
|
@ -98,16 +98,16 @@ nk_draw_button(struct nk_command_buffer *out,
|
||||||
background = &style->active;
|
background = &style->active;
|
||||||
else background = &style->normal;
|
else background = &style->normal;
|
||||||
|
|
||||||
switch(background->type) {
|
switch (background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
nk_draw_image(out, *bounds, &background->data.image, nk_white);
|
nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor_background));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
|
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor_background));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
nk_fill_rect(out, *bounds, style->rounding, background->data.color);
|
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, style->border_color);
|
nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor_background));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return background;
|
return background;
|
||||||
|
@ -127,8 +127,8 @@ nk_do_button(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r,
|
||||||
/* calculate button content space */
|
/* calculate button content space */
|
||||||
content->x = r.x + style->padding.x + style->border + style->rounding;
|
content->x = r.x + style->padding.x + style->border + style->rounding;
|
||||||
content->y = r.y + style->padding.y + style->border + style->rounding;
|
content->y = r.y + style->padding.y + style->border + style->rounding;
|
||||||
content->w = r.w - (2 * style->padding.x + style->border + style->rounding*2);
|
content->w = r.w - (2 * (style->padding.x + style->border + style->rounding));
|
||||||
content->h = r.h - (2 * style->padding.y + style->border + style->rounding*2);
|
content->h = r.h - (2 * (style->padding.y + style->border + style->rounding));
|
||||||
|
|
||||||
/* execute button behavior */
|
/* execute button behavior */
|
||||||
bounds.x = r.x - style->touch_padding.x;
|
bounds.x = r.x - style->touch_padding.x;
|
||||||
|
@ -157,6 +157,8 @@ nk_draw_button_text(struct nk_command_buffer *out,
|
||||||
text.text = style->text_active;
|
text.text = style->text_active;
|
||||||
else text.text = style->text_normal;
|
else text.text = style->text_normal;
|
||||||
|
|
||||||
|
text.text = nk_rgb_factor(text.text, style->color_factor_text);
|
||||||
|
|
||||||
text.padding = nk_vec2(0,0);
|
text.padding = nk_vec2(0,0);
|
||||||
nk_widget_text(out, *content, txt, len, &text, text_alignment, font);
|
nk_widget_text(out, *content, txt, len, &text, text_alignment, font);
|
||||||
}
|
}
|
||||||
|
@ -204,6 +206,8 @@ nk_draw_button_symbol(struct nk_command_buffer *out,
|
||||||
else if (state & NK_WIDGET_STATE_ACTIVED)
|
else if (state & NK_WIDGET_STATE_ACTIVED)
|
||||||
sym = style->text_active;
|
sym = style->text_active;
|
||||||
else sym = style->text_normal;
|
else sym = style->text_normal;
|
||||||
|
|
||||||
|
sym = nk_rgb_factor(sym, style->color_factor_text);
|
||||||
nk_draw_symbol(out, type, *content, bg, sym, 1, font);
|
nk_draw_symbol(out, type, *content, bg, sym, 1, font);
|
||||||
}
|
}
|
||||||
NK_LIB nk_bool
|
NK_LIB nk_bool
|
||||||
|
@ -235,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_flags state, const struct nk_style_button *style, const struct nk_image *img)
|
||||||
{
|
{
|
||||||
nk_draw_button(out, bounds, state, style);
|
nk_draw_button(out, bounds, state, style);
|
||||||
nk_draw_image(out, *content, img, nk_white);
|
nk_draw_image(out, *content, img, nk_rgb_factor(nk_white, style->color_factor_background));
|
||||||
}
|
}
|
||||||
NK_LIB nk_bool
|
NK_LIB nk_bool
|
||||||
nk_do_button_image(nk_flags *state,
|
nk_do_button_image(nk_flags *state,
|
||||||
|
@ -292,6 +296,8 @@ nk_draw_button_text_symbol(struct nk_command_buffer *out,
|
||||||
text.text = style->text_normal;
|
text.text = style->text_normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
text.padding = nk_vec2(0,0);
|
||||||
nk_draw_symbol(out, type, *symbol, style->text_background, sym, 0, font);
|
nk_draw_symbol(out, type, *symbol, style->text_background, sym, 0, font);
|
||||||
nk_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font);
|
nk_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font);
|
||||||
|
@ -349,9 +355,10 @@ nk_draw_button_text_image(struct nk_command_buffer *out,
|
||||||
text.text = style->text_active;
|
text.text = style->text_active;
|
||||||
else text.text = style->text_normal;
|
else text.text = style->text_normal;
|
||||||
|
|
||||||
text.padding = nk_vec2(0,0);
|
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_widget_text(out, *label, str, len, &text, NK_TEXT_CENTERED, font);
|
||||||
nk_draw_image(out, *image, img, nk_white);
|
nk_draw_image(out, *image, img, nk_rgb_factor(nk_white, style->color_factor_background));
|
||||||
}
|
}
|
||||||
NK_LIB nk_bool
|
NK_LIB nk_bool
|
||||||
nk_do_button_text_image(nk_flags *state,
|
nk_do_button_text_image(nk_flags *state,
|
||||||
|
@ -456,7 +463,7 @@ nk_button_text_styled(struct nk_context *ctx,
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
|
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
return nk_do_button_text(&ctx->last_widget_state, &win->buffer, bounds,
|
return nk_do_button_text(&ctx->last_widget_state, &win->buffer, bounds,
|
||||||
title, len, style->text_alignment, ctx->button_behavior,
|
title, len, style->text_alignment, ctx->button_behavior,
|
||||||
style, in, ctx->style.font);
|
style, in, ctx->style.font);
|
||||||
|
@ -501,7 +508,7 @@ nk_button_color(struct nk_context *ctx, struct nk_color color)
|
||||||
|
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
|
|
||||||
button = ctx->style.button;
|
button = ctx->style.button;
|
||||||
button.normal = nk_style_item_color(color);
|
button.normal = nk_style_item_color(color);
|
||||||
|
@ -533,7 +540,7 @@ nk_button_symbol_styled(struct nk_context *ctx,
|
||||||
layout = win->layout;
|
layout = win->layout;
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
return nk_do_button_symbol(&ctx->last_widget_state, &win->buffer, bounds,
|
return nk_do_button_symbol(&ctx->last_widget_state, &win->buffer, bounds,
|
||||||
symbol, ctx->button_behavior, style, in, ctx->style.font);
|
symbol, ctx->button_behavior, style, in, ctx->style.font);
|
||||||
}
|
}
|
||||||
|
@ -566,7 +573,7 @@ nk_button_image_styled(struct nk_context *ctx, const struct nk_style_button *sty
|
||||||
|
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
return nk_do_button_image(&ctx->last_widget_state, &win->buffer, bounds,
|
return nk_do_button_image(&ctx->last_widget_state, &win->buffer, bounds,
|
||||||
img, ctx->button_behavior, style, in);
|
img, ctx->button_behavior, style, in);
|
||||||
}
|
}
|
||||||
|
@ -600,7 +607,7 @@ nk_button_symbol_text_styled(struct nk_context *ctx,
|
||||||
|
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
return nk_do_button_text_symbol(&ctx->last_widget_state, &win->buffer, bounds,
|
return nk_do_button_text_symbol(&ctx->last_widget_state, &win->buffer, bounds,
|
||||||
symbol, text, len, align, ctx->button_behavior,
|
symbol, text, len, align, ctx->button_behavior,
|
||||||
style, ctx->style.font, in);
|
style, ctx->style.font, in);
|
||||||
|
@ -647,7 +654,7 @@ nk_button_image_text_styled(struct nk_context *ctx,
|
||||||
|
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
return nk_do_button_text_image(&ctx->last_widget_state, &win->buffer,
|
return nk_do_button_text_image(&ctx->last_widget_state, &win->buffer,
|
||||||
bounds, img, text, len, align, ctx->button_behavior,
|
bounds, img, text, len, align, ctx->button_behavior,
|
||||||
style, ctx->style.font, in);
|
style, ctx->style.font, in);
|
||||||
|
|
|
@ -48,26 +48,27 @@ nk_chart_begin_colored(struct nk_context *ctx, enum nk_chart_type type,
|
||||||
{struct nk_chart_slot *slot = &chart->slots[chart->slot++];
|
{struct nk_chart_slot *slot = &chart->slots[chart->slot++];
|
||||||
slot->type = type;
|
slot->type = type;
|
||||||
slot->count = count;
|
slot->count = count;
|
||||||
slot->color = color;
|
slot->color = nk_rgb_factor(color, style->color_factor);
|
||||||
slot->highlight = highlight;
|
slot->highlight = highlight;
|
||||||
slot->min = NK_MIN(min_value, max_value);
|
slot->min = NK_MIN(min_value, max_value);
|
||||||
slot->max = NK_MAX(min_value, max_value);
|
slot->max = NK_MAX(min_value, max_value);
|
||||||
slot->range = slot->max - slot->min;}
|
slot->range = slot->max - slot->min;
|
||||||
|
slot->show_markers = style->show_markers;}
|
||||||
|
|
||||||
/* draw chart background */
|
/* draw chart background */
|
||||||
background = &style->background;
|
background = &style->background;
|
||||||
|
|
||||||
switch(background->type) {
|
switch(background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
nk_draw_image(&win->buffer, bounds, &background->data.image, nk_white);
|
nk_draw_image(&win->buffer, bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
nk_draw_nine_slice(&win->buffer, bounds, &background->data.slice, nk_white);
|
nk_draw_nine_slice(&win->buffer, bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
nk_fill_rect(&win->buffer, bounds, style->rounding, style->border_color);
|
nk_fill_rect(&win->buffer, bounds, style->rounding, nk_rgb_factor(style->border_color, style->color_factor));
|
||||||
nk_fill_rect(&win->buffer, nk_shrink_rect(bounds, style->border),
|
nk_fill_rect(&win->buffer, nk_shrink_rect(bounds, style->border),
|
||||||
style->rounding, style->background.data.color);
|
style->rounding, nk_rgb_factor(style->background.data.color, style->color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -84,6 +85,8 @@ nk_chart_add_slot_colored(struct nk_context *ctx, const enum nk_chart_type type,
|
||||||
struct nk_color color, struct nk_color highlight,
|
struct nk_color color, struct nk_color highlight,
|
||||||
int count, float min_value, float max_value)
|
int count, float min_value, float max_value)
|
||||||
{
|
{
|
||||||
|
const struct nk_style_chart* style;
|
||||||
|
|
||||||
NK_ASSERT(ctx);
|
NK_ASSERT(ctx);
|
||||||
NK_ASSERT(ctx->current);
|
NK_ASSERT(ctx->current);
|
||||||
NK_ASSERT(ctx->current->layout);
|
NK_ASSERT(ctx->current->layout);
|
||||||
|
@ -91,16 +94,19 @@ nk_chart_add_slot_colored(struct nk_context *ctx, const enum nk_chart_type type,
|
||||||
if (!ctx || !ctx->current || !ctx->current->layout) return;
|
if (!ctx || !ctx->current || !ctx->current->layout) return;
|
||||||
if (ctx->current->layout->chart.slot >= NK_CHART_MAX_SLOT) return;
|
if (ctx->current->layout->chart.slot >= NK_CHART_MAX_SLOT) return;
|
||||||
|
|
||||||
|
style = &ctx->style.chart;
|
||||||
|
|
||||||
/* add another slot into the graph */
|
/* add another slot into the graph */
|
||||||
{struct nk_chart *chart = &ctx->current->layout->chart;
|
{struct nk_chart *chart = &ctx->current->layout->chart;
|
||||||
struct nk_chart_slot *slot = &chart->slots[chart->slot++];
|
struct nk_chart_slot *slot = &chart->slots[chart->slot++];
|
||||||
slot->type = type;
|
slot->type = type;
|
||||||
slot->count = count;
|
slot->count = count;
|
||||||
slot->color = color;
|
slot->color = nk_rgb_factor(color, style->color_factor);
|
||||||
slot->highlight = highlight;
|
slot->highlight = highlight;
|
||||||
slot->min = NK_MIN(min_value, max_value);
|
slot->min = NK_MIN(min_value, max_value);
|
||||||
slot->max = NK_MAX(min_value, max_value);
|
slot->max = NK_MAX(min_value, max_value);
|
||||||
slot->range = slot->max - slot->min;}
|
slot->range = slot->max - slot->min;
|
||||||
|
slot->show_markers = style->show_markers;}
|
||||||
}
|
}
|
||||||
NK_API void
|
NK_API void
|
||||||
nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type type,
|
nk_chart_add_slot(struct nk_context *ctx, const enum nk_chart_type type,
|
||||||
|
@ -114,7 +120,7 @@ nk_chart_push_line(struct nk_context *ctx, struct nk_window *win,
|
||||||
struct nk_chart *g, float value, int slot)
|
struct nk_chart *g, float value, int slot)
|
||||||
{
|
{
|
||||||
struct nk_panel *layout = win->layout;
|
struct nk_panel *layout = win->layout;
|
||||||
const struct nk_input *i = &ctx->input;
|
const struct nk_input *i = ctx->current->widgets_disabled ? 0 : &ctx->input;
|
||||||
struct nk_command_buffer *out = &win->buffer;
|
struct nk_command_buffer *out = &win->buffer;
|
||||||
|
|
||||||
nk_flags ret = 0;
|
nk_flags ret = 0;
|
||||||
|
@ -140,14 +146,16 @@ nk_chart_push_line(struct nk_context *ctx, struct nk_window *win,
|
||||||
bounds.w = bounds.h = 4;
|
bounds.w = bounds.h = 4;
|
||||||
|
|
||||||
color = g->slots[slot].color;
|
color = g->slots[slot].color;
|
||||||
if (!(layout->flags & NK_WINDOW_ROM) &&
|
if (!(layout->flags & NK_WINDOW_ROM) && i &&
|
||||||
NK_INBOX(i->mouse.pos.x,i->mouse.pos.y, g->slots[slot].last.x-3, g->slots[slot].last.y-3, 6, 6)){
|
NK_INBOX(i->mouse.pos.x,i->mouse.pos.y, g->slots[slot].last.x-3, g->slots[slot].last.y-3, 6, 6)){
|
||||||
ret = nk_input_is_mouse_hovering_rect(i, bounds) ? NK_CHART_HOVERING : 0;
|
ret = nk_input_is_mouse_hovering_rect(i, bounds) ? NK_CHART_HOVERING : 0;
|
||||||
ret |= (i->mouse.buttons[NK_BUTTON_LEFT].down &&
|
ret |= (i->mouse.buttons[NK_BUTTON_LEFT].down &&
|
||||||
i->mouse.buttons[NK_BUTTON_LEFT].clicked) ? NK_CHART_CLICKED: 0;
|
i->mouse.buttons[NK_BUTTON_LEFT].clicked) ? NK_CHART_CLICKED: 0;
|
||||||
color = g->slots[slot].highlight;
|
color = g->slots[slot].highlight;
|
||||||
}
|
}
|
||||||
nk_fill_rect(out, bounds, 0, color);
|
if (g->slots[slot].show_markers) {
|
||||||
|
nk_fill_rect(out, bounds, 0, color);
|
||||||
|
}
|
||||||
g->slots[slot].index += 1;
|
g->slots[slot].index += 1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +179,9 @@ nk_chart_push_line(struct nk_context *ctx, struct nk_window *win,
|
||||||
color = g->slots[slot].highlight;
|
color = g->slots[slot].highlight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nk_fill_rect(out, nk_rect(cur.x - 2, cur.y - 2, 4, 4), 0, color);
|
if (g->slots[slot].show_markers) {
|
||||||
|
nk_fill_rect(out, nk_rect(cur.x - 2, cur.y - 2, 4, 4), 0, color);
|
||||||
|
}
|
||||||
|
|
||||||
/* save current data point position */
|
/* save current data point position */
|
||||||
g->slots[slot].last.x = cur.x;
|
g->slots[slot].last.x = cur.x;
|
||||||
|
@ -184,7 +194,7 @@ nk_chart_push_column(const struct nk_context *ctx, struct nk_window *win,
|
||||||
struct nk_chart *chart, float value, int slot)
|
struct nk_chart *chart, float value, int slot)
|
||||||
{
|
{
|
||||||
struct nk_command_buffer *out = &win->buffer;
|
struct nk_command_buffer *out = &win->buffer;
|
||||||
const struct nk_input *in = &ctx->input;
|
const struct nk_input *in = ctx->current->widgets_disabled ? 0 : &ctx->input;
|
||||||
struct nk_panel *layout = win->layout;
|
struct nk_panel *layout = win->layout;
|
||||||
|
|
||||||
float ratio;
|
float ratio;
|
||||||
|
@ -214,7 +224,7 @@ nk_chart_push_column(const struct nk_context *ctx, struct nk_window *win,
|
||||||
item.x = item.x + ((float)chart->slots[slot].index);
|
item.x = item.x + ((float)chart->slots[slot].index);
|
||||||
|
|
||||||
/* user chart bar selection */
|
/* user chart bar selection */
|
||||||
if (!(layout->flags & NK_WINDOW_ROM) &&
|
if (!(layout->flags & NK_WINDOW_ROM) && in &&
|
||||||
NK_INBOX(in->mouse.pos.x,in->mouse.pos.y,item.x,item.y,item.w,item.h)) {
|
NK_INBOX(in->mouse.pos.x,in->mouse.pos.y,item.x,item.y,item.w,item.h)) {
|
||||||
ret = NK_CHART_HOVERING;
|
ret = NK_CHART_HOVERING;
|
||||||
ret |= (!in->mouse.buttons[NK_BUTTON_LEFT].down &&
|
ret |= (!in->mouse.buttons[NK_BUTTON_LEFT].down &&
|
||||||
|
|
|
@ -23,6 +23,16 @@ nk_parse_hex(const char *p, int length)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
NK_API struct nk_color
|
NK_API struct nk_color
|
||||||
|
nk_rgb_factor(struct nk_color col, const float factor)
|
||||||
|
{
|
||||||
|
if (factor == 1.0f)
|
||||||
|
return col;
|
||||||
|
col.r = (nk_byte)(col.r * factor);
|
||||||
|
col.g = (nk_byte)(col.g * factor);
|
||||||
|
col.b = (nk_byte)(col.b * factor);
|
||||||
|
return col;
|
||||||
|
}
|
||||||
|
NK_API struct nk_color
|
||||||
nk_rgba(int r, int g, int b, int a)
|
nk_rgba(int r, int g, int b, int a)
|
||||||
{
|
{
|
||||||
struct nk_color ret;
|
struct nk_color ret;
|
||||||
|
|
|
@ -187,7 +187,7 @@ nk_color_pick(struct nk_context * ctx, struct nk_colorf *color,
|
||||||
layout = win->layout;
|
layout = win->layout;
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
return nk_do_color_picker(&ctx->last_widget_state, &win->buffer, color, fmt, bounds,
|
return nk_do_color_picker(&ctx->last_widget_state, &win->buffer, color, fmt, bounds,
|
||||||
nk_vec2(0,0), in, config->font);
|
nk_vec2(0,0), in, config->font);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ nk_combo_begin_text(struct nk_context *ctx, const char *selected, int len,
|
||||||
if (s == NK_WIDGET_INVALID)
|
if (s == NK_WIDGET_INVALID)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
||||||
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
||||||
is_clicked = nk_true;
|
is_clicked = nk_true;
|
||||||
|
|
||||||
|
@ -83,19 +83,21 @@ nk_combo_begin_text(struct nk_context *ctx, const char *selected, int len,
|
||||||
text.text = style->combo.label_normal;
|
text.text = style->combo.label_normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text.text = nk_rgb_factor(text.text, style->combo.color_factor);
|
||||||
|
|
||||||
switch(background->type) {
|
switch(background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
text.background = nk_rgba(0, 0, 0, 0);
|
text.background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
|
nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
text.background = nk_rgba(0, 0, 0, 0);
|
text.background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
|
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
text.background = background->data.color;
|
text.background = background->data.color;
|
||||||
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
|
nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
|
||||||
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
|
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -175,7 +177,7 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
|
||||||
if (s == NK_WIDGET_INVALID)
|
if (s == NK_WIDGET_INVALID)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
||||||
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
||||||
is_clicked = nk_true;
|
is_clicked = nk_true;
|
||||||
|
|
||||||
|
@ -188,14 +190,14 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
|
||||||
|
|
||||||
switch(background->type) {
|
switch(background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
|
nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
|
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
|
nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
|
||||||
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
|
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -233,7 +235,7 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
|
||||||
bounds.w = (button.x - (style->combo.content_padding.x + style->combo.spacing.x)) - bounds.x;
|
bounds.w = (button.x - (style->combo.content_padding.x + style->combo.spacing.x)) - bounds.x;
|
||||||
else
|
else
|
||||||
bounds.w = header.w - 4 * style->combo.content_padding.x;
|
bounds.w = header.w - 4 * style->combo.content_padding.x;
|
||||||
nk_fill_rect(&win->buffer, bounds, 0, color);
|
nk_fill_rect(&win->buffer, bounds, 0, nk_rgb_factor(color, style->combo.color_factor));
|
||||||
|
|
||||||
/* draw open/close button */
|
/* draw open/close button */
|
||||||
if (draw_button_symbol)
|
if (draw_button_symbol)
|
||||||
|
@ -268,7 +270,7 @@ nk_combo_begin_symbol(struct nk_context *ctx, enum nk_symbol_type symbol, struct
|
||||||
if (s == NK_WIDGET_INVALID)
|
if (s == NK_WIDGET_INVALID)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
||||||
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
||||||
is_clicked = nk_true;
|
is_clicked = nk_true;
|
||||||
|
|
||||||
|
@ -284,19 +286,21 @@ nk_combo_begin_symbol(struct nk_context *ctx, enum nk_symbol_type symbol, struct
|
||||||
symbol_color = style->combo.symbol_hover;
|
symbol_color = style->combo.symbol_hover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
symbol_color = nk_rgb_factor(symbol_color, style->combo.color_factor);
|
||||||
|
|
||||||
switch(background->type) {
|
switch(background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
sym_background = nk_rgba(0, 0, 0, 0);
|
sym_background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
|
nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
sym_background = nk_rgba(0, 0, 0, 0);
|
sym_background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
|
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
sym_background = background->data.color;
|
sym_background = background->data.color;
|
||||||
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
|
nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
|
||||||
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
|
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -362,7 +366,7 @@ nk_combo_begin_symbol_text(struct nk_context *ctx, const char *selected, int len
|
||||||
s = nk_widget(&header, ctx);
|
s = nk_widget(&header, ctx);
|
||||||
if (!s) return 0;
|
if (!s) return 0;
|
||||||
|
|
||||||
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
||||||
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
||||||
is_clicked = nk_true;
|
is_clicked = nk_true;
|
||||||
|
|
||||||
|
@ -381,19 +385,22 @@ nk_combo_begin_symbol_text(struct nk_context *ctx, const char *selected, int len
|
||||||
text.text = style->combo.label_normal;
|
text.text = style->combo.label_normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text.text = nk_rgb_factor(text.text, style->combo.color_factor);
|
||||||
|
symbol_color = nk_rgb_factor(symbol_color, style->combo.color_factor);
|
||||||
|
|
||||||
switch(background->type) {
|
switch(background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
text.background = nk_rgba(0, 0, 0, 0);
|
text.background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
|
nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
text.background = nk_rgba(0, 0, 0, 0);
|
text.background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
|
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
text.background = background->data.color;
|
text.background = background->data.color;
|
||||||
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
|
nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
|
||||||
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
|
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -464,7 +471,7 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
|
||||||
if (s == NK_WIDGET_INVALID)
|
if (s == NK_WIDGET_INVALID)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
||||||
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
||||||
is_clicked = nk_true;
|
is_clicked = nk_true;
|
||||||
|
|
||||||
|
@ -477,14 +484,14 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
|
||||||
|
|
||||||
switch (background->type) {
|
switch (background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
|
nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
|
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
|
nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
|
||||||
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
|
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -522,7 +529,7 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
|
||||||
bounds.w = (button.x - style->combo.content_padding.y) - bounds.x;
|
bounds.w = (button.x - style->combo.content_padding.y) - bounds.x;
|
||||||
else
|
else
|
||||||
bounds.w = header.w - 2 * style->combo.content_padding.x;
|
bounds.w = header.w - 2 * style->combo.content_padding.x;
|
||||||
nk_draw_image(&win->buffer, bounds, &img, nk_white);
|
nk_draw_image(&win->buffer, bounds, &img, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
|
|
||||||
/* draw open/close button */
|
/* draw open/close button */
|
||||||
if (draw_button_symbol)
|
if (draw_button_symbol)
|
||||||
|
@ -556,7 +563,7 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
|
||||||
s = nk_widget(&header, ctx);
|
s = nk_widget(&header, ctx);
|
||||||
if (!s) return 0;
|
if (!s) return 0;
|
||||||
|
|
||||||
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
in = (win->layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED || s == NK_WIDGET_ROM)? 0: &ctx->input;
|
||||||
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
if (nk_button_behavior(&ctx->last_widget_state, header, in, NK_BUTTON_DEFAULT))
|
||||||
is_clicked = nk_true;
|
is_clicked = nk_true;
|
||||||
|
|
||||||
|
@ -572,19 +579,21 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
|
||||||
text.text = style->combo.label_normal;
|
text.text = style->combo.label_normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text.text = nk_rgb_factor(text.text, style->combo.color_factor);
|
||||||
|
|
||||||
switch(background->type) {
|
switch(background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
text.background = nk_rgba(0, 0, 0, 0);
|
text.background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
|
nk_draw_image(&win->buffer, header, &background->data.image, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
text.background = nk_rgba(0, 0, 0, 0);
|
text.background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
|
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
text.background = background->data.color;
|
text.background = background->data.color;
|
||||||
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
|
nk_fill_rect(&win->buffer, header, style->combo.rounding, nk_rgb_factor(background->data.color, style->combo.color_factor));
|
||||||
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
|
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, nk_rgb_factor(style->combo.border_color, style->combo.color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -623,7 +632,7 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
|
||||||
image.y = header.y + style->combo.content_padding.y;
|
image.y = header.y + style->combo.content_padding.y;
|
||||||
image.h = header.h - 2 * style->combo.content_padding.y;
|
image.h = header.h - 2 * style->combo.content_padding.y;
|
||||||
image.w = image.h;
|
image.w = image.h;
|
||||||
nk_draw_image(&win->buffer, image, &img, nk_white);
|
nk_draw_image(&win->buffer, image, &img, nk_rgb_factor(nk_white, style->combo.color_factor));
|
||||||
|
|
||||||
/* draw label */
|
/* draw label */
|
||||||
text.padding = nk_vec2(0,0);
|
text.padding = nk_vec2(0,0);
|
||||||
|
|
|
@ -13,6 +13,7 @@ nk_contextual_begin(struct nk_context *ctx, nk_flags flags, struct nk_vec2 size,
|
||||||
struct nk_window *win;
|
struct nk_window *win;
|
||||||
struct nk_window *popup;
|
struct nk_window *popup;
|
||||||
struct nk_rect body;
|
struct nk_rect body;
|
||||||
|
struct nk_input* in;
|
||||||
|
|
||||||
NK_STORAGE const struct nk_rect null_rect = {-1,-1,0,0};
|
NK_STORAGE const struct nk_rect null_rect = {-1,-1,0,0};
|
||||||
int is_clicked = 0;
|
int is_clicked = 0;
|
||||||
|
@ -33,35 +34,39 @@ nk_contextual_begin(struct nk_context *ctx, nk_flags flags, struct nk_vec2 size,
|
||||||
/* check if currently active contextual is active */
|
/* check if currently active contextual is active */
|
||||||
popup = win->popup.win;
|
popup = win->popup.win;
|
||||||
is_open = (popup && win->popup.type == NK_PANEL_CONTEXTUAL);
|
is_open = (popup && win->popup.type == NK_PANEL_CONTEXTUAL);
|
||||||
is_clicked = nk_input_mouse_clicked(&ctx->input, NK_BUTTON_RIGHT, trigger_bounds);
|
in = win->widgets_disabled ? 0 : &ctx->input;
|
||||||
if (win->popup.active_con && win->popup.con_count != win->popup.active_con)
|
if (in) {
|
||||||
return 0;
|
is_clicked = nk_input_mouse_clicked(in, NK_BUTTON_RIGHT, trigger_bounds);
|
||||||
if (!is_open && win->popup.active_con)
|
if (win->popup.active_con && win->popup.con_count != win->popup.active_con)
|
||||||
win->popup.active_con = 0;
|
return 0;
|
||||||
if ((!is_open && !is_clicked))
|
if (!is_open && win->popup.active_con)
|
||||||
return 0;
|
win->popup.active_con = 0;
|
||||||
|
if ((!is_open && !is_clicked))
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* calculate contextual position on click */
|
/* calculate contextual position on click */
|
||||||
win->popup.active_con = win->popup.con_count;
|
win->popup.active_con = win->popup.con_count;
|
||||||
if (is_clicked) {
|
if (is_clicked) {
|
||||||
body.x = ctx->input.mouse.pos.x;
|
body.x = in->mouse.pos.x;
|
||||||
body.y = ctx->input.mouse.pos.y;
|
body.y = in->mouse.pos.y;
|
||||||
} else {
|
} else {
|
||||||
body.x = popup->bounds.x;
|
body.x = popup->bounds.x;
|
||||||
body.y = popup->bounds.y;
|
body.y = popup->bounds.y;
|
||||||
}
|
}
|
||||||
body.w = size.x;
|
|
||||||
body.h = size.y;
|
|
||||||
|
|
||||||
/* start nonblocking contextual popup */
|
body.w = size.x;
|
||||||
ret = nk_nonblock_begin(ctx, flags|NK_WINDOW_NO_SCROLLBAR, body,
|
body.h = size.y;
|
||||||
|
|
||||||
|
/* start nonblocking contextual popup */
|
||||||
|
ret = nk_nonblock_begin(ctx, flags | NK_WINDOW_NO_SCROLLBAR, body,
|
||||||
null_rect, NK_PANEL_CONTEXTUAL);
|
null_rect, NK_PANEL_CONTEXTUAL);
|
||||||
if (ret) win->popup.type = NK_PANEL_CONTEXTUAL;
|
if (ret) win->popup.type = NK_PANEL_CONTEXTUAL;
|
||||||
else {
|
else {
|
||||||
win->popup.active_con = 0;
|
win->popup.active_con = 0;
|
||||||
win->popup.type = NK_PANEL_NONE;
|
win->popup.type = NK_PANEL_NONE;
|
||||||
if (win->popup.win)
|
if (win->popup.win)
|
||||||
win->popup.win->flags = 0;
|
win->popup.win->flags = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +198,7 @@ nk_contextual_end(struct nk_context *ctx)
|
||||||
popup = ctx->current;
|
popup = ctx->current;
|
||||||
panel = popup->layout;
|
panel = popup->layout;
|
||||||
NK_ASSERT(popup->parent);
|
NK_ASSERT(popup->parent);
|
||||||
NK_ASSERT(panel->type & NK_PANEL_SET_POPUP);
|
NK_ASSERT((int)panel->type & (int)NK_PANEL_SET_POPUP);
|
||||||
if (panel->flags & NK_WINDOW_DYNAMIC) {
|
if (panel->flags & NK_WINDOW_DYNAMIC) {
|
||||||
/* Close behavior
|
/* Close behavior
|
||||||
This is a bit of a hack solution since we do not know before we end our popup
|
This is a bit of a hack solution since we do not know before we end our popup
|
||||||
|
|
|
@ -94,6 +94,9 @@ nk_edit_draw_text(struct nk_command_buffer *out,
|
||||||
txt.background = background;
|
txt.background = background;
|
||||||
txt.text = foreground;
|
txt.text = foreground;
|
||||||
|
|
||||||
|
foreground = nk_rgb_factor(foreground, style->color_factor);
|
||||||
|
background = nk_rgb_factor(background, style->color_factor);
|
||||||
|
|
||||||
glyph_len = nk_utf_decode(text+text_len, &unicode, byte_len-text_len);
|
glyph_len = nk_utf_decode(text+text_len, &unicode, byte_len-text_len);
|
||||||
if (!glyph_len) return;
|
if (!glyph_len) return;
|
||||||
while ((text_len < byte_len) && glyph_len)
|
while ((text_len < byte_len) && glyph_len)
|
||||||
|
@ -331,14 +334,14 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
|
||||||
/* draw background frame */
|
/* draw background frame */
|
||||||
switch(background->type) {
|
switch(background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
nk_draw_image(out, bounds, &background->data.image, nk_white);
|
nk_draw_image(out, bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
nk_draw_nine_slice(out, bounds, &background->data.slice, nk_white);
|
nk_draw_nine_slice(out, bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
nk_fill_rect(out, bounds, style->rounding, background->data.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, style->border_color);
|
nk_stroke_rect(out, bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor));
|
||||||
break;
|
break;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -547,6 +550,8 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
|
||||||
else
|
else
|
||||||
background_color = background->data.color;
|
background_color = background->data.color;
|
||||||
|
|
||||||
|
cursor_color = nk_rgb_factor(cursor_color, style->color_factor);
|
||||||
|
cursor_text_color = nk_rgb_factor(cursor_text_color, style->color_factor);
|
||||||
|
|
||||||
if (edit->select_start == edit->select_end) {
|
if (edit->select_start == edit->select_end) {
|
||||||
/* no selection so just draw the complete text */
|
/* no selection so just draw the complete text */
|
||||||
|
@ -654,6 +659,10 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
|
||||||
background_color = nk_rgba(0,0,0,0);
|
background_color = nk_rgba(0,0,0,0);
|
||||||
else
|
else
|
||||||
background_color = background->data.color;
|
background_color = background->data.color;
|
||||||
|
|
||||||
|
background_color = nk_rgb_factor(background_color, style->color_factor);
|
||||||
|
text_color = nk_rgb_factor(text_color, style->color_factor);
|
||||||
|
|
||||||
nk_edit_draw_text(out, style, area.x - edit->scrollbar.x,
|
nk_edit_draw_text(out, style, area.x - edit->scrollbar.x,
|
||||||
area.y - edit->scrollbar.y, 0, begin, l, row_height, font,
|
area.y - edit->scrollbar.y, 0, begin, l, row_height, font,
|
||||||
background_color, text_color, nk_false);
|
background_color, text_color, nk_false);
|
||||||
|
@ -773,6 +782,8 @@ nk_edit_buffer(struct nk_context *ctx, nk_flags flags,
|
||||||
style = &ctx->style;
|
style = &ctx->style;
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return state;
|
if (!state) return state;
|
||||||
|
else if (state == NK_WIDGET_DISABLED)
|
||||||
|
flags |= NK_EDIT_READ_ONLY;
|
||||||
in = (win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
|
|
||||||
/* check if edit is currently hot item */
|
/* check if edit is currently hot item */
|
||||||
|
|
|
@ -255,9 +255,9 @@ enum nk_toggle_type {
|
||||||
NK_TOGGLE_OPTION
|
NK_TOGGLE_OPTION
|
||||||
};
|
};
|
||||||
NK_LIB nk_bool nk_toggle_behavior(const struct nk_input *in, struct nk_rect select, nk_flags *state, nk_bool active);
|
NK_LIB nk_bool nk_toggle_behavior(const struct nk_input *in, struct nk_rect select, nk_flags *state, nk_bool active);
|
||||||
NK_LIB void nk_draw_checkbox(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, nk_bool active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font);
|
NK_LIB void nk_draw_checkbox(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, nk_bool active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font, nk_flags text_alignment);
|
||||||
NK_LIB void nk_draw_option(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, nk_bool active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font);
|
NK_LIB void nk_draw_option(struct nk_command_buffer *out, nk_flags state, const struct nk_style_toggle *style, nk_bool active, const struct nk_rect *label, const struct nk_rect *selector, const struct nk_rect *cursors, const char *string, int len, const struct nk_user_font *font, nk_flags text_alignment);
|
||||||
NK_LIB nk_bool nk_do_toggle(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, nk_bool *active, const char *str, int len, enum nk_toggle_type type, const struct nk_style_toggle *style, const struct nk_input *in, const struct nk_user_font *font);
|
NK_LIB nk_bool nk_do_toggle(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r, nk_bool *active, const char *str, int len, enum nk_toggle_type type, const struct nk_style_toggle *style, const struct nk_input *in, const struct nk_user_font *font, nk_flags widget_alignment, nk_flags text_alignment);
|
||||||
|
|
||||||
/* progress */
|
/* progress */
|
||||||
NK_LIB nk_size nk_progress_behavior(nk_flags *state, struct nk_input *in, struct nk_rect r, struct nk_rect cursor, nk_size max, nk_size value, nk_bool modifiable);
|
NK_LIB nk_size nk_progress_behavior(nk_flags *state, struct nk_input *in, struct nk_rect r, struct nk_rect cursor, nk_size max, nk_size value, nk_bool modifiable);
|
||||||
|
@ -350,14 +350,14 @@ NK_LIB void nk_property(struct nk_context *ctx, const char *name, struct nk_prop
|
||||||
#ifndef STBTT_malloc
|
#ifndef STBTT_malloc
|
||||||
static void*
|
static void*
|
||||||
nk_stbtt_malloc(nk_size size, void *user_data) {
|
nk_stbtt_malloc(nk_size size, void *user_data) {
|
||||||
struct nk_allocator *alloc = (struct nk_allocator *) user_data;
|
struct nk_allocator *alloc = (struct nk_allocator *) user_data;
|
||||||
return alloc->alloc(alloc->userdata, 0, size);
|
return alloc->alloc(alloc->userdata, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nk_stbtt_free(void *ptr, void *user_data) {
|
nk_stbtt_free(void *ptr, void *user_data) {
|
||||||
struct nk_allocator *alloc = (struct nk_allocator *) user_data;
|
struct nk_allocator *alloc = (struct nk_allocator *) user_data;
|
||||||
alloc->free(alloc->userdata, ptr);
|
alloc->free(alloc->userdata, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define STBTT_malloc(x,u) nk_stbtt_malloc(x,u)
|
#define STBTT_malloc(x,u) nk_stbtt_malloc(x,u)
|
||||||
|
|
|
@ -128,7 +128,7 @@ nk_menu_begin_text(struct nk_context *ctx, const char *title, int len,
|
||||||
win = ctx->current;
|
win = ctx->current;
|
||||||
state = nk_widget(&header, ctx);
|
state = nk_widget(&header, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || win->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || win->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
if (nk_do_button_text(&ctx->last_widget_state, &win->buffer, header,
|
if (nk_do_button_text(&ctx->last_widget_state, &win->buffer, header,
|
||||||
title, len, align, NK_BUTTON_DEFAULT, &ctx->style.menu_button, in, ctx->style.font))
|
title, len, align, NK_BUTTON_DEFAULT, &ctx->style.menu_button, in, ctx->style.font))
|
||||||
is_clicked = nk_true;
|
is_clicked = nk_true;
|
||||||
|
@ -158,7 +158,7 @@ nk_menu_begin_image(struct nk_context *ctx, const char *id, struct nk_image img,
|
||||||
win = ctx->current;
|
win = ctx->current;
|
||||||
state = nk_widget(&header, ctx);
|
state = nk_widget(&header, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
if (nk_do_button_image(&ctx->last_widget_state, &win->buffer, header,
|
if (nk_do_button_image(&ctx->last_widget_state, &win->buffer, header,
|
||||||
img, NK_BUTTON_DEFAULT, &ctx->style.menu_button, in))
|
img, NK_BUTTON_DEFAULT, &ctx->style.menu_button, in))
|
||||||
is_clicked = nk_true;
|
is_clicked = nk_true;
|
||||||
|
@ -183,7 +183,7 @@ nk_menu_begin_symbol(struct nk_context *ctx, const char *id,
|
||||||
win = ctx->current;
|
win = ctx->current;
|
||||||
state = nk_widget(&header, ctx);
|
state = nk_widget(&header, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
if (nk_do_button_symbol(&ctx->last_widget_state, &win->buffer, header,
|
if (nk_do_button_symbol(&ctx->last_widget_state, &win->buffer, header,
|
||||||
sym, NK_BUTTON_DEFAULT, &ctx->style.menu_button, in, ctx->style.font))
|
sym, NK_BUTTON_DEFAULT, &ctx->style.menu_button, in, ctx->style.font))
|
||||||
is_clicked = nk_true;
|
is_clicked = nk_true;
|
||||||
|
@ -208,7 +208,7 @@ nk_menu_begin_image_text(struct nk_context *ctx, const char *title, int len,
|
||||||
win = ctx->current;
|
win = ctx->current;
|
||||||
state = nk_widget(&header, ctx);
|
state = nk_widget(&header, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
if (nk_do_button_text_image(&ctx->last_widget_state, &win->buffer,
|
if (nk_do_button_text_image(&ctx->last_widget_state, &win->buffer,
|
||||||
header, img, title, len, align, NK_BUTTON_DEFAULT, &ctx->style.menu_button,
|
header, img, title, len, align, NK_BUTTON_DEFAULT, &ctx->style.menu_button,
|
||||||
ctx->style.font, in))
|
ctx->style.font, in))
|
||||||
|
@ -241,7 +241,7 @@ nk_menu_begin_symbol_text(struct nk_context *ctx, const char *title, int len,
|
||||||
state = nk_widget(&header, ctx);
|
state = nk_widget(&header, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
|
|
||||||
in = (state == NK_WIDGET_ROM || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || win->layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
if (nk_do_button_text_symbol(&ctx->last_widget_state, &win->buffer,
|
if (nk_do_button_text_symbol(&ctx->last_widget_state, &win->buffer,
|
||||||
header, sym, title, len, align, NK_BUTTON_DEFAULT, &ctx->style.menu_button,
|
header, sym, title, len, align, NK_BUTTON_DEFAULT, &ctx->style.menu_button,
|
||||||
ctx->style.font, in)) is_clicked = nk_true;
|
ctx->style.font, in)) is_clicked = nk_true;
|
||||||
|
|
|
@ -76,12 +76,12 @@ nk_panel_get_border_color(const struct nk_style *style, enum nk_panel_type type)
|
||||||
NK_LIB nk_bool
|
NK_LIB nk_bool
|
||||||
nk_panel_is_sub(enum nk_panel_type type)
|
nk_panel_is_sub(enum nk_panel_type type)
|
||||||
{
|
{
|
||||||
return (type & NK_PANEL_SET_SUB)?1:0;
|
return ((int)type & (int)NK_PANEL_SET_SUB)?1:0;
|
||||||
}
|
}
|
||||||
NK_LIB nk_bool
|
NK_LIB nk_bool
|
||||||
nk_panel_is_nonblock(enum nk_panel_type type)
|
nk_panel_is_nonblock(enum nk_panel_type type)
|
||||||
{
|
{
|
||||||
return (type & NK_PANEL_SET_NONBLOCK)?1:0;
|
return ((int)type & (int)NK_PANEL_SET_NONBLOCK)?1:0;
|
||||||
}
|
}
|
||||||
NK_LIB nk_bool
|
NK_LIB nk_bool
|
||||||
nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type panel_type)
|
nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type panel_type)
|
||||||
|
|
|
@ -27,7 +27,7 @@ nk_popup_begin(struct nk_context *ctx, enum nk_popup_type type,
|
||||||
|
|
||||||
win = ctx->current;
|
win = ctx->current;
|
||||||
panel = win->layout;
|
panel = win->layout;
|
||||||
NK_ASSERT(!(panel->type & NK_PANEL_SET_POPUP) && "popups are not allowed to have popups");
|
NK_ASSERT(!((int)panel->type & (int)NK_PANEL_SET_POPUP) && "popups are not allowed to have popups");
|
||||||
(void)panel;
|
(void)panel;
|
||||||
title_len = (int)nk_strlen(title);
|
title_len = (int)nk_strlen(title);
|
||||||
title_hash = nk_murmur_hash(title, (int)title_len, NK_PANEL_POPUP);
|
title_hash = nk_murmur_hash(title, (int)title_len, NK_PANEL_POPUP);
|
||||||
|
@ -121,7 +121,7 @@ nk_nonblock_begin(struct nk_context *ctx,
|
||||||
/* popups cannot have popups */
|
/* popups cannot have popups */
|
||||||
win = ctx->current;
|
win = ctx->current;
|
||||||
panel = win->layout;
|
panel = win->layout;
|
||||||
NK_ASSERT(!(panel->type & NK_PANEL_SET_POPUP));
|
NK_ASSERT(!((int)panel->type & (int)NK_PANEL_SET_POPUP));
|
||||||
(void)panel;
|
(void)panel;
|
||||||
popup = win->popup.win;
|
popup = win->popup.win;
|
||||||
if (!popup) {
|
if (!popup) {
|
||||||
|
@ -194,7 +194,7 @@ nk_popup_close(struct nk_context *ctx)
|
||||||
|
|
||||||
popup = ctx->current;
|
popup = ctx->current;
|
||||||
NK_ASSERT(popup->parent);
|
NK_ASSERT(popup->parent);
|
||||||
NK_ASSERT(popup->layout->type & NK_PANEL_SET_POPUP);
|
NK_ASSERT((int)popup->layout->type & (int)NK_PANEL_SET_POPUP);
|
||||||
popup->flags |= NK_WINDOW_HIDDEN;
|
popup->flags |= NK_WINDOW_HIDDEN;
|
||||||
}
|
}
|
||||||
NK_API void
|
NK_API void
|
||||||
|
|
|
@ -62,28 +62,28 @@ nk_draw_progress(struct nk_command_buffer *out, nk_flags state,
|
||||||
/* draw background */
|
/* draw background */
|
||||||
switch(background->type) {
|
switch(background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
nk_draw_image(out, *bounds, &background->data.image, nk_white);
|
nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
|
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
nk_fill_rect(out, *bounds, style->rounding, background->data.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, style->border_color);
|
nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw cursor */
|
/* draw cursor */
|
||||||
switch(cursor->type) {
|
switch(cursor->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
nk_draw_image(out, *scursor, &cursor->data.image, nk_white);
|
nk_draw_image(out, *scursor, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
nk_draw_nine_slice(out, *scursor, &cursor->data.slice, nk_white);
|
nk_draw_nine_slice(out, *scursor, &cursor->data.slice, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
nk_fill_rect(out, *scursor, style->rounding, cursor->data.color);
|
nk_fill_rect(out, *scursor, style->rounding, nk_rgb_factor(cursor->data.color, style->color_factor));
|
||||||
nk_stroke_rect(out, *scursor, style->rounding, style->border, style->border_color);
|
nk_stroke_rect(out, *scursor, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ nk_progress(struct nk_context *ctx, nk_size *cur, nk_size max, nk_bool is_modify
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
|
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
old_value = *cur;
|
old_value = *cur;
|
||||||
*cur = nk_do_progress(&ctx->last_widget_state, &win->buffer, bounds,
|
*cur = nk_do_progress(&ctx->last_widget_state, &win->buffer, bounds,
|
||||||
*cur, max, is_modifyable, &style->progress, in);
|
*cur, max, is_modifyable, &style->progress, in);
|
||||||
|
|
|
@ -85,20 +85,22 @@ nk_draw_property(struct nk_command_buffer *out, const struct nk_style_property *
|
||||||
text.text = style->label_normal;
|
text.text = style->label_normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text.text = nk_rgb_factor(text.text, style->color_factor);
|
||||||
|
|
||||||
/* draw background */
|
/* draw background */
|
||||||
switch(background->type) {
|
switch(background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
text.background = nk_rgba(0, 0, 0, 0);
|
text.background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_image(out, *bounds, &background->data.image, nk_white);
|
nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
text.background = nk_rgba(0, 0, 0, 0);
|
text.background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
|
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
text.background = background->data.color;
|
text.background = background->data.color;
|
||||||
nk_fill_rect(out, *bounds, style->rounding, background->data.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, background->data.color);
|
nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(background->data.color, style->color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +251,7 @@ nk_do_property(nk_flags *ws,
|
||||||
text_edit->string.buffer.memory.ptr = dst;
|
text_edit->string.buffer.memory.ptr = dst;
|
||||||
text_edit->string.buffer.size = NK_MAX_NUMBER_BUFFER;
|
text_edit->string.buffer.size = NK_MAX_NUMBER_BUFFER;
|
||||||
text_edit->mode = NK_TEXT_EDIT_MODE_INSERT;
|
text_edit->mode = NK_TEXT_EDIT_MODE_INSERT;
|
||||||
nk_do_edit(ws, out, edit, NK_EDIT_FIELD|NK_EDIT_AUTO_SELECT,
|
nk_do_edit(ws, out, edit, (int)NK_EDIT_FIELD|(int)NK_EDIT_AUTO_SELECT,
|
||||||
filters[filter], text_edit, &style->edit, (*state == NK_PROPERTY_EDIT) ? in: 0, font);
|
filters[filter], text_edit, &style->edit, (*state == NK_PROPERTY_EDIT) ? in: 0, font);
|
||||||
|
|
||||||
*length = text_edit->string.len;
|
*length = text_edit->string.len;
|
||||||
|
@ -383,7 +385,7 @@ nk_property(struct nk_context *ctx, const char *name, struct nk_property_variant
|
||||||
old_state = *state;
|
old_state = *state;
|
||||||
ctx->text_edit.clip = ctx->clip;
|
ctx->text_edit.clip = ctx->clip;
|
||||||
in = ((s == NK_WIDGET_ROM && !win->property.active) ||
|
in = ((s == NK_WIDGET_ROM && !win->property.active) ||
|
||||||
layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
layout->flags & NK_WINDOW_ROM || s == NK_WIDGET_DISABLED) ? 0 : &ctx->input;
|
||||||
nk_do_property(&ctx->last_widget_state, &win->buffer, bounds, name,
|
nk_do_property(&ctx->last_widget_state, &win->buffer, bounds, name,
|
||||||
variant, inc_per_pixel, buffer, len, state, cursor, select_begin,
|
variant, inc_per_pixel, buffer, len, state, cursor, select_begin,
|
||||||
select_end, &style->property, filter, in, style->font, &ctx->text_edit,
|
select_end, &style->property, filter, in, style->font, &ctx->text_edit,
|
||||||
|
|
|
@ -41,15 +41,18 @@ nk_draw_selectable(struct nk_command_buffer *out,
|
||||||
text.text = style->text_normal_active;
|
text.text = style->text_normal_active;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text.text = nk_rgb_factor(text.text, style->color_factor);
|
||||||
|
|
||||||
/* draw selectable background and text */
|
/* draw selectable background and text */
|
||||||
switch (background->type) {
|
switch (background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
text.background = nk_rgba(0, 0, 0, 0);
|
text.background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_image(out, *bounds, &background->data.image, nk_white);
|
nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
text.background = nk_rgba(0, 0, 0, 0);
|
text.background = nk_rgba(0, 0, 0, 0);
|
||||||
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
|
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
text.background = background->data.color;
|
text.background = background->data.color;
|
||||||
|
@ -57,7 +60,7 @@ nk_draw_selectable(struct nk_command_buffer *out,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (icon) {
|
if (icon) {
|
||||||
if (img) nk_draw_image(out, *icon, img, nk_white);
|
if (img) nk_draw_image(out, *icon, img, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
else nk_draw_symbol(out, sym, *icon, text.background, text.text, 1, font);
|
else nk_draw_symbol(out, sym, *icon, text.background, text.text, 1, font);
|
||||||
}
|
}
|
||||||
nk_widget_text(out, *bounds, string, len, &text, align, font);
|
nk_widget_text(out, *bounds, string, len, &text, align, font);
|
||||||
|
@ -218,7 +221,7 @@ nk_selectable_text(struct nk_context *ctx, const char *str, int len,
|
||||||
|
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
return nk_do_selectable(&ctx->last_widget_state, &win->buffer, bounds,
|
return nk_do_selectable(&ctx->last_widget_state, &win->buffer, bounds,
|
||||||
str, len, align, value, &style->selectable, in, style->font);
|
str, len, align, value, &style->selectable, in, style->font);
|
||||||
}
|
}
|
||||||
|
@ -247,7 +250,7 @@ nk_selectable_image_text(struct nk_context *ctx, struct nk_image img,
|
||||||
|
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
return nk_do_selectable_image(&ctx->last_widget_state, &win->buffer, bounds,
|
return nk_do_selectable_image(&ctx->last_widget_state, &win->buffer, bounds,
|
||||||
str, len, align, value, &img, &style->selectable, in, style->font);
|
str, len, align, value, &img, &style->selectable, in, style->font);
|
||||||
}
|
}
|
||||||
|
@ -276,7 +279,7 @@ nk_selectable_symbol_text(struct nk_context *ctx, enum nk_symbol_type sym,
|
||||||
|
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return 0;
|
if (!state) return 0;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (state == NK_WIDGET_ROM || state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
return nk_do_selectable_symbol(&ctx->last_widget_state, &win->buffer, bounds,
|
return nk_do_selectable_symbol(&ctx->last_widget_state, &win->buffer, bounds,
|
||||||
str, len, align, value, sym, &style->selectable, in, style->font);
|
str, len, align, value, sym, &style->selectable, in, style->font);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ nk_draw_slider(struct nk_command_buffer *out, nk_flags state,
|
||||||
bar_color = style->bar_normal;
|
bar_color = style->bar_normal;
|
||||||
cursor = &style->cursor_normal;
|
cursor = &style->cursor_normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calculate slider background bar */
|
/* calculate slider background bar */
|
||||||
bar.x = bounds->x;
|
bar.x = bounds->x;
|
||||||
bar.y = (visual_cursor->y + visual_cursor->h/2) - bounds->h/12;
|
bar.y = (visual_cursor->y + visual_cursor->h/2) - bounds->h/12;
|
||||||
|
@ -93,26 +94,26 @@ nk_draw_slider(struct nk_command_buffer *out, nk_flags state,
|
||||||
/* draw background */
|
/* draw background */
|
||||||
switch(background->type) {
|
switch(background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
nk_draw_image(out, *bounds, &background->data.image, nk_white);
|
nk_draw_image(out, *bounds, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
|
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
nk_fill_rect(out, *bounds, style->rounding, background->data.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, style->border_color);
|
nk_stroke_rect(out, *bounds, style->rounding, style->border, nk_rgb_factor(style->border_color, style->color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw slider bar */
|
/* draw slider bar */
|
||||||
nk_fill_rect(out, bar, style->rounding, bar_color);
|
nk_fill_rect(out, bar, style->rounding, nk_rgb_factor(bar_color, style->color_factor));
|
||||||
nk_fill_rect(out, fill, style->rounding, style->bar_filled);
|
nk_fill_rect(out, fill, style->rounding, nk_rgb_factor(style->bar_filled, style->color_factor));
|
||||||
|
|
||||||
/* draw cursor */
|
/* draw cursor */
|
||||||
if (cursor->type == NK_STYLE_ITEM_IMAGE)
|
if (cursor->type == NK_STYLE_ITEM_IMAGE)
|
||||||
nk_draw_image(out, *visual_cursor, &cursor->data.image, nk_white);
|
nk_draw_image(out, *visual_cursor, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
else
|
else
|
||||||
nk_fill_circle(out, *visual_cursor, cursor->data.color);
|
nk_fill_circle(out, *visual_cursor, nk_rgb_factor(cursor->data.color, style->color_factor));
|
||||||
}
|
}
|
||||||
NK_LIB float
|
NK_LIB float
|
||||||
nk_do_slider(nk_flags *state,
|
nk_do_slider(nk_flags *state,
|
||||||
|
@ -230,7 +231,7 @@ nk_slider_float(struct nk_context *ctx, float min_value, float *value, float max
|
||||||
|
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return ret;
|
if (!state) return ret;
|
||||||
in = (/*state == NK_WIDGET_ROM || */ layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
in = (/*state == NK_WIDGET_ROM || */ state == NK_WIDGET_DISABLED || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
||||||
|
|
||||||
old_value = *value;
|
old_value = *value;
|
||||||
*value = nk_do_slider(&ctx->last_widget_state, &win->buffer, bounds, min_value,
|
*value = nk_do_slider(&ctx->last_widget_state, &win->buffer, bounds, min_value,
|
||||||
|
|
|
@ -113,27 +113,32 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
text = &style->text;
|
text = &style->text;
|
||||||
text->color = table[NK_COLOR_TEXT];
|
text->color = table[NK_COLOR_TEXT];
|
||||||
text->padding = nk_vec2(0,0);
|
text->padding = nk_vec2(0,0);
|
||||||
|
text->color_factor = 1.0f;
|
||||||
|
text->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
|
|
||||||
/* default button */
|
/* default button */
|
||||||
button = &style->button;
|
button = &style->button;
|
||||||
nk_zero_struct(*button);
|
nk_zero_struct(*button);
|
||||||
button->normal = nk_style_item_color(table[NK_COLOR_BUTTON]);
|
button->normal = nk_style_item_color(table[NK_COLOR_BUTTON]);
|
||||||
button->hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]);
|
button->hover = nk_style_item_color(table[NK_COLOR_BUTTON_HOVER]);
|
||||||
button->active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]);
|
button->active = nk_style_item_color(table[NK_COLOR_BUTTON_ACTIVE]);
|
||||||
button->border_color = table[NK_COLOR_BORDER];
|
button->border_color = table[NK_COLOR_BORDER];
|
||||||
button->text_background = table[NK_COLOR_BUTTON];
|
button->text_background = table[NK_COLOR_BUTTON];
|
||||||
button->text_normal = table[NK_COLOR_TEXT];
|
button->text_normal = table[NK_COLOR_TEXT];
|
||||||
button->text_hover = table[NK_COLOR_TEXT];
|
button->text_hover = table[NK_COLOR_TEXT];
|
||||||
button->text_active = table[NK_COLOR_TEXT];
|
button->text_active = table[NK_COLOR_TEXT];
|
||||||
button->padding = nk_vec2(2.0f,2.0f);
|
button->padding = nk_vec2(2.0f,2.0f);
|
||||||
button->image_padding = nk_vec2(0.0f,0.0f);
|
button->image_padding = nk_vec2(0.0f,0.0f);
|
||||||
button->touch_padding = nk_vec2(0.0f, 0.0f);
|
button->touch_padding = nk_vec2(0.0f, 0.0f);
|
||||||
button->userdata = nk_handle_ptr(0);
|
button->userdata = nk_handle_ptr(0);
|
||||||
button->text_alignment = NK_TEXT_CENTERED;
|
button->text_alignment = NK_TEXT_CENTERED;
|
||||||
button->border = 1.0f;
|
button->border = 1.0f;
|
||||||
button->rounding = 4.0f;
|
button->rounding = 4.0f;
|
||||||
button->draw_begin = 0;
|
button->color_factor_text = 1.0f;
|
||||||
button->draw_end = 0;
|
button->color_factor_background = 1.0f;
|
||||||
|
button->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
|
button->draw_begin = 0;
|
||||||
|
button->draw_end = 0;
|
||||||
|
|
||||||
/* contextual button */
|
/* contextual button */
|
||||||
button = &style->contextual_button;
|
button = &style->contextual_button;
|
||||||
|
@ -152,6 +157,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
button->text_alignment = NK_TEXT_CENTERED;
|
button->text_alignment = NK_TEXT_CENTERED;
|
||||||
button->border = 0.0f;
|
button->border = 0.0f;
|
||||||
button->rounding = 0.0f;
|
button->rounding = 0.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_begin = 0;
|
||||||
button->draw_end = 0;
|
button->draw_end = 0;
|
||||||
|
|
||||||
|
@ -172,6 +180,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
button->text_alignment = NK_TEXT_CENTERED;
|
button->text_alignment = NK_TEXT_CENTERED;
|
||||||
button->border = 0.0f;
|
button->border = 0.0f;
|
||||||
button->rounding = 1.0f;
|
button->rounding = 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_begin = 0;
|
||||||
button->draw_end = 0;
|
button->draw_end = 0;
|
||||||
|
|
||||||
|
@ -193,6 +204,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
toggle->border_color = nk_rgba(0,0,0,0);
|
toggle->border_color = nk_rgba(0,0,0,0);
|
||||||
toggle->border = 0.0f;
|
toggle->border = 0.0f;
|
||||||
toggle->spacing = 4;
|
toggle->spacing = 4;
|
||||||
|
toggle->color_factor = 1.0f;
|
||||||
|
toggle->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
|
|
||||||
/* option toggle */
|
/* option toggle */
|
||||||
toggle = &style->option;
|
toggle = &style->option;
|
||||||
|
@ -212,6 +225,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
toggle->border_color = nk_rgba(0,0,0,0);
|
toggle->border_color = nk_rgba(0,0,0,0);
|
||||||
toggle->border = 0.0f;
|
toggle->border = 0.0f;
|
||||||
toggle->spacing = 4;
|
toggle->spacing = 4;
|
||||||
|
toggle->color_factor = 1.0f;
|
||||||
|
toggle->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
|
|
||||||
/* selectable */
|
/* selectable */
|
||||||
select = &style->selectable;
|
select = &style->selectable;
|
||||||
|
@ -233,6 +248,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
select->touch_padding = nk_vec2(0,0);
|
select->touch_padding = nk_vec2(0,0);
|
||||||
select->userdata = nk_handle_ptr(0);
|
select->userdata = nk_handle_ptr(0);
|
||||||
select->rounding = 0.0f;
|
select->rounding = 0.0f;
|
||||||
|
select->color_factor = 1.0f;
|
||||||
|
select->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
select->draw_begin = 0;
|
select->draw_begin = 0;
|
||||||
select->draw_end = 0;
|
select->draw_end = 0;
|
||||||
|
|
||||||
|
@ -258,6 +275,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
slider->show_buttons = nk_false;
|
slider->show_buttons = nk_false;
|
||||||
slider->bar_height = 8;
|
slider->bar_height = 8;
|
||||||
slider->rounding = 0;
|
slider->rounding = 0;
|
||||||
|
slider->color_factor = 1.0f;
|
||||||
|
slider->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
slider->draw_begin = 0;
|
slider->draw_begin = 0;
|
||||||
slider->draw_end = 0;
|
slider->draw_end = 0;
|
||||||
|
|
||||||
|
@ -277,6 +296,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
button->text_alignment = NK_TEXT_CENTERED;
|
button->text_alignment = NK_TEXT_CENTERED;
|
||||||
button->border = 1.0f;
|
button->border = 1.0f;
|
||||||
button->rounding = 0.0f;
|
button->rounding = 0.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_begin = 0;
|
||||||
button->draw_end = 0;
|
button->draw_end = 0;
|
||||||
style->slider.dec_button = style->slider.inc_button;
|
style->slider.dec_button = style->slider.inc_button;
|
||||||
|
@ -298,6 +320,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
prog->border = 0;
|
prog->border = 0;
|
||||||
prog->cursor_rounding = 0;
|
prog->cursor_rounding = 0;
|
||||||
prog->cursor_border = 0;
|
prog->cursor_border = 0;
|
||||||
|
prog->color_factor = 1.0f;
|
||||||
|
prog->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
prog->draw_begin = 0;
|
prog->draw_begin = 0;
|
||||||
prog->draw_end = 0;
|
prog->draw_end = 0;
|
||||||
|
|
||||||
|
@ -321,6 +345,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
scroll->rounding = 0;
|
scroll->rounding = 0;
|
||||||
scroll->border_cursor = 0;
|
scroll->border_cursor = 0;
|
||||||
scroll->rounding_cursor = 0;
|
scroll->rounding_cursor = 0;
|
||||||
|
scroll->color_factor = 1.0f;
|
||||||
|
scroll->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
scroll->draw_begin = 0;
|
scroll->draw_begin = 0;
|
||||||
scroll->draw_end = 0;
|
scroll->draw_end = 0;
|
||||||
style->scrollv = style->scrollh;
|
style->scrollv = style->scrollh;
|
||||||
|
@ -341,6 +367,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
button->text_alignment = NK_TEXT_CENTERED;
|
button->text_alignment = NK_TEXT_CENTERED;
|
||||||
button->border = 1.0f;
|
button->border = 1.0f;
|
||||||
button->rounding = 0.0f;
|
button->rounding = 0.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_begin = 0;
|
||||||
button->draw_end = 0;
|
button->draw_end = 0;
|
||||||
style->scrollh.dec_button = style->scrollh.inc_button;
|
style->scrollh.dec_button = style->scrollh.inc_button;
|
||||||
|
@ -372,6 +401,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
edit->cursor_size = 4;
|
edit->cursor_size = 4;
|
||||||
edit->border = 1;
|
edit->border = 1;
|
||||||
edit->rounding = 0;
|
edit->rounding = 0;
|
||||||
|
edit->color_factor = 1.0f;
|
||||||
|
edit->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
|
|
||||||
/* property */
|
/* property */
|
||||||
property = &style->property;
|
property = &style->property;
|
||||||
|
@ -391,6 +422,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
property->rounding = 10;
|
property->rounding = 10;
|
||||||
property->draw_begin = 0;
|
property->draw_begin = 0;
|
||||||
property->draw_end = 0;
|
property->draw_end = 0;
|
||||||
|
property->color_factor = 1.0f;
|
||||||
|
property->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
|
|
||||||
/* property buttons */
|
/* property buttons */
|
||||||
button = &style->property.dec_button;
|
button = &style->property.dec_button;
|
||||||
|
@ -409,6 +442,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
button->text_alignment = NK_TEXT_CENTERED;
|
button->text_alignment = NK_TEXT_CENTERED;
|
||||||
button->border = 0.0f;
|
button->border = 0.0f;
|
||||||
button->rounding = 0.0f;
|
button->rounding = 0.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_begin = 0;
|
||||||
button->draw_end = 0;
|
button->draw_end = 0;
|
||||||
style->property.inc_button = style->property.dec_button;
|
style->property.inc_button = style->property.dec_button;
|
||||||
|
@ -435,6 +471,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
edit->cursor_size = 8;
|
edit->cursor_size = 8;
|
||||||
edit->border = 0;
|
edit->border = 0;
|
||||||
edit->rounding = 0;
|
edit->rounding = 0;
|
||||||
|
edit->color_factor = 1.0f;
|
||||||
|
edit->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
|
|
||||||
/* chart */
|
/* chart */
|
||||||
chart = &style->chart;
|
chart = &style->chart;
|
||||||
|
@ -446,6 +484,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
chart->padding = nk_vec2(4,4);
|
chart->padding = nk_vec2(4,4);
|
||||||
chart->border = 0;
|
chart->border = 0;
|
||||||
chart->rounding = 0;
|
chart->rounding = 0;
|
||||||
|
chart->color_factor = 1.0f;
|
||||||
|
chart->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
|
chart->show_markers = nk_true;
|
||||||
|
|
||||||
/* combo */
|
/* combo */
|
||||||
combo = &style->combo;
|
combo = &style->combo;
|
||||||
|
@ -464,6 +505,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
combo->spacing = nk_vec2(4,0);
|
combo->spacing = nk_vec2(4,0);
|
||||||
combo->border = 1;
|
combo->border = 1;
|
||||||
combo->rounding = 0;
|
combo->rounding = 0;
|
||||||
|
combo->color_factor = 1.0f;
|
||||||
|
combo->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
|
|
||||||
/* combo button */
|
/* combo button */
|
||||||
button = &style->combo.button;
|
button = &style->combo.button;
|
||||||
|
@ -482,6 +525,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
button->text_alignment = NK_TEXT_CENTERED;
|
button->text_alignment = NK_TEXT_CENTERED;
|
||||||
button->border = 0.0f;
|
button->border = 0.0f;
|
||||||
button->rounding = 0.0f;
|
button->rounding = 0.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_begin = 0;
|
||||||
button->draw_end = 0;
|
button->draw_end = 0;
|
||||||
|
|
||||||
|
@ -497,6 +543,8 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
tab->indent = 10.0f;
|
tab->indent = 10.0f;
|
||||||
tab->border = 1;
|
tab->border = 1;
|
||||||
tab->rounding = 0;
|
tab->rounding = 0;
|
||||||
|
tab->color_factor = 1.0f;
|
||||||
|
tab->disabled_factor = NK_WIDGET_DISABLED_FACTOR;
|
||||||
|
|
||||||
/* tab button */
|
/* tab button */
|
||||||
button = &style->tab.tab_minimize_button;
|
button = &style->tab.tab_minimize_button;
|
||||||
|
@ -515,6 +563,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
button->text_alignment = NK_TEXT_CENTERED;
|
button->text_alignment = NK_TEXT_CENTERED;
|
||||||
button->border = 0.0f;
|
button->border = 0.0f;
|
||||||
button->rounding = 0.0f;
|
button->rounding = 0.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_begin = 0;
|
||||||
button->draw_end = 0;
|
button->draw_end = 0;
|
||||||
style->tab.tab_maximize_button =*button;
|
style->tab.tab_maximize_button =*button;
|
||||||
|
@ -536,6 +587,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
button->text_alignment = NK_TEXT_CENTERED;
|
button->text_alignment = NK_TEXT_CENTERED;
|
||||||
button->border = 0.0f;
|
button->border = 0.0f;
|
||||||
button->rounding = 0.0f;
|
button->rounding = 0.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_begin = 0;
|
||||||
button->draw_end = 0;
|
button->draw_end = 0;
|
||||||
style->tab.node_maximize_button =*button;
|
style->tab.node_maximize_button =*button;
|
||||||
|
@ -573,6 +627,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
button->text_alignment = NK_TEXT_CENTERED;
|
button->text_alignment = NK_TEXT_CENTERED;
|
||||||
button->border = 0.0f;
|
button->border = 0.0f;
|
||||||
button->rounding = 0.0f;
|
button->rounding = 0.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_begin = 0;
|
||||||
button->draw_end = 0;
|
button->draw_end = 0;
|
||||||
|
|
||||||
|
@ -593,6 +650,9 @@ nk_style_from_table(struct nk_context *ctx, const struct nk_color *table)
|
||||||
button->text_alignment = NK_TEXT_CENTERED;
|
button->text_alignment = NK_TEXT_CENTERED;
|
||||||
button->border = 0.0f;
|
button->border = 0.0f;
|
||||||
button->rounding = 0.0f;
|
button->rounding = 0.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_begin = 0;
|
||||||
button->draw_end = 0;
|
button->draw_end = 0;
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ nk_text_colored(struct nk_context *ctx, const char *str, int len,
|
||||||
text.padding.x = item_padding.x;
|
text.padding.x = item_padding.x;
|
||||||
text.padding.y = item_padding.y;
|
text.padding.y = item_padding.y;
|
||||||
text.background = style->window.background;
|
text.background = style->window.background;
|
||||||
text.text = color;
|
text.text = nk_rgb_factor(color, style->text.color_factor);
|
||||||
nk_widget_text(&win->buffer, bounds, str, len, &text, alignment, style->font);
|
nk_widget_text(&win->buffer, bounds, str, len, &text, alignment, style->font);
|
||||||
}
|
}
|
||||||
NK_API void
|
NK_API void
|
||||||
|
@ -141,7 +141,7 @@ nk_text_wrap_colored(struct nk_context *ctx, const char *str,
|
||||||
text.padding.x = item_padding.x;
|
text.padding.x = item_padding.x;
|
||||||
text.padding.y = item_padding.y;
|
text.padding.y = item_padding.y;
|
||||||
text.background = style->window.background;
|
text.background = style->window.background;
|
||||||
text.text = color;
|
text.text = nk_rgb_factor(color, style->text.color_factor);
|
||||||
nk_widget_text_wrap(&win->buffer, bounds, str, len, &text, style->font);
|
nk_widget_text_wrap(&win->buffer, bounds, str, len, &text, style->font);
|
||||||
}
|
}
|
||||||
#ifdef NK_INCLUDE_STANDARD_VARARGS
|
#ifdef NK_INCLUDE_STANDARD_VARARGS
|
||||||
|
|
|
@ -26,7 +26,7 @@ nk_draw_checkbox(struct nk_command_buffer *out,
|
||||||
nk_flags state, const struct nk_style_toggle *style, nk_bool active,
|
nk_flags state, const struct nk_style_toggle *style, nk_bool active,
|
||||||
const struct nk_rect *label, const struct nk_rect *selector,
|
const struct nk_rect *label, const struct nk_rect *selector,
|
||||||
const struct nk_rect *cursors, const char *string, int len,
|
const struct nk_rect *cursors, const char *string, int len,
|
||||||
const struct nk_user_font *font)
|
const struct nk_user_font *font, nk_flags text_alignment)
|
||||||
{
|
{
|
||||||
const struct nk_style_item *background;
|
const struct nk_style_item *background;
|
||||||
const struct nk_style_item *cursor;
|
const struct nk_style_item *cursor;
|
||||||
|
@ -47,28 +47,29 @@ nk_draw_checkbox(struct nk_command_buffer *out,
|
||||||
text.text = style->text_normal;
|
text.text = style->text_normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw background and cursor */
|
text.text = nk_rgb_factor(text.text, style->color_factor);
|
||||||
if (background->type == NK_STYLE_ITEM_COLOR) {
|
|
||||||
nk_fill_rect(out, *selector, 0, style->border_color);
|
|
||||||
nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, background->data.color);
|
|
||||||
} else nk_draw_image(out, *selector, &background->data.image, nk_white);
|
|
||||||
if (active) {
|
|
||||||
if (cursor->type == NK_STYLE_ITEM_IMAGE)
|
|
||||||
nk_draw_image(out, *cursors, &cursor->data.image, nk_white);
|
|
||||||
else nk_fill_rect(out, *cursors, 0, cursor->data.color);
|
|
||||||
}
|
|
||||||
|
|
||||||
text.padding.x = 0;
|
text.padding.x = 0;
|
||||||
text.padding.y = 0;
|
text.padding.y = 0;
|
||||||
text.background = style->text_background;
|
text.background = style->text_background;
|
||||||
nk_widget_text(out, *label, string, len, &text, NK_TEXT_LEFT, font);
|
nk_widget_text(out, *label, string, len, &text, text_alignment, font);
|
||||||
|
|
||||||
|
/* draw background and cursor */
|
||||||
|
if (background->type == NK_STYLE_ITEM_COLOR) {
|
||||||
|
nk_fill_rect(out, *selector, 0, nk_rgb_factor(style->border_color, style->color_factor));
|
||||||
|
nk_fill_rect(out, nk_shrink_rect(*selector, style->border), 0, nk_rgb_factor(background->data.color, style->color_factor));
|
||||||
|
} else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
|
if (active) {
|
||||||
|
if (cursor->type == NK_STYLE_ITEM_IMAGE)
|
||||||
|
nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
|
else nk_fill_rect(out, *cursors, 0, cursor->data.color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NK_LIB void
|
NK_LIB void
|
||||||
nk_draw_option(struct nk_command_buffer *out,
|
nk_draw_option(struct nk_command_buffer *out,
|
||||||
nk_flags state, const struct nk_style_toggle *style, nk_bool active,
|
nk_flags state, const struct nk_style_toggle *style, nk_bool active,
|
||||||
const struct nk_rect *label, const struct nk_rect *selector,
|
const struct nk_rect *label, const struct nk_rect *selector,
|
||||||
const struct nk_rect *cursors, const char *string, int len,
|
const struct nk_rect *cursors, const char *string, int len,
|
||||||
const struct nk_user_font *font)
|
const struct nk_user_font *font, nk_flags text_alignment)
|
||||||
{
|
{
|
||||||
const struct nk_style_item *background;
|
const struct nk_style_item *background;
|
||||||
const struct nk_style_item *cursor;
|
const struct nk_style_item *cursor;
|
||||||
|
@ -89,28 +90,29 @@ nk_draw_option(struct nk_command_buffer *out,
|
||||||
text.text = style->text_normal;
|
text.text = style->text_normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw background and cursor */
|
text.text = nk_rgb_factor(text.text, style->color_factor);
|
||||||
if (background->type == NK_STYLE_ITEM_COLOR) {
|
|
||||||
nk_fill_circle(out, *selector, style->border_color);
|
|
||||||
nk_fill_circle(out, nk_shrink_rect(*selector, style->border), background->data.color);
|
|
||||||
} else nk_draw_image(out, *selector, &background->data.image, nk_white);
|
|
||||||
if (active) {
|
|
||||||
if (cursor->type == NK_STYLE_ITEM_IMAGE)
|
|
||||||
nk_draw_image(out, *cursors, &cursor->data.image, nk_white);
|
|
||||||
else nk_fill_circle(out, *cursors, cursor->data.color);
|
|
||||||
}
|
|
||||||
|
|
||||||
text.padding.x = 0;
|
text.padding.x = 0;
|
||||||
text.padding.y = 0;
|
text.padding.y = 0;
|
||||||
text.background = style->text_background;
|
text.background = style->text_background;
|
||||||
nk_widget_text(out, *label, string, len, &text, NK_TEXT_LEFT, font);
|
nk_widget_text(out, *label, string, len, &text, text_alignment, font);
|
||||||
|
|
||||||
|
/* draw background and cursor */
|
||||||
|
if (background->type == NK_STYLE_ITEM_COLOR) {
|
||||||
|
nk_fill_circle(out, *selector, nk_rgb_factor(style->border_color, style->color_factor));
|
||||||
|
nk_fill_circle(out, nk_shrink_rect(*selector, style->border), nk_rgb_factor(background->data.color, style->color_factor));
|
||||||
|
} else nk_draw_image(out, *selector, &background->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
|
if (active) {
|
||||||
|
if (cursor->type == NK_STYLE_ITEM_IMAGE)
|
||||||
|
nk_draw_image(out, *cursors, &cursor->data.image, nk_rgb_factor(nk_white, style->color_factor));
|
||||||
|
else nk_fill_circle(out, *cursors, cursor->data.color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NK_LIB nk_bool
|
NK_LIB nk_bool
|
||||||
nk_do_toggle(nk_flags *state,
|
nk_do_toggle(nk_flags *state,
|
||||||
struct nk_command_buffer *out, struct nk_rect r,
|
struct nk_command_buffer *out, struct nk_rect r,
|
||||||
nk_bool *active, const char *str, int len, enum nk_toggle_type type,
|
nk_bool *active, const char *str, int len, enum nk_toggle_type type,
|
||||||
const struct nk_style_toggle *style, const struct nk_input *in,
|
const struct nk_style_toggle *style, const struct nk_input *in,
|
||||||
const struct nk_user_font *font)
|
const struct nk_user_font *font, nk_flags widget_alignment, nk_flags text_alignment)
|
||||||
{
|
{
|
||||||
int was_active;
|
int was_active;
|
||||||
struct nk_rect bounds;
|
struct nk_rect bounds;
|
||||||
|
@ -136,8 +138,37 @@ nk_do_toggle(nk_flags *state,
|
||||||
/* calculate the selector space */
|
/* calculate the selector space */
|
||||||
select.w = font->height;
|
select.w = font->height;
|
||||||
select.h = select.w;
|
select.h = select.w;
|
||||||
select.y = r.y + r.h/2.0f - select.h/2.0f;
|
|
||||||
select.x = r.x;
|
if (widget_alignment & NK_WIDGET_ALIGN_RIGHT) {
|
||||||
|
select.x = r.x + r.w - font->height;
|
||||||
|
|
||||||
|
/* label in front of the selector */
|
||||||
|
label.x = r.x;
|
||||||
|
label.w = r.w - select.w - style->spacing * 2;
|
||||||
|
} else if (widget_alignment & NK_WIDGET_ALIGN_CENTERED) {
|
||||||
|
select.x = r.x + (r.w - select.w) / 2;
|
||||||
|
|
||||||
|
/* label in front of selector */
|
||||||
|
label.x = r.x;
|
||||||
|
label.w = (r.w - select.w - style->spacing * 2) / 2;
|
||||||
|
} else { /* Default: NK_WIDGET_ALIGN_LEFT */
|
||||||
|
select.x = r.x;
|
||||||
|
|
||||||
|
/* label behind the selector */
|
||||||
|
label.x = select.x + select.w + style->spacing;
|
||||||
|
label.w = NK_MAX(r.x + r.w, label.x) - label.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (widget_alignment & NK_WIDGET_ALIGN_TOP) {
|
||||||
|
select.y = r.y;
|
||||||
|
} else if (widget_alignment & NK_WIDGET_ALIGN_BOTTOM) {
|
||||||
|
select.y = r.y + r.h - select.h - 2 * style->padding.y;
|
||||||
|
} else { /* Default: NK_WIDGET_ALIGN_MIDDLE */
|
||||||
|
select.y = r.y + r.h/2.0f - select.h/2.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
label.y = select.y;
|
||||||
|
label.h = select.w;
|
||||||
|
|
||||||
/* calculate the bounds of the cursor inside the selector */
|
/* calculate the bounds of the cursor inside the selector */
|
||||||
cursor.x = select.x + style->padding.x + style->border;
|
cursor.x = select.x + style->padding.x + style->border;
|
||||||
|
@ -145,12 +176,6 @@ nk_do_toggle(nk_flags *state,
|
||||||
cursor.w = select.w - (2 * style->padding.x + 2 * style->border);
|
cursor.w = select.w - (2 * style->padding.x + 2 * style->border);
|
||||||
cursor.h = select.h - (2 * style->padding.y + 2 * style->border);
|
cursor.h = select.h - (2 * style->padding.y + 2 * style->border);
|
||||||
|
|
||||||
/* label behind the selector */
|
|
||||||
label.x = select.x + select.w + style->spacing;
|
|
||||||
label.y = select.y;
|
|
||||||
label.w = NK_MAX(r.x + r.w, label.x) - label.x;
|
|
||||||
label.h = select.w;
|
|
||||||
|
|
||||||
/* update selector */
|
/* update selector */
|
||||||
was_active = *active;
|
was_active = *active;
|
||||||
*active = nk_toggle_behavior(in, bounds, state, *active);
|
*active = nk_toggle_behavior(in, bounds, state, *active);
|
||||||
|
@ -159,9 +184,9 @@ nk_do_toggle(nk_flags *state,
|
||||||
if (style->draw_begin)
|
if (style->draw_begin)
|
||||||
style->draw_begin(out, style->userdata);
|
style->draw_begin(out, style->userdata);
|
||||||
if (type == NK_TOGGLE_CHECK) {
|
if (type == NK_TOGGLE_CHECK) {
|
||||||
nk_draw_checkbox(out, *state, style, *active, &label, &select, &cursor, str, len, font);
|
nk_draw_checkbox(out, *state, style, *active, &label, &select, &cursor, str, len, font, text_alignment);
|
||||||
} else {
|
} else {
|
||||||
nk_draw_option(out, *state, style, *active, &label, &select, &cursor, str, len, font);
|
nk_draw_option(out, *state, style, *active, &label, &select, &cursor, str, len, font, text_alignment);
|
||||||
}
|
}
|
||||||
if (style->draw_end)
|
if (style->draw_end)
|
||||||
style->draw_end(out, style->userdata);
|
style->draw_end(out, style->userdata);
|
||||||
|
@ -195,9 +220,37 @@ nk_check_text(struct nk_context *ctx, const char *text, int len, nk_bool active)
|
||||||
|
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return active;
|
if (!state) return active;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
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,
|
nk_do_toggle(&ctx->last_widget_state, &win->buffer, bounds, &active,
|
||||||
text, len, NK_TOGGLE_CHECK, &style->checkbox, in, style->font);
|
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;
|
||||||
|
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, widget_alignment, text_alignment);
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
NK_API unsigned int
|
NK_API unsigned int
|
||||||
|
@ -227,6 +280,18 @@ nk_checkbox_text(struct nk_context *ctx, const char *text, int len, nk_bool *act
|
||||||
return old_val != *active;
|
return old_val != *active;
|
||||||
}
|
}
|
||||||
NK_API nk_bool
|
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,
|
nk_checkbox_flags_text(struct nk_context *ctx, const char *text, int len,
|
||||||
unsigned int *flags, unsigned int value)
|
unsigned int *flags, unsigned int value)
|
||||||
{
|
{
|
||||||
|
@ -257,6 +322,10 @@ NK_API nk_bool nk_checkbox_label(struct nk_context *ctx, const char *label, nk_b
|
||||||
{
|
{
|
||||||
return nk_checkbox_text(ctx, label, nk_strlen(label), active);
|
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,
|
NK_API nk_bool nk_checkbox_flags_label(struct nk_context *ctx, const char *label,
|
||||||
unsigned int *flags, unsigned int value)
|
unsigned int *flags, unsigned int value)
|
||||||
{
|
{
|
||||||
|
@ -290,9 +359,37 @@ nk_option_text(struct nk_context *ctx, const char *text, int len, nk_bool is_act
|
||||||
|
|
||||||
state = nk_widget(&bounds, ctx);
|
state = nk_widget(&bounds, ctx);
|
||||||
if (!state) return (int)state;
|
if (!state) return (int)state;
|
||||||
in = (state == NK_WIDGET_ROM || layout->flags & NK_WINDOW_ROM) ? 0 : &ctx->input;
|
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,
|
nk_do_toggle(&ctx->last_widget_state, &win->buffer, bounds, &is_active,
|
||||||
text, len, NK_TOGGLE_OPTION, &style->option, in, style->font);
|
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;
|
||||||
|
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, widget_alignment, text_alignment);
|
||||||
return is_active;
|
return is_active;
|
||||||
}
|
}
|
||||||
NK_API nk_bool
|
NK_API nk_bool
|
||||||
|
@ -308,13 +405,35 @@ nk_radio_text(struct nk_context *ctx, const char *text, int len, nk_bool *active
|
||||||
return old_value != *active;
|
return old_value != *active;
|
||||||
}
|
}
|
||||||
NK_API nk_bool
|
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)
|
||||||
|
{
|
||||||
|
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_option_label(struct nk_context *ctx, const char *label, nk_bool active)
|
nk_option_label(struct nk_context *ctx, const char *label, nk_bool active)
|
||||||
{
|
{
|
||||||
return nk_option_text(ctx, label, nk_strlen(label), active);
|
return nk_option_text(ctx, label, nk_strlen(label), active);
|
||||||
}
|
}
|
||||||
NK_API nk_bool
|
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)
|
nk_radio_label(struct nk_context *ctx, const char *label, nk_bool *active)
|
||||||
{
|
{
|
||||||
return nk_radio_text(ctx, label, nk_strlen(label), 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ nk_tooltip_begin(struct nk_context *ctx, float width)
|
||||||
/* make sure that no nonblocking popup is currently active */
|
/* make sure that no nonblocking popup is currently active */
|
||||||
win = ctx->current;
|
win = ctx->current;
|
||||||
in = &ctx->input;
|
in = &ctx->input;
|
||||||
if (win->popup.win && (win->popup.type & NK_PANEL_SET_NONBLOCK))
|
if (win->popup.win && ((int)win->popup.type & (int)NK_PANEL_SET_NONBLOCK))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
w = nk_iceilf(width);
|
w = nk_iceilf(width);
|
||||||
|
|
|
@ -52,15 +52,15 @@ nk_tree_state_base(struct nk_context *ctx, enum nk_tree_type type,
|
||||||
|
|
||||||
switch(background->type) {
|
switch(background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
nk_draw_image(out, header, &background->data.image, nk_white);
|
nk_draw_image(out, header, &background->data.image, nk_rgb_factor(nk_white, style->tab.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
nk_draw_nine_slice(out, header, &background->data.slice, nk_white);
|
nk_draw_nine_slice(out, header, &background->data.slice, nk_rgb_factor(nk_white, style->tab.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
nk_fill_rect(out, header, 0, style->tab.border_color);
|
nk_fill_rect(out, header, 0, nk_rgb_factor(style->tab.border_color, style->tab.color_factor));
|
||||||
nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
|
nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
|
||||||
style->tab.rounding, background->data.color);
|
style->tab.rounding, nk_rgb_factor(background->data.color, style->tab.color_factor));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else text.background = style->window.background;
|
} else text.background = style->window.background;
|
||||||
|
@ -105,7 +105,7 @@ nk_tree_state_base(struct nk_context *ctx, enum nk_tree_type type,
|
||||||
label.y = sym.y;
|
label.y = sym.y;
|
||||||
label.w = header.w - (sym.w + item_spacing.y + style->tab.indent);
|
label.w = header.w - (sym.w + item_spacing.y + style->tab.indent);
|
||||||
label.h = style->font->height;
|
label.h = style->font->height;
|
||||||
text.text = style->tab.text;
|
text.text = nk_rgb_factor(style->tab.text, style->tab.color_factor);
|
||||||
text.padding = nk_vec2(0,0);
|
text.padding = nk_vec2(0,0);
|
||||||
nk_widget_text(out, label, title, nk_strlen(title), &text,
|
nk_widget_text(out, label, title, nk_strlen(title), &text,
|
||||||
NK_TEXT_LEFT, style->font);}
|
NK_TEXT_LEFT, style->font);}
|
||||||
|
@ -242,15 +242,16 @@ nk_tree_element_image_push_hashed_base(struct nk_context *ctx, enum nk_tree_type
|
||||||
|
|
||||||
switch (background->type) {
|
switch (background->type) {
|
||||||
case NK_STYLE_ITEM_IMAGE:
|
case NK_STYLE_ITEM_IMAGE:
|
||||||
nk_draw_image(out, header, &background->data.image, nk_white);
|
nk_draw_image(out, header, &background->data.image, nk_rgb_factor(nk_white, style->tab.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_NINE_SLICE:
|
case NK_STYLE_ITEM_NINE_SLICE:
|
||||||
nk_draw_nine_slice(out, header, &background->data.slice, nk_white);
|
nk_draw_nine_slice(out, header, &background->data.slice, nk_rgb_factor(nk_white, style->tab.color_factor));
|
||||||
break;
|
break;
|
||||||
case NK_STYLE_ITEM_COLOR:
|
case NK_STYLE_ITEM_COLOR:
|
||||||
nk_fill_rect(out, header, 0, style->tab.border_color);
|
nk_fill_rect(out, header, 0, nk_rgb_factor(style->tab.border_color, style->tab.color_factor));
|
||||||
nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
|
nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
|
||||||
style->tab.rounding, background->data.color);
|
style->tab.rounding, nk_rgb_factor(background->data.color, style->tab.color_factor));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,8 @@ nk_widget(struct nk_rect *bounds, const struct nk_context *ctx)
|
||||||
nk_unify(&v, &c, bounds->x, bounds->y, bounds->x + bounds->w, bounds->y + bounds->h);
|
nk_unify(&v, &c, bounds->x, bounds->y, bounds->x + bounds->w, bounds->y + bounds->h);
|
||||||
if (!NK_INTERSECT(c.x, c.y, c.w, c.h, bounds->x, bounds->y, bounds->w, bounds->h))
|
if (!NK_INTERSECT(c.x, c.y, c.w, c.h, bounds->x, bounds->y, bounds->w, bounds->h))
|
||||||
return NK_WIDGET_INVALID;
|
return NK_WIDGET_INVALID;
|
||||||
|
if (win->widgets_disabled)
|
||||||
|
return NK_WIDGET_DISABLED;
|
||||||
if (!NK_INBOX(in->mouse.pos.x, in->mouse.pos.y, v.x, v.y, v.w, v.h))
|
if (!NK_INBOX(in->mouse.pos.x, in->mouse.pos.y, v.x, v.y, v.w, v.h))
|
||||||
return NK_WIDGET_ROM;
|
return NK_WIDGET_ROM;
|
||||||
return NK_WIDGET_VALID;
|
return NK_WIDGET_VALID;
|
||||||
|
@ -227,4 +229,129 @@ nk_spacing(struct nk_context *ctx, int cols)
|
||||||
nk_panel_alloc_space(&none, ctx);
|
nk_panel_alloc_space(&none, ctx);
|
||||||
} layout->row.index = index;
|
} layout->row.index = index;
|
||||||
}
|
}
|
||||||
|
NK_API void
|
||||||
|
nk_widget_disable_begin(struct nk_context* ctx)
|
||||||
|
{
|
||||||
|
struct nk_window* win;
|
||||||
|
struct nk_style* style;
|
||||||
|
|
||||||
|
NK_ASSERT(ctx);
|
||||||
|
NK_ASSERT(ctx->current);
|
||||||
|
|
||||||
|
if (!ctx || !ctx->current)
|
||||||
|
return;
|
||||||
|
|
||||||
|
win = ctx->current;
|
||||||
|
style = &ctx->style;
|
||||||
|
|
||||||
|
win->widgets_disabled = nk_true;
|
||||||
|
|
||||||
|
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_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_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_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_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_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_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_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
|
||||||
|
nk_widget_disable_end(struct nk_context* ctx)
|
||||||
|
{
|
||||||
|
struct nk_window* win;
|
||||||
|
struct nk_style* style;
|
||||||
|
|
||||||
|
NK_ASSERT(ctx);
|
||||||
|
NK_ASSERT(ctx->current);
|
||||||
|
|
||||||
|
if (!ctx || !ctx->current)
|
||||||
|
return;
|
||||||
|
|
||||||
|
win = ctx->current;
|
||||||
|
style = &ctx->style;
|
||||||
|
|
||||||
|
win->widgets_disabled = nk_false;
|
||||||
|
|
||||||
|
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_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_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_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_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_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_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_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;
|
||||||
|
}
|
||||||
|
|
|
@ -180,6 +180,7 @@ nk_begin_titled(struct nk_context *ctx, const char *name, const char *title,
|
||||||
NK_MEMCPY(win->name_string, name, name_length);
|
NK_MEMCPY(win->name_string, name, name_length);
|
||||||
win->name_string[name_length] = 0;
|
win->name_string[name_length] = 0;
|
||||||
win->popup.win = 0;
|
win->popup.win = 0;
|
||||||
|
win->widgets_disabled = nk_false;
|
||||||
if (!ctx->active)
|
if (!ctx->active)
|
||||||
ctx->active = win;
|
ctx->active = win;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -311,7 +311,7 @@ static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0
|
||||||
if (node->y > min_y) {
|
if (node->y > min_y) {
|
||||||
// raise min_y higher.
|
// raise min_y higher.
|
||||||
// we've accounted for all waste up to min_y,
|
// we've accounted for all waste up to min_y,
|
||||||
// but we'll now add more waste for everything we've visted
|
// but we'll now add more waste for everything we've visited
|
||||||
waste_area += visited_width * (node->y - min_y);
|
waste_area += visited_width * (node->y - min_y);
|
||||||
min_y = node->y;
|
min_y = node->y;
|
||||||
// the first time through, visited_width might be reduced
|
// the first time through, visited_width might be reduced
|
||||||
|
@ -466,7 +466,7 @@ static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, i
|
||||||
|
|
||||||
// insert the new node into the right starting point, and
|
// insert the new node into the right starting point, and
|
||||||
// let 'cur' point to the remaining nodes needing to be
|
// let 'cur' point to the remaining nodes needing to be
|
||||||
// stiched back in
|
// stitched back in
|
||||||
|
|
||||||
cur = *res.prev_link;
|
cur = *res.prev_link;
|
||||||
if (cur->x < res.x) {
|
if (cur->x < res.x) {
|
||||||
|
|
Loading…
Reference in New Issue