Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e4133b7
Now detecting if memcpy and memset are actually needed. And same goes…
Nielsbishere Dec 4, 2019
0919f70
https://github.com/vurtun/nuklear/pull/803
Nielsbishere Dec 4, 2019
c9980c2
Merge branch 'fix_cpp17' of https://github.com/Nielsbishere/Nuklear i…
Nielsbishere Dec 4, 2019
dc951bf
Problem with existing PR was as follows:
Nielsbishere Dec 4, 2019
11aa9a3
https://github.com/vurtun/nuklear/pull/653 zhouxs1023's Modify the ap…
Nielsbishere Dec 4, 2019
842fd02
Fixed readme
Nielsbishere Dec 4, 2019
f4d97f5
Fixed logical mistake I made in readme
Nielsbishere Dec 4, 2019
014cd2d
Update nuklear_internal.h
Nielsbishere Dec 5, 2019
0de31b9
Update nuklear_util.c
Nielsbishere Dec 5, 2019
be3f371
Repacked nuklear.h and updated package.json
Dec 5, 2019
2c6afa7
Delete package-lock.json
Nielsbishere Dec 5, 2019
31492dc
Merged with fixed_cpp17
Dec 5, 2019
4ede715
Moved ctx to the stack
Dec 5, 2019
8e89387
Merge branch 'fix_click' of https://github.com/Nielsbishere/Nuklear i…
Dec 5, 2019
9f8a941
Merge with fix_click and bump version
Dec 5, 2019
871f277
Update changelog
Dec 9, 2019
15aff92
Fixed indenting and updated changelog
Dec 9, 2019
9b05321
Merge branch 'fix_click' of https://github.com/Nielsbishere/Nuklear i…
Dec 9, 2019
498c3c1
Updated changelog
Dec 9, 2019
2c6db66
Merge https://github.com/Immediate-Mode-UI/Nuklear into fix_cpp17
Nielsbishere Dec 11, 2019
2a415e8
Updated to work with clang
Nielsbishere Dec 11, 2019
792931d
Moved to linux line endings.
Nielsbishere Dec 12, 2019
9aa9729
Merge branch 'fix_cpp17' of https://github.com/Nielsbishere/Nuklear i…
Nielsbishere Dec 12, 2019
ccafa56
Merge branch 'fix_click' of https://github.com/Nielsbishere/Nuklear i…
Nielsbishere Dec 12, 2019
f7c0f03
Reverted checkboxes to the old looks; because imho it looks better
Nielsbishere Dec 12, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 44 additions & 26 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,37 +59,55 @@ This is very important; not doing it either leads to compiler errors, or even wo
struct nk_context ctx;
nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);

enum {EASY, HARD};
static int op = EASY;
enum { EASY, NORMAL, HARD };
static int op = EASY, active[3]{ 1, 0, 1 }, selected{};
static float value = 0.6f;
static int i = 20;

if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220),
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
/* fixed widget pixel width */
nk_layout_row_static(&ctx, 30, 80, 1);
if (nk_button_label(&ctx, "button")) {
/* event handling */
}

/* fixed widget window ratio width */
nk_layout_row_dynamic(&ctx, 30, 2);
if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY;
if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD;

/* custom widget pixel width */
nk_layout_row_begin(&ctx, NK_STATIC, 30, 2);
{
nk_layout_row_push(&ctx, 50);
nk_label(&ctx, "Volume:", NK_TEXT_LEFT);
nk_layout_row_push(&ctx, 110);
nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f);
}
nk_layout_row_end(&ctx);
static size_t test{};

static char const * biomes[] = {
"Large biome",
"Small biome"
};

static int biomeCount = int(sizeof(biomes) / sizeof(biomes[0]));

if (nk_begin(&ctx, "Show", nk_rect(50, 50, 300, 350),
NK_WINDOW_BORDER|NK_WINDOW_SCALABLE|NK_WINDOW_MOVABLE|NK_WINDOW_TITLE)) {

// fixed widget pixel width
nk_layout_row_static(&ctx, 30, 150, 1);
if (nk_button_label(&ctx, "Play"))
myPlayFunction();

// fixed widget window ratio width
nk_layout_row_dynamic(&ctx, 30, 2);
if (nk_option_label(&ctx, "Easy", op == EASY)) op = EASY;
if (nk_option_label(&ctx, "Normal", op == NORMAL)) op = NORMAL;
if (nk_option_label(&ctx, "Hard", op == HARD)) op = HARD;

nk_layout_row_dynamic(ctx, 30, 2);
nk_checkbox_label(&ctx, "Silver", active);
nk_checkbox_label(&ctx, "Bronze", active + 1);
nk_checkbox_label(&ctx, "Gold", active + 2);

nk_layout_row_dynamic(&ctx, 30, 2);
nk_combobox(&ctx, names, biome_count, &selected, 30, nk_vec2(150, 200));

// custom widget pixel width
nk_layout_row_begin(&ctx, NK_STATIC, 30, 2);
{
nk_layout_row_push(&ctx, 50);
nk_label(&ctx, "Volume:", NK_TEXT_LEFT);
nk_layout_row_push(&ctx, 110);
nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f);
nk_progress(&ctx, &test, 100, 1);
}
nk_layout_row_end(&ctx);
}
nk_end(&ctx);
```
![example](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png)
![example](img/test%20window.png)

## Bindings
There are a number of nuklear bindings for different languges created by other authors.
Expand Down
Binary file added img/test window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
179 changes: 112 additions & 67 deletions nuklear.h

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
{
"name": "nuklear",
"version": "4.01.5",
"version": "4.01.8",
"repo": "Immediate-Mode-UI/Nuklear",
"description": "A small ANSI C gui toolkit",
"keywords": ["gl", "ui", "toolkit"],
"src": ["nuklear.h"]
"keywords": [
"gl",
"ui",
"toolkit"
],
"src": [
"nuklear.h"
]
}
5 changes: 5 additions & 0 deletions src/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
/// - [yy]: Minor version with non-breaking API and library changes
/// - [zz]: Bug fix version with no direct changes to API
///
/// - 2019/12/05 (4.01.8) - Fixed radio buttons' style.
/// - 2019/12/05 (4.01.7) - Fixed click cascading through multiple buttons; it should only click the upper button.
/// - 2019/12/11 (4.01.6) - Strict c++17 now compiles: only declaring memset, memcpy if they are used.
/// Only asserting index range if ushorts are used for indices.
/// Made paq.sh identical to paq.bat (outputs to nuklear.h).
/// - 2019/12/10 (4.01.5) - Fix off-by-one error in NK_INTERSECT
/// - 2019/10/09 (4.01.4) - Fix bug for autoscrolling in nk_do_edit
/// - 2019/09/20 (4.01.3) - Fixed a bug wherein combobox cannot be closed by clicking the header
Expand Down
2 changes: 1 addition & 1 deletion src/Readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
File Packer:
------------
- [Click to generate nuklear.h](http://apoorvaj.io/single-header-packer.html?macro=NK&pre=https://raw.githubusercontent.com/vurtun/nuklear/master/src/HEADER&pub=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear.h&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_internal.h&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_math.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_util.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_color.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_utf8.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_buffer.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_string.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_draw.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_vertex.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_font.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_input.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_style.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_context.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_pool.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_page_element.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_table.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_panel.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_window.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_popup.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_contextual.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_menu.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_layout.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_tree.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_group.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_list_view.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_widget.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_text.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_image.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_button.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_toggle.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_selectable.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_slider.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_progress.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_scrollbar.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_text_editor.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_edit.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_property.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_chart.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_color_picker.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_combo.c&priv=https://raw.githubusercontent.com/vurtun/nuklear/master/src/nuklear_tooltip.c&post=https://raw.githubusercontent.com/vurtun/nuklear/master/src/LICENSE&post=https://raw.githubusercontent.com/vurtun/nuklear/master/src/CHANGELOG&post=https://raw.githubusercontent.com/vurtun/nuklear/master/src/CREDITS)
- On Linux/Mac just run ./paq > ../nuklear.h
- On Linux/Mac just run ./paq.sh
- On Windows just run paq.bat
4 changes: 3 additions & 1 deletion src/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

import fnmatch
import os.path
import sys
import sys, io

sys.stdout = io.TextIOWrapper(sys.stdout.buffer, newline='\n' )

def print_help():
print(
Expand Down
1 change: 1 addition & 0 deletions src/nuklear.h
Original file line number Diff line number Diff line change
Expand Up @@ -4391,6 +4391,7 @@ struct nk_mouse {
unsigned char grab;
unsigned char grabbed;
unsigned char ungrab;
unsigned char clicked;
};

struct nk_key {
Expand Down
28 changes: 15 additions & 13 deletions src/nuklear_button.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ nk_draw_symbol(struct nk_command_buffer *out, enum nk_symbol_type type,
}
NK_LIB int
nk_button_behavior(nk_flags *state, struct nk_rect r,
const struct nk_input *i, enum nk_button_behavior behavior)
struct nk_input *i, enum nk_button_behavior behavior)
{
int ret = 0;
nk_widget_state_reset(state);
Expand All @@ -78,6 +78,8 @@ nk_button_behavior(nk_flags *state, struct nk_rect r,
#else
nk_input_is_mouse_pressed(i, NK_BUTTON_LEFT);
#endif
if (ret)
i->mouse.clicked = 1;
}
}
if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(i, r))
Expand Down Expand Up @@ -108,7 +110,7 @@ nk_draw_button(struct nk_command_buffer *out,
}
NK_LIB int
nk_do_button(nk_flags *state, struct nk_command_buffer *out, struct nk_rect r,
const struct nk_style_button *style, const struct nk_input *in,
const struct nk_style_button *style, struct nk_input *in,
enum nk_button_behavior behavior, struct nk_rect *content)
{
struct nk_rect bounds;
Expand Down Expand Up @@ -158,7 +160,7 @@ NK_LIB int
nk_do_button_text(nk_flags *state,
struct nk_command_buffer *out, struct nk_rect bounds,
const char *string, int len, nk_flags align, enum nk_button_behavior behavior,
const struct nk_style_button *style, const struct nk_input *in,
const struct nk_style_button *style, struct nk_input *in,
const struct nk_user_font *font)
{
struct nk_rect content;
Expand Down Expand Up @@ -204,7 +206,7 @@ NK_LIB int
nk_do_button_symbol(nk_flags *state,
struct nk_command_buffer *out, struct nk_rect bounds,
enum nk_symbol_type symbol, enum nk_button_behavior behavior,
const struct nk_style_button *style, const struct nk_input *in,
const struct nk_style_button *style, struct nk_input *in,
const struct nk_user_font *font)
{
int ret;
Expand Down Expand Up @@ -235,7 +237,7 @@ NK_LIB int
nk_do_button_image(nk_flags *state,
struct nk_command_buffer *out, struct nk_rect bounds,
struct nk_image img, enum nk_button_behavior b,
const struct nk_style_button *style, const struct nk_input *in)
const struct nk_style_button *style, struct nk_input *in)
{
int ret;
struct nk_rect content;
Expand Down Expand Up @@ -295,7 +297,7 @@ nk_do_button_text_symbol(nk_flags *state,
struct nk_command_buffer *out, struct nk_rect bounds,
enum nk_symbol_type symbol, const char *str, int len, nk_flags align,
enum nk_button_behavior behavior, const struct nk_style_button *style,
const struct nk_user_font *font, const struct nk_input *in)
const struct nk_user_font *font, struct nk_input *in)
{
int ret;
struct nk_rect tri = {0,0,0,0};
Expand Down Expand Up @@ -352,7 +354,7 @@ nk_do_button_text_image(nk_flags *state,
struct nk_command_buffer *out, struct nk_rect bounds,
struct nk_image img, const char* str, int len, nk_flags align,
enum nk_button_behavior behavior, const struct nk_style_button *style,
const struct nk_user_font *font, const struct nk_input *in)
const struct nk_user_font *font, struct nk_input *in)
{
int ret;
struct nk_rect icon;
Expand Down Expand Up @@ -434,7 +436,7 @@ nk_button_text_styled(struct nk_context *ctx,
{
struct nk_window *win;
struct nk_panel *layout;
const struct nk_input *in;
struct nk_input *in;

struct nk_rect bounds;
enum nk_widget_layout_states state;
Expand Down Expand Up @@ -476,7 +478,7 @@ nk_button_color(struct nk_context *ctx, struct nk_color color)
{
struct nk_window *win;
struct nk_panel *layout;
const struct nk_input *in;
struct nk_input *in;
struct nk_style_button button;

int ret = 0;
Expand Down Expand Up @@ -512,7 +514,7 @@ nk_button_symbol_styled(struct nk_context *ctx,
{
struct nk_window *win;
struct nk_panel *layout;
const struct nk_input *in;
struct nk_input *in;

struct nk_rect bounds;
enum nk_widget_layout_states state;
Expand Down Expand Up @@ -544,7 +546,7 @@ nk_button_image_styled(struct nk_context *ctx, const struct nk_style_button *sty
{
struct nk_window *win;
struct nk_panel *layout;
const struct nk_input *in;
struct nk_input *in;

struct nk_rect bounds;
enum nk_widget_layout_states state;
Expand Down Expand Up @@ -578,7 +580,7 @@ nk_button_symbol_text_styled(struct nk_context *ctx,
{
struct nk_window *win;
struct nk_panel *layout;
const struct nk_input *in;
struct nk_input *in;

struct nk_rect bounds;
enum nk_widget_layout_states state;
Expand Down Expand Up @@ -625,7 +627,7 @@ nk_button_image_text_styled(struct nk_context *ctx,
{
struct nk_window *win;
struct nk_panel *layout;
const struct nk_input *in;
struct nk_input *in;

struct nk_rect bounds;
enum nk_widget_layout_states state;
Expand Down
2 changes: 1 addition & 1 deletion src/nuklear_chart.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ nk_chart_push_line(struct nk_context *ctx, struct nk_window *win,
struct nk_chart *g, float value, int slot)
{
struct nk_panel *layout = win->layout;
const struct nk_input *i = &ctx->input;
struct nk_input *i = &ctx->input;
struct nk_command_buffer *out = &win->buffer;

nk_flags ret = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/nuklear_color_picker.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ NK_LIB int
nk_color_picker_behavior(nk_flags *state,
const struct nk_rect *bounds, const struct nk_rect *matrix,
const struct nk_rect *hue_bar, const struct nk_rect *alpha_bar,
struct nk_colorf *color, const struct nk_input *in)
struct nk_colorf *color, struct nk_input *in)
{
float hsva[4];
int value_changed = 0;
Expand Down Expand Up @@ -121,7 +121,7 @@ NK_LIB int
nk_do_color_picker(nk_flags *state,
struct nk_command_buffer *out, struct nk_colorf *col,
enum nk_color_format fmt, struct nk_rect bounds,
struct nk_vec2 padding, const struct nk_input *in,
struct nk_vec2 padding, struct nk_input *in,
const struct nk_user_font *font)
{
int ret = 0;
Expand Down Expand Up @@ -170,7 +170,7 @@ nk_color_pick(struct nk_context * ctx, struct nk_colorf *color,
struct nk_window *win;
struct nk_panel *layout;
const struct nk_style *config;
const struct nk_input *in;
struct nk_input *in;

enum nk_widget_layout_states state;
struct nk_rect bounds;
Expand Down
8 changes: 4 additions & 4 deletions src/nuklear_combo.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ NK_API int
nk_combo_begin_text(struct nk_context *ctx, const char *selected, int len,
struct nk_vec2 size)
{
const struct nk_input *in;
struct nk_input *in;
struct nk_window *win;
struct nk_style *style;

Expand Down Expand Up @@ -139,7 +139,7 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
{
struct nk_window *win;
struct nk_style *style;
const struct nk_input *in;
struct nk_input *in;

struct nk_rect header;
int is_clicked = nk_false;
Expand Down Expand Up @@ -216,7 +216,7 @@ nk_combo_begin_symbol(struct nk_context *ctx, enum nk_symbol_type symbol, struct
{
struct nk_window *win;
struct nk_style *style;
const struct nk_input *in;
struct nk_input *in;

struct nk_rect header;
int is_clicked = nk_false;
Expand Down Expand Up @@ -399,7 +399,7 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
{
struct nk_window *win;
struct nk_style *style;
const struct nk_input *in;
struct nk_input *in;

struct nk_rect header;
int is_clicked = nk_false;
Expand Down
6 changes: 3 additions & 3 deletions src/nuklear_contextual.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ nk_contextual_item_text(struct nk_context *ctx, const char *text, int len,
nk_flags alignment)
{
struct nk_window *win;
const struct nk_input *in;
struct nk_input *in;
const struct nk_style *style;

struct nk_rect bounds;
Expand Down Expand Up @@ -105,7 +105,7 @@ nk_contextual_item_image_text(struct nk_context *ctx, struct nk_image img,
const char *text, int len, nk_flags align)
{
struct nk_window *win;
const struct nk_input *in;
struct nk_input *in;
const struct nk_style *style;

struct nk_rect bounds;
Expand Down Expand Up @@ -141,7 +141,7 @@ nk_contextual_item_symbol_text(struct nk_context *ctx, enum nk_symbol_type symbo
const char *text, int len, nk_flags align)
{
struct nk_window *win;
const struct nk_input *in;
struct nk_input *in;
const struct nk_style *style;

struct nk_rect bounds;
Expand Down
Loading