Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Immediate-Mode-UI/Nuklear into pa…
Browse files Browse the repository at this point in the history
…tch-1
  • Loading branch information
RobLoach committed Apr 4, 2024
2 parents 6af0db2 + 34ea8bb commit b4e9e92
Show file tree
Hide file tree
Showing 74 changed files with 9,392 additions and 1,481 deletions.
38 changes: 33 additions & 5 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,42 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: apt-update
run: sudo apt-get update -qq
- name: apt get glfw
run: sudo apt-get install -y --no-install-recommends libglfw3 libglfw3-dev libglew-dev
- name: build opengl2
- name: apt get demo-libs
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 allegro5
run: make -C demo/allegro5
- name: build glfw_opengl2
run: make -C demo/glfw_opengl2
- name: build opengl3
- name: build 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
run: make -C example
7 changes: 4 additions & 3 deletions .github/workflows/create-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: butlerlogic/action-autotag@stable
with:
- uses: actions/checkout@v4
- uses: butlerlogic/action-autotag@1.1.2
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
root: clib.json
2 changes: 1 addition & 1 deletion clib.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuklear",
"version": "4.10.7",
"version": "4.12.2",
"repo": "Immediate-Mode-UI/Nuklear",
"description": "A small ANSI C gui toolkit",
"keywords": ["gl", "ui", "toolkit"],
Expand Down
1 change: 1 addition & 0 deletions demo/allegro5/nuklear_allegro5.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ NK_API void nk_allegro5_font_set_font(NkAllegro5Font *font);
* ===============================================================
*/
#ifdef NK_ALLEGRO5_IMPLEMENTATION
#include <stdio.h>

#ifndef NK_ALLEGRO5_TEXT_MAX
#define NK_ALLEGRO5_TEXT_MAX 256
Expand Down
3,372 changes: 2,425 additions & 947 deletions demo/common/filebrowser/stb_image.h

Large diffs are not rendered by default.

110 changes: 64 additions & 46 deletions demo/common/overview.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ static int
overview(struct nk_context *ctx)
{
/* window flags */
static int show_menu = nk_true;
static nk_bool show_menu = nk_true;
static nk_flags window_flags = NK_WINDOW_TITLE|NK_WINDOW_BORDER|NK_WINDOW_SCALABLE|NK_WINDOW_MOVABLE|NK_WINDOW_MINIMIZABLE;
nk_flags actual_window_flags;

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

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

static nk_bool disable_widgets = nk_false;

actual_window_flags = window_flags;
if (!(actual_window_flags & NK_WINDOW_TITLE))
actual_window_flags &= ~(NK_WINDOW_MINIMIZABLE|NK_WINDOW_CLOSABLE);
Expand All @@ -23,7 +25,7 @@ overview(struct nk_context *ctx)
enum menu_states {MENU_DEFAULT, MENU_WINDOWS};
static nk_size mprog = 60;
static int mslider = 10;
static int mcheck = nk_true;
static nk_bool mcheck = nk_true;
nk_menubar_begin(ctx);

/* menu #1 */
Expand All @@ -33,7 +35,7 @@ overview(struct nk_context *ctx)
{
static size_t prog = 40;
static int slider = 10;
static int check = nk_true;
static nk_bool check = nk_true;
nk_layout_row_dynamic(ctx, 25, 1);
if (nk_menu_item_label(ctx, "Hide", NK_TEXT_LEFT))
show_menu = nk_false;
Expand Down Expand Up @@ -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, "Minimizable", &window_flags, NK_WINDOW_MINIMIZABLE);
nk_checkbox_flags_label(ctx, "Scale Left", &window_flags, NK_WINDOW_SCALE_LEFT);
nk_checkbox_label(ctx, "Disable widgets", &disable_widgets);
nk_tree_pop(ctx);
}

if (disable_widgets)
nk_widget_disable_begin(ctx);

if (nk_tree_push(ctx, NK_TREE_TAB, "Widgets", NK_MINIMIZED))
{
enum options {A,B,C};
static int checkbox;
static int option;
static nk_bool checkbox_left_text_left;
static nk_bool checkbox_centered_text_right;
static nk_bool checkbox_right_text_right;
static nk_bool checkbox_right_text_left;
static int option_left;
static int option_right;
if (nk_tree_push(ctx, NK_TREE_NODE, "Text", NK_MINIMIZED))
{
/* Text Widgets */
Expand Down Expand Up @@ -180,6 +190,7 @@ overview(struct nk_context *ctx)
nk_layout_row_static(ctx, 30, 100, 2);
nk_button_symbol_label(ctx, NK_SYMBOL_TRIANGLE_LEFT, "prev", NK_TEXT_RIGHT);
nk_button_symbol_label(ctx, NK_SYMBOL_TRIANGLE_RIGHT, "next", NK_TEXT_LEFT);

nk_tree_pop(ctx);
}

Expand All @@ -201,13 +212,21 @@ overview(struct nk_context *ctx)
static int range_int_max = 4096;
static const float ratio[] = {120, 150};

nk_layout_row_static(ctx, 30, 100, 1);
nk_checkbox_label(ctx, "Checkbox", &checkbox);
nk_layout_row_dynamic(ctx, 0, 1);
nk_checkbox_label(ctx, "CheckLeft TextLeft", &checkbox_left_text_left);
nk_checkbox_label_align(ctx, "CheckCenter TextRight", &checkbox_centered_text_right, NK_WIDGET_ALIGN_CENTERED | NK_WIDGET_ALIGN_MIDDLE, NK_TEXT_RIGHT);
nk_checkbox_label_align(ctx, "CheckRight TextRight", &checkbox_right_text_right, NK_WIDGET_LEFT, NK_TEXT_RIGHT);
nk_checkbox_label_align(ctx, "CheckRight TextLeft", &checkbox_right_text_left, NK_WIDGET_RIGHT, NK_TEXT_LEFT);

nk_layout_row_static(ctx, 30, 80, 3);
option = nk_option_label(ctx, "optionA", option == A) ? A : option;
option = nk_option_label(ctx, "optionB", option == B) ? B : option;
option = nk_option_label(ctx, "optionC", option == C) ? C : option;
option_left = nk_option_label(ctx, "optionA", option_left == A) ? A : option_left;
option_left = nk_option_label(ctx, "optionB", option_left == B) ? B : option_left;
option_left = nk_option_label(ctx, "optionC", option_left == C) ? C : option_left;

nk_layout_row_static(ctx, 30, 80, 3);
option_right = nk_option_label_align(ctx, "optionA", option_right == A, NK_WIDGET_RIGHT, NK_TEXT_RIGHT) ? A : option_right;
option_right = nk_option_label_align(ctx, "optionB", option_right == B, NK_WIDGET_RIGHT, NK_TEXT_RIGHT) ? B : option_right;
option_right = nk_option_label_align(ctx, "optionC", option_right == C, NK_WIDGET_RIGHT, NK_TEXT_RIGHT) ? C : option_right;

nk_layout_row(ctx, NK_STATIC, 30, 2, ratio);
nk_labelf(ctx, NK_TEXT_LEFT, "Slider int");
Expand Down Expand Up @@ -242,35 +261,28 @@ overview(struct nk_context *ctx)

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

nk_layout_row_static(ctx, 30, 80, 1);
if (inactive) {
struct nk_style_button button;
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));
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"))
nk_widget_disable_begin(ctx);
}

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

nk_widget_disable_end(ctx);

nk_tree_pop(ctx);
}


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

if (nk_tree_push(ctx, NK_TREE_NODE, "Horizontal Rule", NK_MINIMIZED))
{
nk_layout_row_dynamic(ctx, 12, 1);
Expand Down Expand Up @@ -620,6 +632,7 @@ overview(struct nk_context *ctx)
float id = 0;
static int col_index = -1;
static int line_index = -1;
static int show_markers = nk_true;
float step = (2*3.141592654f) / 32;

int i;
Expand All @@ -628,7 +641,10 @@ overview(struct nk_context *ctx)
/* line chart */
id = 0;
index = -1;
nk_layout_row_dynamic(ctx, 15, 1);
nk_checkbox_label(ctx, "Show markers", &show_markers);
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)) {
for (i = 0; i < 32; ++i) {
nk_flags res = nk_chart_push(ctx, (float)cos(id));
Expand Down Expand Up @@ -701,8 +717,8 @@ overview(struct nk_context *ctx)
if (nk_tree_push(ctx, NK_TREE_TAB, "Popup", NK_MINIMIZED))
{
static struct nk_color color = {255,0,0, 255};
static int select[4];
static int popup_active;
static nk_bool select[4];
static nk_bool popup_active;
const struct nk_input *in = &ctx->input;
struct nk_rect bounds;

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

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

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

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

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

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

1 change: 1 addition & 0 deletions demo/d3d11/nuklear_d3d11.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ NK_API void nk_d3d11_shutdown(void);
#define COBJMACROS
#include <d3d11.h>

#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <float.h>
Expand Down
1 change: 1 addition & 0 deletions demo/d3d12/nuklear_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ NK_API void nk_d3d12_shutdown(void);
#define COBJMACROS
#include <d3d12.h>

#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <float.h>
Expand Down
1 change: 1 addition & 0 deletions demo/d3d9/nuklear_d3d9.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ NK_API void nk_d3d9_shutdown(void);
#define COBJMACROS
#include <d3d9.h>

#include <stdlib.h>
#include <stddef.h>
#include <string.h>

Expand Down
Loading

0 comments on commit b4e9e92

Please sign in to comment.