Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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
76 changes: 47 additions & 29 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,40 +56,58 @@ This is very important not doing it either leads to compiler errors or even wors

```c
/* init gui state */
struct nk_context ctx;
nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);
struct nk_context *ctx = (nk_context*) malloc(sizeof(nk_context));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: why on heap? It's a small struct and the less allocated memory you have to manage, the better (and more readable).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I'll fix this, it's because on my own project there's too much on the stack already.

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);
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.
Loading