Merge branch 'master' of github.com:Immediate-Mode-UI/Nuklear into br_example_sdl_rendergeometry

This commit is contained in:
Rob Loach 2021-12-22 16:08:49 -05:00
commit 1f562ecb94
No known key found for this signature in database
GPG Key ID: 627C60834A74A21A
102 changed files with 5544 additions and 3903 deletions

14
.editorconfig Normal file
View File

@ -0,0 +1,14 @@
# EditorConfig: https://EditorConfig.org
root = true
[*]
indent_style = space
charset = utf-8
end_of_line = lf
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[clib.json]
indent_size = 2

16
.github/workflows/create-tag.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: Create Tag
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: butlerlogic/action-autotag@stable
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
root: clib.json

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ docs/src
*.tmp
*.swo
*.swp
/private/

View File

@ -92,7 +92,7 @@ nk_end(&ctx);
![example](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png)
## Bindings
There are a number of nuklear bindings for different languges created by other authors.
There are a number of nuklear bindings for different languages created by other authors.
I cannot attest for their quality since I am not necessarily proficient in any of these
languages. Furthermore there are no guarantee that all bindings will always be kept up to date:
@ -185,8 +185,8 @@ Reviewing changes to `src/*` and `nuklear.h`:
* Variable/function name casing.
* Indentation.
* Curly bracket (`{}`) placement.
* Ensure that the contributer have bumped the appropriate version in
[package.json](https://github.com/Immediate-Mode-UI/Nuklear/blob/master/package.json)
* Ensure that the contributor has bumped the appropriate version in
[clib.json](https://github.com/Immediate-Mode-UI/Nuklear/blob/master/clib.json)
and added their changes to the
[CHANGELOG](https://github.com/Immediate-Mode-UI/Nuklear/blob/master/src/CHANGELOG).
* Have at least one other person review the changes before merging.

View File

@ -1,8 +1,9 @@
{
"name": "nuklear",
"version": "4.07.0",
"version": "4.9.4",
"repo": "Immediate-Mode-UI/Nuklear",
"description": "A small ANSI C gui toolkit",
"keywords": ["gl", "ui", "toolkit"],
"license": "MIT, Unlicense",
"src": ["nuklear.h"]
}

View File

@ -2,7 +2,7 @@
BIN = demo
# Flags
CFLAGS += -std=c99 -pedantic -O2
CFLAGS += -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -29,32 +29,57 @@
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define LEN(a) (sizeof(a)/sizeof(a)[0])
/* ===============================================================
*
* EXAMPLE
*
* ===============================================================*/
/* This are some code examples to provide a small overview of what can be
* done with this library. To try out an example uncomment the include
* and the corresponding function. */
/*#include "../style.c"*/
/*#include "../calculator.c"*/
#include "../overview.c"
/*#include "../node_editor.c"*/
* done with this library. To try out an example uncomment the defines */
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
#define INCLUDE_OVERVIEW
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
#ifdef INCLUDE_STYLE
#include "../style.c"
#endif
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
#ifdef INCLUDE_NODE_EDITOR
#include "../node_editor.c"
#endif
/* ===============================================================
*
* DEMO
*
* ===============================================================*/
static void error_callback(int e, const char *d)
{printf("Error %d: %s\n", e, d);}
int main(void)
{
/* Platform */
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_EVENT_QUEUE *event_queue = NULL;
NkAllegro5Font *font;
struct nk_context *ctx;
if (!al_init()) {
fprintf(stdout, "failed to initialize allegro5!\n");
@ -85,9 +110,7 @@ int main(void)
al_register_event_source(event_queue, al_get_mouse_event_source());
al_register_event_source(event_queue, al_get_keyboard_event_source());
NkAllegro5Font *font;
font = nk_allegro5_font_create_from_file("../../../extra_font/Roboto-Regular.ttf", 12, 0);
struct nk_context *ctx;
ctx = nk_allegro5_init(font, display, WINDOW_WIDTH, WINDOW_HEIGHT);
@ -99,11 +122,12 @@ int main(void)
while(1)
{
bool get_event;
ALLEGRO_EVENT ev;
ALLEGRO_TIMEOUT timeout;
al_init_timeout(&timeout, 0.06);
bool get_event = al_wait_for_event_until(event_queue, &ev, &timeout);
get_event = al_wait_for_event_until(event_queue, &ev, &timeout);
if (get_event && ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
break;
@ -141,9 +165,18 @@ int main(void)
nk_end(ctx);
/* -------------- EXAMPLES ---------------- */
/*calculator(ctx);*/
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
/*node_editor(ctx);*/
#endif
#ifdef INCLUDE_NODE_EDITOR
node_editor(ctx);
#endif
/* ----------------------------------------- */
/* Draw */

View File

@ -70,18 +70,20 @@ static struct nk_allegro5 {
NK_API struct nk_image* nk_allegro5_create_image(const char* file_name)
{
ALLEGRO_BITMAP *bitmap;
struct nk_image *image;
if (!al_init_image_addon()) {
fprintf(stdout, "Unable to initialize required allegro5 image addon\n");
exit(1);
}
ALLEGRO_BITMAP* bitmap = al_load_bitmap(file_name);
bitmap = al_load_bitmap(file_name);
if (bitmap == NULL) {
fprintf(stdout, "Unable to load image file: %s\n", file_name);
return NULL;
}
struct nk_image *image = (struct nk_image*)calloc(1, sizeof(struct nk_image));
image = (struct nk_image*)calloc(1, sizeof(struct nk_image));
image->handle.ptr = bitmap;
image->w = al_get_bitmap_width(bitmap);
image->h = al_get_bitmap_height(bitmap);
@ -98,7 +100,10 @@ NK_API void nk_allegro5_del_image(struct nk_image* image)
static float
nk_allegro5_font_get_text_width(nk_handle handle, float height, const char *text, int len)
{
float width;
char *strcpy;
NkAllegro5Font *font = (NkAllegro5Font*)handle.ptr;
NK_UNUSED(height);
if (!font || !text) {
return 0;
}
@ -106,16 +111,19 @@ nk_allegro5_font_get_text_width(nk_handle handle, float height, const char *text
as nuklear uses variable size buffers and al_get_text_width doesn't
accept a length, it infers length from null-termination
(which is unsafe API design by allegro devs!) */
char strcpy[len+1];
strncpy((char*)&strcpy, text, len);
strcpy = malloc(len + 1);
strncpy(strcpy, text, len);
strcpy[len] = '\0';
return al_get_text_width(font->font, strcpy);
width = al_get_text_width(font->font, strcpy);
free(strcpy);
return width;
}
/* Flags are identical to al_load_font() flags argument */
NK_API NkAllegro5Font*
nk_allegro5_font_create_from_file(const char *file_name, int font_size, int flags)
{
NkAllegro5Font *font;
if (!al_init_image_addon()) {
fprintf(stdout, "Unable to initialize required allegro5 image addon\n");
exit(1);
@ -128,7 +136,7 @@ nk_allegro5_font_create_from_file(const char *file_name, int font_size, int flag
fprintf(stdout, "Unable to initialize required allegro5 TTF font addon\n");
exit(1);
}
NkAllegro5Font *font = (NkAllegro5Font*)calloc(1, sizeof(NkAllegro5Font));
font = (NkAllegro5Font*)calloc(1, sizeof(NkAllegro5Font));
font->font = al_load_font(file_name, font_size, flags);
if (font->font == NULL) {
@ -200,18 +208,18 @@ nk_allegro5_render()
(float)r->rounding, color);
} break;
case NK_COMMAND_CIRCLE: {
float xr, yr;
const struct nk_command_circle *c = (const struct nk_command_circle *)cmd;
color = nk_color_to_allegro_color(c->color);
float xr, yr;
xr = (float)c->w/2;
yr = (float)c->h/2;
al_draw_ellipse(((float)(c->x)) + xr, ((float)c->y) + yr,
xr, yr, color, (float)c->line_thickness);
} break;
case NK_COMMAND_CIRCLE_FILLED: {
float xr, yr;
const struct nk_command_circle_filled *c = (const struct nk_command_circle_filled *)cmd;
color = nk_color_to_allegro_color(c->color);
float xr, yr;
xr = (float)c->w/2;
yr = (float)c->h/2;
al_draw_filled_ellipse(((float)(c->x)) + xr, ((float)c->y) + yr,
@ -230,54 +238,61 @@ nk_allegro5_render()
(float)t->b.y, (float)t->c.x, (float)t->c.y, color);
} break;
case NK_COMMAND_POLYGON: {
const struct nk_command_polygon *p = (const struct nk_command_polygon*)cmd;
color = nk_color_to_allegro_color(p->color);
int i;
float vertices[p->point_count * 2];
float *vertices;
const struct nk_command_polygon *p = (const struct nk_command_polygon*)cmd;
vertices = calloc(p->point_count * 2, sizeof(float));
color = nk_color_to_allegro_color(p->color);
for (i = 0; i < p->point_count; i++) {
vertices[i*2] = p->points[i].x;
vertices[(i*2) + 1] = p->points[i].y;
}
al_draw_polyline((const float*)&vertices, (2 * sizeof(float)),
al_draw_polyline(vertices, (2 * sizeof(float)),
(int)p->point_count, ALLEGRO_LINE_JOIN_ROUND, ALLEGRO_LINE_CAP_CLOSED,
color, (float)p->line_thickness, 0.0);
free(vertices);
} break;
case NK_COMMAND_POLYGON_FILLED: {
int i, j = 0;
float *vertices;
const struct nk_command_polygon_filled *p = (const struct nk_command_polygon_filled *)cmd;
vertices = calloc(p->point_count * 2, sizeof(float));
color = nk_color_to_allegro_color(p->color);
int i;
float vertices[p->point_count * 2];
for (i = 0; i < p->point_count; i++) {
vertices[i*2] = p->points[i].x;
vertices[(i*2) + 1] = p->points[i].y;
for (i = p->point_count - 1; i >= 0; i--) {
vertices[j++] = p->points[i].x;
vertices[j++] = p->points[i].y;
}
al_draw_filled_polygon((const float*)&vertices, (int)p->point_count, color);
al_draw_filled_polygon(vertices, (int)p->point_count, color);
free(vertices);
} break;
case NK_COMMAND_POLYLINE: {
const struct nk_command_polyline *p = (const struct nk_command_polyline *)cmd;
color = nk_color_to_allegro_color(p->color);
int i;
float vertices[p->point_count * 2];
float *vertices;
const struct nk_command_polyline *p = (const struct nk_command_polyline *)cmd;
vertices = calloc(p->point_count * 2, sizeof(float));
color = nk_color_to_allegro_color(p->color);
for (i = 0; i < p->point_count; i++) {
vertices[i*2] = p->points[i].x;
vertices[(i*2) + 1] = p->points[i].y;
}
al_draw_polyline((const float*)&vertices, (2 * sizeof(float)),
al_draw_polyline(vertices, (2 * sizeof(float)),
(int)p->point_count, ALLEGRO_LINE_JOIN_ROUND, ALLEGRO_LINE_CAP_ROUND,
color, (float)p->line_thickness, 0.0);
free(vertices);
} break;
case NK_COMMAND_TEXT: {
NkAllegro5Font *font;
const struct nk_command_text *t = (const struct nk_command_text*)cmd;
color = nk_color_to_allegro_color(t->foreground);
NkAllegro5Font *font = (NkAllegro5Font*)t->font->userdata.ptr;
font = (NkAllegro5Font*)t->font->userdata.ptr;
al_draw_text(font->font,
color, (float)t->x, (float)t->y, 0,
(const char*)t->string);
} break;
case NK_COMMAND_CURVE: {
float points[8];
const struct nk_command_curve *q = (const struct nk_command_curve *)cmd;
color = nk_color_to_allegro_color(q->color);
float points[8];
points[0] = (float)q->begin.x;
points[1] = (float)q->begin.y;
points[2] = (float)q->ctrl[0].x;
@ -291,15 +306,20 @@ nk_allegro5_render()
case NK_COMMAND_ARC: {
const struct nk_command_arc *a = (const struct nk_command_arc *)cmd;
color = nk_color_to_allegro_color(a->color);
al_draw_arc((float)a->cx, (float)a->cy, (float)a->r, a->a[0],
al_draw_pieslice((float)a->cx, (float)a->cy, (float)a->r, a->a[0],
a->a[1], color, (float)a->line_thickness);
} break;
case NK_COMMAND_ARC_FILLED: {
const struct nk_command_arc_filled *a = (const struct nk_command_arc_filled *)cmd;
color = nk_color_to_allegro_color(a->color);
al_draw_filled_pieslice((float)a->cx, (float)a->cy, (float)a->r, a->a[0],
a->a[1], color);
} break;
case NK_COMMAND_IMAGE: {
const struct nk_command_image *i = (const struct nk_command_image *)cmd;
al_draw_bitmap_region(i->img.handle.ptr, 0, 0, i->w, i->h, i->x, i->y, 0);
} break;
case NK_COMMAND_RECT_MULTI_COLOR:
case NK_COMMAND_ARC_FILLED:
default: break;
}
}
@ -465,12 +485,13 @@ NK_API struct nk_context*
nk_allegro5_init(NkAllegro5Font *allegro5font, ALLEGRO_DISPLAY *dsp,
unsigned int width, unsigned int height)
{
struct nk_user_font *font;
if (!al_init_primitives_addon()) {
fprintf(stdout, "Unable to initialize required allegro5 primitives addon\n");
exit(1);
}
struct nk_user_font *font = &allegro5font->nk;
font = &allegro5font->nk;
allegro5.dsp = dsp;
allegro5.width = width;

105
demo/canvas.c Normal file
View File

@ -0,0 +1,105 @@
/* nuklear - v1.05 - public domain */
struct nk_canvas {
struct nk_command_buffer *painter;
struct nk_vec2 item_spacing;
struct nk_vec2 panel_padding;
struct nk_style_item window_background;
};
static nk_bool
canvas_begin(struct nk_context *ctx, struct nk_canvas *canvas, nk_flags flags,
int x, int y, int width, int height, struct nk_color background_color)
{
/* save style properties which will be overwritten */
canvas->panel_padding = ctx->style.window.padding;
canvas->item_spacing = ctx->style.window.spacing;
canvas->window_background = ctx->style.window.fixed_background;
/* use the complete window space and set background */
ctx->style.window.spacing = nk_vec2(0,0);
ctx->style.window.padding = nk_vec2(0,0);
ctx->style.window.fixed_background = nk_style_item_color(background_color);
/* create/update window and set position + size */
if (!nk_begin(ctx, "Canvas", nk_rect(x, y, width, height), NK_WINDOW_NO_SCROLLBAR|flags))
return nk_false;
/* allocate the complete window space for drawing */
{
struct nk_rect total_space;
total_space = nk_window_get_content_region(ctx);
nk_layout_row_dynamic(ctx, total_space.h, 1);
nk_widget(&total_space, ctx);
canvas->painter = nk_window_get_canvas(ctx);
}
return nk_true;
}
static void
canvas_end(struct nk_context *ctx, struct nk_canvas *canvas)
{
nk_end(ctx);
ctx->style.window.spacing = canvas->panel_padding;
ctx->style.window.padding = canvas->item_spacing;
ctx->style.window.fixed_background = canvas->window_background;
}
static void
canvas(struct nk_context *ctx)
{
struct nk_canvas canvas;
if (canvas_begin(ctx, &canvas, NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|
NK_WINDOW_CLOSABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE, 10, 10, 500, 550, nk_rgb(250,250,250)))
{
float x = canvas.painter->clip.x, y = canvas.painter->clip.y;
nk_fill_rect(canvas.painter, nk_rect(x + 15, y + 15, 210, 210), 5, nk_rgb(247, 230, 154));
nk_fill_rect(canvas.painter, nk_rect(x + 20, y + 20, 200, 200), 5, nk_rgb(188, 174, 118));
/* nk_draw_text(canvas.painter, nk_rect(x + 30, y + 30, 150, 20), "Text to draw", 12, &font->handle, nk_rgb(188,174,118), nk_rgb(0,0,0)); */
nk_fill_rect(canvas.painter, nk_rect(x + 250, y + 20, 100, 100), 0, nk_rgb(0,0,255));
nk_fill_circle(canvas.painter, nk_rect(x + 20, y + 250, 100, 100), nk_rgb(255,0,0));
nk_fill_triangle(canvas.painter, x + 250, y + 250, x + 350, y + 250, x + 300, y + 350, nk_rgb(0,255,0));
nk_fill_arc(canvas.painter, x + 300, y + 420, 50, 0, 3.141592654f * 3.0f / 4.0f, nk_rgb(255,255,0));
{
float points[12];
points[0] = x + 200; points[1] = y + 250;
points[2] = x + 250; points[3] = y + 350;
points[4] = x + 225; points[5] = y + 350;
points[6] = x + 200; points[7] = y + 300;
points[8] = x + 175; points[9] = y + 350;
points[10] = x + 150; points[11] = y + 350;
nk_fill_polygon(canvas.painter, points, 6, nk_rgb(0,0,0));
}
{
float points[12];
points[0] = x + 200; points[1] = y + 370;
points[2] = x + 250; points[3] = y + 470;
points[4] = x + 225; points[5] = y + 470;
points[6] = x + 200; points[7] = y + 420;
points[8] = x + 175; points[9] = y + 470;
points[10] = x + 150; points[11] = y + 470;
nk_stroke_polygon(canvas.painter, points, 6, 4, nk_rgb(0,0,0));
}
{
float points[8];
points[0] = x + 250; points[1] = y + 200;
points[2] = x + 275; points[3] = y + 220;
points[4] = x + 325; points[5] = y + 170;
points[6] = x + 350; points[7] = y + 200;
nk_stroke_polyline(canvas.painter, points, 4, 2, nk_rgb(255,128,0));
}
nk_stroke_line(canvas.painter, x + 15, y + 10, x + 200, y + 10, 2.0f, nk_rgb(189,45,75));
nk_stroke_rect(canvas.painter, nk_rect(x + 370, y + 20, 100, 100), 10, 3, nk_rgb(0,0,255));
nk_stroke_curve(canvas.painter, x + 380, y + 200, x + 405, y + 270, x + 455, y + 120, x + 480, y + 200, 2, nk_rgb(0,150,220));
nk_stroke_circle(canvas.painter, nk_rect(x + 20, y + 370, 100, 100), 5, nk_rgb(0,255,120));
nk_stroke_triangle(canvas.painter, x + 370, y + 250, x + 470, y + 250, x + 420, y + 350, 6, nk_rgb(255,0,143));
nk_stroke_arc(canvas.painter, x + 420, y + 420, 50, 0, 3.141592654f * 3.0f / 4.0f, 5, nk_rgb(0,255,255));
}
canvas_end(ctx, &canvas);
}

View File

@ -36,12 +36,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -52,6 +54,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -264,6 +269,9 @@ int main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -179,11 +179,15 @@ nk_d3d11_get_projection_matrix(int width, int height, float *result)
const float B = (float)height;
float matrix[4][4] =
{
{ 2.0f / (R - L), 0.0f, 0.0f, 0.0f },
{ 0.0f, 2.0f / (T - B), 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.5f, 0.0f },
{ (R + L) / (L - R), (T + B) / (B - T), 0.5f, 1.0f },
{ 0.0f, 0.0f, 0.5f, 1.0f },
};
matrix[0][0] = 2.0f / (R - L);
matrix[1][1] = 2.0f / (T - B);
matrix[3][0] = (R + L) / (L - R);
matrix[3][1] = (T + B) / (B - T);
memcpy(result, matrix, sizeof(matrix));
}

View File

@ -33,12 +33,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -49,6 +51,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -82,10 +87,11 @@ WindowProc(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
if (width != 0 && height != 0 &&
(width != present.BackBufferWidth || height != present.BackBufferHeight))
{
HRESULT hr;
nk_d3d9_release();
present.BackBufferWidth = width;
present.BackBufferHeight = height;
HRESULT hr = IDirect3DDevice9_Reset(device, &present);
hr = IDirect3DDevice9_Reset(device, &present);
NK_ASSERT(SUCCEEDED(hr));
nk_d3d9_resize(width, height);
}
@ -268,6 +274,9 @@ int main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -204,11 +204,15 @@ nk_d3d9_get_projection_matrix(int width, int height, float *result)
const float T = 0.5f;
const float B = (float)height + 0.5f;
float matrix[4][4] = {
{ 2.0f / (R - L), 0.0f, 0.0f, 0.0f },
{ 0.0f, 2.0f / (T - B), 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 0.0f },
{ (R + L) / (L - R), (T + B) / (B - T), 0.0f, 1.0f },
{ 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f },
};
matrix[0][0] = 2.0f / (R - L);
matrix[1][1] = 2.0f / (T - B);
matrix[3][0] = (R + L) / (L - R);
matrix[3][1] = (T + B) / (B - T);
memcpy(result, matrix, sizeof(matrix));
}
@ -426,30 +430,35 @@ nk_d3d9_handle_event(HWND wnd, UINT msg, WPARAM wparam, LPARAM lparam)
static void
nk_d3d9_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
{
HGLOBAL mem;
SIZE_T size;
LPCWSTR wstr;
int utf8size;
(void)usr;
if (!IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(NULL)) {
return;
}
HGLOBAL mem = GetClipboardData(CF_UNICODETEXT);
mem = GetClipboardData(CF_UNICODETEXT);
if (!mem) {
CloseClipboard();
return;
}
SIZE_T size = GlobalSize(mem) - 1;
size = GlobalSize(mem) - 1;
if (!size) {
CloseClipboard();
return;
}
LPCWSTR wstr = (LPCWSTR)GlobalLock(mem);
wstr = (LPCWSTR)GlobalLock(mem);
if (!wstr) {
CloseClipboard();
return;
}
int utf8size = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)size / sizeof(wchar_t), NULL, 0, NULL, NULL);
utf8size = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)size / sizeof(wchar_t), NULL, 0, NULL, NULL);
if (utf8size) {
char *utf8 = (char *)malloc(utf8size);
if (utf8) {
@ -466,12 +475,14 @@ nk_d3d9_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
static void
nk_d3d9_clipboard_copy(nk_handle usr, const char *text, int len)
{
int wsize;
(void)usr;
if (!OpenClipboard(NULL)) {
return;
}
int wsize = MultiByteToWideChar(CP_UTF8, 0, text, len, NULL, 0);
wsize = MultiByteToWideChar(CP_UTF8, 0, text, len, NULL, 0);
if (wsize) {
HGLOBAL mem = GlobalAlloc(GMEM_MOVEABLE, (wsize + 1) * sizeof(wchar_t));
if (mem) {

View File

@ -28,12 +28,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -44,6 +46,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -164,6 +169,9 @@ int main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -62,6 +62,13 @@ nk_create_image(struct nk_image * image, const char * frame_buffer, const int wi
{
if (image && frame_buffer && (width > 0) && (height > 0))
{
const unsigned char * src = (const unsigned char *)frame_buffer;
INT row = ((width * 3 + 3) & ~3);
LPBYTE lpBuf, pb = NULL;
BITMAPINFO bi = { 0 };
HBITMAP hbm;
int v, i;
image->w = width;
image->h = height;
image->region[0] = 0;
@ -69,8 +76,6 @@ nk_create_image(struct nk_image * image, const char * frame_buffer, const int wi
image->region[2] = width;
image->region[3] = height;
INT row = ((width * 3 + 3) & ~3);
BITMAPINFO bi = { 0 };
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bi.bmiHeader.biWidth = width;
bi.bmiHeader.biHeight = height;
@ -79,15 +84,13 @@ nk_create_image(struct nk_image * image, const char * frame_buffer, const int wi
bi.bmiHeader.biCompression = BI_RGB;
bi.bmiHeader.biSizeImage = row * height;
LPBYTE lpBuf, pb = NULL;
HBITMAP hbm = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, (void**)&lpBuf, NULL, 0);
hbm = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, (void**)&lpBuf, NULL, 0);
pb = lpBuf + row * height;
unsigned char * src = (unsigned char *)frame_buffer;
for (int v = 0; v<height; v++)
for (v = 0; v < height; v++)
{
pb -= row;
for (int i = 0; i < row; i += 3)
for (i = 0; i < row; i += 3)
{
pb[i + 0] = src[0];
pb[i + 1] = src[1];
@ -170,8 +173,9 @@ nk_gdi_stroke_rect(HDC dc, short x, short y, unsigned short w,
unsigned short h, unsigned short r, unsigned short line_thickness, struct nk_color col)
{
COLORREF color = convert_color(col);
HGDIOBJ br;
HPEN pen = NULL;
if (line_thickness == 1) {
SetDCPenColor(dc, color);
} else {
@ -179,7 +183,7 @@ nk_gdi_stroke_rect(HDC dc, short x, short y, unsigned short w,
SelectObject(dc, pen);
}
HGDIOBJ br = SelectObject(dc, GetStockObject(NULL_BRUSH));
br = SelectObject(dc, GetStockObject(NULL_BRUSH));
if (r == 0) {
Rectangle(dc, x, y, x + w, y + h);
} else {
@ -200,7 +204,8 @@ nk_gdi_fill_rect(HDC dc, short x, short y, unsigned short w,
COLORREF color = convert_color(col);
if (r == 0) {
RECT rect = { x, y, x + w, y + h };
RECT rect;
SetRect(&rect, x, y, x + w, y + h);
SetBkColor(dc, color);
ExtTextOutW(dc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);
} else {
@ -262,16 +267,26 @@ nk_gdi_rect_multi_color(HDC dc, short x, short y, unsigned short w,
}
static BOOL
SetPoint(POINT *p, LONG x, LONG y)
{
if (!p)
return FALSE;
p->x = x;
p->y = y;
return TRUE;
}
static void
nk_gdi_fill_triangle(HDC dc, short x0, short y0, short x1,
short y1, short x2, short y2, struct nk_color col)
{
COLORREF color = convert_color(col);
POINT points[] = {
{ x0, y0 },
{ x1, y1 },
{ x2, y2 },
};
POINT points[3];
SetPoint(&points[0], x0, y0);
SetPoint(&points[1], x1, y1);
SetPoint(&points[2], x2, y2);
SetDCPenColor(dc, color);
SetDCBrushColor(dc, color);
@ -283,14 +298,14 @@ nk_gdi_stroke_triangle(HDC dc, short x0, short y0, short x1,
short y1, short x2, short y2, unsigned short line_thickness, struct nk_color col)
{
COLORREF color = convert_color(col);
POINT points[] = {
{ x0, y0 },
{ x1, y1 },
{ x2, y2 },
{ x0, y0 },
};
POINT points[4];
HPEN pen = NULL;
SetPoint(&points[0], x0, y0);
SetPoint(&points[1], x1, y1);
SetPoint(&points[2], x2, y2);
SetPoint(&points[3], x0, y0);
if (line_thickness == 1) {
SetDCPenColor(dc, color);
} else {
@ -414,14 +429,14 @@ nk_gdi_stroke_curve(HDC dc, struct nk_vec2i p1,
unsigned short line_thickness, struct nk_color col)
{
COLORREF color = convert_color(col);
POINT p[] = {
{ p1.x, p1.y },
{ p2.x, p2.y },
{ p3.x, p3.y },
{ p4.x, p4.y },
};
POINT p[4];
HPEN pen = NULL;
SetPoint(&p[0], p1.x, p1.y);
SetPoint(&p[1], p2.x, p2.y);
SetPoint(&p[2], p3.x, p3.y);
SetPoint(&p[3], p4.x, p4.y);
if (line_thickness == 1) {
SetDCPenColor(dc, color);
} else {
@ -462,7 +477,8 @@ static void
nk_gdi_clear(HDC dc, struct nk_color col)
{
COLORREF color = convert_color(col);
RECT rect = { 0, 0, gdi.width, gdi.height };
RECT rect;
SetRect(&rect, 0, 0, gdi.width, gdi.height);
SetBkColor(dc, color);
ExtTextOutW(dc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL);

View File

@ -28,12 +28,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -44,6 +46,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -159,6 +164,9 @@ int main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -47,6 +47,8 @@ NK_API void nk_gdip_image_free(struct nk_image image);
#include <stdlib.h>
#include <malloc.h>
#define _USE_MATH_DEFINES
#include <math.h>
/* manually declare everything GDI+ needs, because
GDI+ headers are not usable from C */
@ -319,6 +321,10 @@ GpStatus WINGDIPAPI
GdipDrawArcI(GpGraphics *graphics, GpPen *pen, INT x, INT y,
INT width, INT height, REAL startAngle, REAL sweepAngle);
GpStatus WINGDIPAPI
GdipDrawPieI(GpGraphics *graphics, GpPen *pen, INT x, INT y,
INT width, INT height, REAL startAngle, REAL sweepAngle);
GpStatus WINGDIPAPI
GdipFillPieI(GpGraphics *graphics, GpBrush *brush, INT x, INT y,
INT width, INT height, REAL startAngle, REAL sweepAngle);
@ -471,15 +477,25 @@ nk_gdip_fill_rect(short x, short y, unsigned short w,
}
}
static BOOL
SetPoint(POINT *p, LONG x, LONG y)
{
if (!p)
return FALSE;
p->x = x;
p->y = y;
return TRUE;
}
static void
nk_gdip_fill_triangle(short x0, short y0, short x1,
short y1, short x2, short y2, struct nk_color col)
{
POINT points[] = {
{ x0, y0 },
{ x1, y1 },
{ x2, y2 },
};
POINT points[3];
SetPoint(&points[0], x0, y0);
SetPoint(&points[1], x1, y1);
SetPoint(&points[2], x2, y2);
GdipSetSolidFillColor(gdip.brush, convert_color(col));
GdipFillPolygonI(gdip.memory, gdip.brush, points, 3, FillModeAlternate);
@ -489,12 +505,13 @@ static void
nk_gdip_stroke_triangle(short x0, short y0, short x1,
short y1, short x2, short y2, unsigned short line_thickness, struct nk_color col)
{
POINT points[] = {
{ x0, y0 },
{ x1, y1 },
{ x2, y2 },
{ x0, y0 },
};
POINT points[4];
SetPoint(&points[0], x0, y0);
SetPoint(&points[1], x1, y1);
SetPoint(&points[2], x2, y2);
SetPoint(&points[3], x0, y0);
GdipSetPenWidth(gdip.pen, (REAL)line_thickness);
GdipSetPenColor(gdip.pen, convert_color(col));
GdipDrawPolygonI(gdip.memory, gdip.pen, points, 4);
@ -569,13 +586,33 @@ nk_gdip_stroke_curve(struct nk_vec2i p1,
GdipDrawBezierI(gdip.memory, gdip.pen, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y);
}
static void
nk_gdip_fill_arc(short cx, short cy, unsigned short r, float amin, float adelta, struct nk_color col)
{
GdipSetSolidFillColor(gdip.brush, convert_color(col));
GdipFillPieI(gdip.memory, gdip.brush, cx - r, cy - r, r * 2, r * 2, amin * (180/M_PI), adelta * (180/M_PI));
}
static void
nk_gdip_stroke_arc(short cx, short cy, unsigned short r, float amin, float adelta, unsigned short line_thickness, struct nk_color col)
{
GdipSetPenWidth(gdip.pen, (REAL)line_thickness);
GdipSetPenColor(gdip.pen, convert_color(col));
GdipDrawPieI(gdip.memory, gdip.pen, cx - r, cy - r, r * 2, r * 2, amin * (180/M_PI), adelta * (180/M_PI));
}
static void
nk_gdip_draw_text(short x, short y, unsigned short w, unsigned short h,
const char *text, int len, GdipFont *font, struct nk_color cbg, struct nk_color cfg)
{
int wsize;
WCHAR* wstr;
RectF layout = { (FLOAT)x, (FLOAT)y, (FLOAT)w, (FLOAT)h };
RectF layout;
layout.X = x;
layout.Y = y;
layout.Width = w;
layout.Height = h;
if(!text || !font || !len) return;
@ -1149,9 +1186,15 @@ nk_gdip_prerender_gui(enum nk_anti_aliasing AA)
const struct nk_command_image *i = (const struct nk_command_image *)cmd;
nk_gdip_draw_image(i->x, i->y, i->w, i->h, i->img, i->col);
} break;
case NK_COMMAND_ARC: {
const struct nk_command_arc *i = (const struct nk_command_arc *)cmd;
nk_gdip_stroke_arc(i->cx, i->cy, i->r, i->a[0], i->a[1], i->line_thickness, i->color);
} break;
case NK_COMMAND_ARC_FILLED: {
const struct nk_command_arc_filled *i = (const struct nk_command_arc_filled *)cmd;
nk_gdip_fill_arc(i->cx, i->cy, i->r, i->a[0], i->a[1], i->color);
} break;
case NK_COMMAND_RECT_MULTI_COLOR:
case NK_COMMAND_ARC:
case NK_COMMAND_ARC_FILLED:
default: break;
}
}

View File

@ -2,7 +2,7 @@
BIN = demo
# Flags
CFLAGS += -std=c99 -pedantic -O2
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -37,12 +37,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
#define INCLUDE_OVERVIEW
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -53,6 +55,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -155,6 +160,9 @@ int main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -136,7 +136,7 @@ nk_glfw3_render(enum nk_anti_aliasing AA)
{NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_glfw_vertex, col)},
{NK_VERTEX_LAYOUT_END}
};
NK_MEMSET(&config, 0, sizeof(config));
memset(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_glfw_vertex);
config.vertex_alignment = NK_ALIGNOF(struct nk_glfw_vertex);
@ -218,6 +218,7 @@ NK_API void
nk_glfw3_mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{
double x, y;
NK_UNUSED(mods);
if (button != GLFW_MOUSE_BUTTON_LEFT) return;
glfwGetCursorPos(window, &x, &y);
if (action == GLFW_PRESS) {

View File

@ -2,7 +2,7 @@
BIN = demo
# Flags
CFLAGS += -std=c99 -pedantic -O2
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -41,12 +41,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
#define INCLUDE_OVERVIEW
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -57,6 +59,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -173,6 +178,9 @@ int main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -262,7 +262,7 @@ nk_glfw3_render(struct nk_glfw* glfw, enum nk_anti_aliasing AA, int max_vertex_b
{NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_glfw_vertex, col)},
{NK_VERTEX_LAYOUT_END}
};
NK_MEMSET(&config, 0, sizeof(config));
memset(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_glfw_vertex);
config.vertex_alignment = NK_ALIGNOF(struct nk_glfw_vertex);
@ -328,9 +328,10 @@ nk_gflw3_scroll_callback(GLFWwindow *win, double xoff, double yoff)
NK_API void
nk_glfw3_mouse_button_callback(GLFWwindow* win, int button, int action, int mods)
{
double x, y;
if (button != GLFW_MOUSE_BUTTON_LEFT) return;
struct nk_glfw* glfw = glfwGetWindowUserPointer(win);
double x, y;
NK_UNUSED(mods);
if (button != GLFW_MOUSE_BUTTON_LEFT) return;
glfwGetCursorPos(win, &x, &y);
if (action == GLFW_PRESS) {
double dt = glfwGetTime() - glfw->last_button_click;
@ -354,13 +355,13 @@ nk_glfw3_clipboard_paste(nk_handle usr, struct nk_text_edit *edit)
NK_INTERN void
nk_glfw3_clipboard_copy(nk_handle usr, const char *text, int len)
{
struct nk_glfw* glfw = usr.ptr;
char *str = 0;
if (!len) return;
str = (char*)malloc((size_t)len+1);
if (!str) return;
memcpy(str, text, (size_t)len);
str[len] = '\0';
struct nk_glfw* glfw = usr.ptr;
glfwSetClipboardString(glfw->win, str);
free(str);
}
@ -378,7 +379,7 @@ nk_glfw3_init(struct nk_glfw* glfw, GLFWwindow *win, enum nk_glfw_init_state ini
nk_init_default(&glfw->ctx, 0);
glfw->ctx.clip.copy = nk_glfw3_clipboard_copy;
glfw->ctx.clip.paste = nk_glfw3_clipboard_paste;
glfw->ctx.clip.userdata = nk_handle_ptr(0);
glfw->ctx.clip.userdata = nk_handle_ptr(&glfw);
glfw->last_button_click = 0;
nk_glfw3_device_create(glfw);

View File

@ -2,7 +2,7 @@
BIN = demo
# Flags
CFLAGS += -std=c99 -pedantic -O2
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -41,12 +41,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
#define INCLUDE_OVERVIEW
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -57,6 +59,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -194,6 +199,9 @@ int main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -116,6 +116,7 @@ NK_API void
nk_glfw3_device_create()
{
GLint status;
GLint len = 0;
static const GLchar *vertex_shader =
NK_SHADER_VERSION
NK_SHADER_BINDLESS
@ -156,7 +157,6 @@ nk_glfw3_device_create()
glCompileShader(dev->frag_shdr);
glGetShaderiv(dev->vert_shdr, GL_COMPILE_STATUS, &status);
GLint len = 0;
glGetShaderiv(dev->vert_shdr, GL_INFO_LOG_LENGTH, &len);
if (len > 1) {
char *log = (char*)calloc((size_t)len, sizeof(char));
@ -403,7 +403,7 @@ nk_glfw3_render(enum nk_anti_aliasing AA)
{NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_glfw_vertex, col)},
{NK_VERTEX_LAYOUT_END}
};
NK_MEMSET(&config, 0, sizeof(config));
memset(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_glfw_vertex);
config.vertex_alignment = NK_ALIGNOF(struct nk_glfw_vertex);
@ -477,6 +477,7 @@ NK_API void
nk_glfw3_mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
{
double x, y;
NK_UNUSED(mods);
if (button != GLFW_MOUSE_BUTTON_LEFT) return;
glfwGetCursorPos(window, &x, &y);
if (action == GLFW_PRESS) {
@ -608,6 +609,7 @@ nk_glfw3_new_frame(void)
nk_input_key(ctx, NK_KEY_TEXT_WORD_RIGHT, glfwGetKey(win, GLFW_KEY_RIGHT) == GLFW_PRESS);
nk_input_key(ctx, NK_KEY_TEXT_LINE_START, glfwGetKey(win, GLFW_KEY_B) == GLFW_PRESS);
nk_input_key(ctx, NK_KEY_TEXT_LINE_END, glfwGetKey(win, GLFW_KEY_E) == GLFW_PRESS);
nk_input_key(ctx, NK_KEY_TEXT_SELECT_ALL, glfwGetKey(win, GLFW_KEY_A) == GLFW_PRESS);
} else {
nk_input_key(ctx, NK_KEY_LEFT, glfwGetKey(win, GLFW_KEY_LEFT) == GLFW_PRESS);
nk_input_key(ctx, NK_KEY_RIGHT, glfwGetKey(win, GLFW_KEY_RIGHT) == GLFW_PRESS);

View File

@ -199,7 +199,7 @@ overview(struct nk_context *ctx)
/* Basic widgets */
static int int_slider = 5;
static float float_slider = 2.5f;
static size_t prog_value = 40;
static nk_size prog_value = 40;
static float property_float = 2;
static int property_int = 10;
static int property_neg = 10;
@ -226,7 +226,7 @@ overview(struct nk_context *ctx)
nk_label(ctx, "Slider float", NK_TEXT_LEFT);
nk_slider_float(ctx, 0, &float_slider, 5.0, 0.5f);
nk_labelf(ctx, NK_TEXT_LEFT, "Progressbar: %zu" , prog_value);
nk_labelf(ctx, NK_TEXT_LEFT, "Progressbar: %u" , (int)prog_value);
nk_progress(ctx, &prog_value, 100, NK_MODIFIABLE);
nk_layout_row(ctx, NK_STATIC, 25, 2, ratio);
@ -623,13 +623,11 @@ overview(struct nk_context *ctx)
int i;
int index = -1;
struct nk_rect bounds;
/* line chart */
id = 0;
index = -1;
nk_layout_row_dynamic(ctx, 100, 1);
bounds = nk_widget_bounds(ctx);
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));
@ -651,7 +649,6 @@ overview(struct nk_context *ctx)
/* column chart */
nk_layout_row_dynamic(ctx, 100, 1);
bounds = nk_widget_bounds(ctx);
if (nk_chart_begin(ctx, NK_CHART_COLUMN, 32, 0.0f, 1.0f)) {
for (i = 0; i < 32; ++i) {
nk_flags res = nk_chart_push(ctx, (float)fabs(sin(id)));
@ -672,7 +669,6 @@ overview(struct nk_context *ctx)
/* mixed chart */
nk_layout_row_dynamic(ctx, 100, 1);
bounds = nk_widget_bounds(ctx);
if (nk_chart_begin(ctx, NK_CHART_COLUMN, 32, 0.0f, 1.0f)) {
nk_chart_add_slot(ctx, NK_CHART_LINES, 32, -1.0f, 1.0f);
nk_chart_add_slot(ctx, NK_CHART_LINES, 32, -1.0f, 1.0f);
@ -687,7 +683,6 @@ overview(struct nk_context *ctx)
/* mixed colored chart */
nk_layout_row_dynamic(ctx, 100, 1);
bounds = nk_widget_bounds(ctx);
if (nk_chart_begin_colored(ctx, NK_CHART_LINES, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) {
nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,0,255), nk_rgb(0,0,150),32, -1.0f, 1.0f);
nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,255,0), nk_rgb(0,150,0), 32, -1.0f, 1.0f);
@ -765,7 +760,7 @@ overview(struct nk_context *ctx)
if (nk_popup_begin(ctx, NK_POPUP_STATIC, "Error", 0, s))
{
nk_layout_row_dynamic(ctx, 25, 1);
nk_label(ctx, "A terrible error as occured", NK_TEXT_LEFT);
nk_label(ctx, "A terrible error as occurred", NK_TEXT_LEFT);
nk_layout_row_dynamic(ctx, 25, 2);
if (nk_button_label(ctx, "OK")) {
popup_active = 0;
@ -946,7 +941,6 @@ overview(struct nk_context *ctx)
if (nk_tree_push(ctx, NK_TREE_NODE, "Notebook", NK_MINIMIZED))
{
static int current_tab = 0;
struct nk_rect bounds;
float step = (2*3.141592654f) / 32;
enum chart_type {CHART_LINE, CHART_HISTO, CHART_MIXED};
const char *names[] = {"Lines", "Columns", "Mixed"};
@ -982,7 +976,6 @@ overview(struct nk_context *ctx)
default: break;
case CHART_LINE:
nk_layout_row_dynamic(ctx, 100, 1);
bounds = nk_widget_bounds(ctx);
if (nk_chart_begin_colored(ctx, NK_CHART_LINES, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) {
nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,0,255), nk_rgb(0,0,150),32, -1.0f, 1.0f);
for (i = 0, id = 0; i < 32; ++i) {
@ -995,7 +988,6 @@ overview(struct nk_context *ctx)
break;
case CHART_HISTO:
nk_layout_row_dynamic(ctx, 100, 1);
bounds = nk_widget_bounds(ctx);
if (nk_chart_begin_colored(ctx, NK_CHART_COLUMN, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) {
for (i = 0, id = 0; i < 32; ++i) {
nk_chart_push_slot(ctx, (float)fabs(sin(id)), 0);
@ -1006,7 +998,6 @@ overview(struct nk_context *ctx)
break;
case CHART_MIXED:
nk_layout_row_dynamic(ctx, 100, 1);
bounds = nk_widget_bounds(ctx);
if (nk_chart_begin_colored(ctx, NK_CHART_LINES, nk_rgb(255,0,0), nk_rgb(150,0,0), 32, 0.0f, 1.0f)) {
nk_chart_add_slot_colored(ctx, NK_CHART_LINES, nk_rgb(0,0,255), nk_rgb(0,0,150),32, -1.0f, 1.0f);
nk_chart_add_slot_colored(ctx, NK_CHART_COLUMN, nk_rgb(0,255,0), nk_rgb(0,150,0), 32, 0.0f, 1.0f);

View File

@ -1,4 +1,4 @@
CFLAGS=`sdl2-config --cflags --libs` -std=c11 -Wall -O0 -g -fvisibility=hidden -Wno-unused `pkg-config SDL2_ttf --cflags --libs`
CFLAGS=`sdl2-config --cflags --libs` -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O0 -g -fvisibility=hidden `pkg-config SDL2_ttf --cflags --libs`
.PHONY: clean

View File

@ -2,7 +2,6 @@
#include <SDL_mouse.h>
#include <SDL_keyboard.h>
#ifndef MIN
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif
@ -23,9 +22,48 @@
#define NK_SDLSURFACE_IMPLEMENTATION
#include "sdl2surface_rawfb.h"
/* ===============================================================
*
* EXAMPLE
*
* ===============================================================*/
/* This are some code examples to provide a small overview of what can be
* done with this library. To try out an example uncomment the defines */
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
#ifdef INCLUDE_STYLE
#include "../style.c"
#endif
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
#ifdef INCLUDE_NODE_EDITOR
#include "../node_editor.c"
#endif
static int translate_sdl_key(struct SDL_Keysym const *k)
{
/*keyboard handling left as an exercise for the reader */
NK_UNUSED(k);
return NK_KEY_NONE;
}
@ -36,7 +74,7 @@ static int sdl_button_to_nk(int button)
switch(button)
{
default:
//ft
/* ft */
case SDL_BUTTON_LEFT:
return NK_BUTTON_LEFT;
break;
@ -50,7 +88,7 @@ static int sdl_button_to_nk(int button)
}
}
#if 0
static void
grid_demo(struct nk_context *ctx)
{
@ -85,7 +123,7 @@ grid_demo(struct nk_context *ctx)
}
nk_end(ctx);
}
#endif
int main(int argc, char **argv)
@ -93,20 +131,28 @@ int main(int argc, char **argv)
struct nk_color clear = {0,100,0,255};
struct nk_vec2 vec;
struct nk_rect bounds = {40,40,0,0};
struct sdlsurface_context *context;
SDL_DisplayMode dm;
SDL_Window *window;
SDL_Renderer *renderer;
SDL_Texture *tex;
SDL_Surface *surface;
NK_UNUSED(argc);
NK_UNUSED(argv);
SDL_Init(SDL_INIT_VIDEO);
printf("sdl init called...\n");
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
SDL_DisplayMode dm;
SDL_GetDesktopDisplayMode(0, &dm);
printf("desktop display mode %d %d\n", dm.w, dm.h);
SDL_Window *window = SDL_CreateWindow("Puzzle", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, dm.w-200,dm.h-200, SDL_WINDOW_OPENGL);
window = SDL_CreateWindow("Puzzle", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, dm.w-200,dm.h-200, SDL_WINDOW_OPENGL);
if (!window)
{
printf("can't open window!\n");
@ -114,18 +160,18 @@ int main(int argc, char **argv)
}
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0);
renderer = SDL_CreateRenderer(window, -1, 0);
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, dm.w-200, dm.h-200, 32, SDL_PIXELFORMAT_ARGB8888);
surface = SDL_CreateRGBSurfaceWithFormat(0, dm.w-200, dm.h-200, 32, SDL_PIXELFORMAT_ARGB8888);
struct sdlsurface_context *context = nk_sdlsurface_init(surface, 13.0f);
context = nk_sdlsurface_init(surface, 13.0f);
while(1)
{
nk_input_begin(&(context->ctx));
SDL_Event event;
nk_input_begin(&(context->ctx));
while (SDL_PollEvent(&event))
{
switch(event.type)
@ -177,14 +223,29 @@ int main(int argc, char **argv)
}
nk_end(&(context->ctx));
// grid_demo(&(context->ctx));
/* grid_demo(&(context->ctx)); */
/* -------------- EXAMPLES ---------------- */
#ifdef INCLUDE_CALCULATOR
calculator(&(context->ctx));
#endif
#ifdef INCLUDE_CANVAS
canvas(&(context->ctx));
#endif
#ifdef INCLUDE_OVERVIEW
overview(&(context->ctx));
#endif
#ifdef INCLUDE_NODE_EDITOR
node_editor(&(context->ctx));
#endif
/* ----------------------------------------- */
nk_sdlsurface_render(context, clear, 1);
SDL_Texture *tex = SDL_CreateTextureFromSurface(renderer, surface);
tex = SDL_CreateTextureFromSurface(renderer, surface);
SDL_RenderCopy(renderer, tex, NULL, NULL);
SDL_RenderPresent(renderer);
SDL_DestroyTexture(tex);

View File

@ -167,7 +167,7 @@ nk_sdlsurface_img_setpixel(const struct SDL_Surface *img,
unsigned int *pixel;
NK_ASSERT(img);
if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) {
ptr = img->pixels + (img->pitch * y0);
ptr = (unsigned char *)img->pixels + (img->pitch * y0);
pixel = (unsigned int *)ptr;
if (img->format == NK_FONT_ATLAS_ALPHA8) {
@ -186,7 +186,7 @@ nk_sdlsurface_img_getpixel(const struct SDL_Surface *img, const int x0, const in
unsigned int pixel;
NK_ASSERT(img);
if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) {
ptr = img->pixels + (img->pitch * y0);
ptr = (unsigned char *)img->pixels + (img->pitch * y0);
if (img->format == NK_FONT_ATLAS_ALPHA8) {
col.a = ptr[x0];
@ -235,6 +235,8 @@ nk_sdlsurface_stroke_line(const struct sdlsurface_context *sdlsurface,
short tmp;
int dy, dx, stepx, stepy;
NK_UNUSED(line_thickness);
dy = y1 - y0;
dx = x1 - x0;
@ -369,6 +371,8 @@ nk_sdlsurface_stroke_arc(const struct sdlsurface_context *sdlsurface,
const int fa2 = 4 * a2, fb2 = 4 * b2;
int x, y, sigma;
NK_UNUSED(line_thickness);
if (s != 0 && s != 90 && s != 180 && s != 270) return;
if (w < 1 || h < 1) return;
@ -735,6 +739,8 @@ nk_sdlsurface_stroke_circle(const struct sdlsurface_context *sdlsurface,
const int fa2 = 4 * a2, fb2 = 4 * b2;
int x, y, sigma;
NK_UNUSED(line_thickness);
/* Convert upper left to center */
h = (h + 1) / 2;
w = (w + 1) / 2;
@ -802,18 +808,18 @@ nk_sdlsurface_clear(const struct sdlsurface_context *sdlsurface, const struct nk
struct sdlsurface_context*
nk_sdlsurface_init(SDL_Surface *fb, float fontSize)
{
SDL_assert((fb->format->format == SDL_PIXELFORMAT_ARGB8888)
|| (fb->format->format == SDL_PIXELFORMAT_RGBA8888));
const void *tex;
int texh, texw;
struct sdlsurface_context *sdlsurface;
assert((fb->format->format == SDL_PIXELFORMAT_ARGB8888)
|| (fb->format->format == SDL_PIXELFORMAT_RGBA8888));
sdlsurface = malloc(sizeof(struct sdlsurface_context));
if (!sdlsurface)
return NULL;
NK_MEMSET(sdlsurface, 0, sizeof(struct sdlsurface_context));
memset(sdlsurface, 0, sizeof(struct sdlsurface_context));
sdlsurface->fb = fb;
@ -843,9 +849,10 @@ nk_sdlsurface_init(SDL_Surface *fb, float fontSize)
if (fb->format->format == SDL_PIXELFORMAT_RGBA8888)
{
SDL_assert(sdlsurface->font_tex->pitch == sdlsurface->font_tex->w * 4);
uint32_t *fontPixels = (uint32_t *)sdlsurface->font_tex->pixels;
for (int i = 0; i < sdlsurface->font_tex->w * sdlsurface->font_tex->h; i++)
int i;
assert(sdlsurface->font_tex->pitch == sdlsurface->font_tex->w * 4);
for (i = 0; i < sdlsurface->font_tex->w * sdlsurface->font_tex->h; i++)
{
uint32_t col = fontPixels[i];
fontPixels[i] &= 0xFFFF00;
@ -961,8 +968,8 @@ nk_sdlsurface_draw_text(const struct sdlsurface_context *sdlsurface,
dst_rect.x = x + g.offset.x + rect.x;
dst_rect.y = g.offset.y + rect.y;
dst_rect.w = ceilf(g.width);
dst_rect.h = ceilf(g.height);
dst_rect.w = ceil(g.width);
dst_rect.h = ceil(g.height);
/* Use software rescaling to blit glyph from font_text to framebuffer */
nk_sdlsurface_stretch_image(sdlsurface->fb, sdlsurface->font_tex, &dst_rect, &src_rect, &sdlsurface->scissors, &fg);
@ -1001,7 +1008,7 @@ nk_sdlsurface_shutdown(struct sdlsurface_context *sdlsurface)
if (sdlsurface) {
SDL_FreeSurface(sdlsurface->font_tex);
nk_free(&sdlsurface->ctx);
NK_MEMSET(sdlsurface, 0, sizeof(struct sdlsurface_context));
memset(sdlsurface, 0, sizeof(struct sdlsurface_context));
free(sdlsurface);
}
}

View File

@ -2,7 +2,7 @@
BIN = demo
# Flags
CFLAGS += -std=c99 -pedantic -O2
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -37,12 +37,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -53,6 +55,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -78,6 +83,9 @@ main(int argc, char *argv[])
struct nk_context *ctx;
struct nk_colorf bg;
NK_UNUSED(argc);
NK_UNUSED(argv);
/* SDL setup */
SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
SDL_Init(SDL_INIT_VIDEO);
@ -165,6 +173,9 @@ main(int argc, char *argv[])
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -116,7 +116,7 @@ nk_sdl_render(enum nk_anti_aliasing AA)
{NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_sdl_vertex, col)},
{NK_VERTEX_LAYOUT_END}
};
NK_MEMSET(&config, 0, sizeof(config));
memset(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_sdl_vertex);
config.vertex_alignment = NK_ALIGNOF(struct nk_sdl_vertex);

View File

@ -2,7 +2,7 @@
BIN = demo
# Flags
CFLAGS += -std=c99 -pedantic -O2
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -41,12 +41,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -57,6 +59,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -81,6 +86,9 @@ int main(int argc, char *argv[])
struct nk_context *ctx;
struct nk_colorf bg;
NK_UNUSED(argc);
NK_UNUSED(argv);
/* SDL setup */
SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_EVENTS);
@ -175,6 +183,9 @@ int main(int argc, char *argv[])
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -243,7 +243,7 @@ nk_sdl_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b
{NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_sdl_vertex, col)},
{NK_VERTEX_LAYOUT_END}
};
NK_MEMSET(&config, 0, sizeof(config));
memset(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_sdl_vertex);
config.vertex_alignment = NK_ALIGNOF(struct nk_sdl_vertex);

View File

@ -2,7 +2,7 @@
BIN = demo
# Flags
CFLAGS += -std=c99 -pedantic -O2
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -38,12 +38,37 @@
*
* ===============================================================*/
/* This are some code examples to provide a small overview of what can be
* done with this library. To try out an example uncomment the include
* and the corresponding function. */
/*#include "../style.c"*/
/*#include "../calculator.c"*/
/*#include "../overview.c"*/
/*#include "../node_editor.c"*/
* done with this library. To try out an example uncomment the defines */
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
#ifdef INCLUDE_STYLE
#include "../style.c"
#endif
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
#ifdef INCLUDE_NODE_EDITOR
#include "../node_editor.c"
#endif
/* ===============================================================
*
@ -95,6 +120,7 @@ MainLoop(void* loopArg){
nk_layout_row_end(ctx);
nk_menubar_end(ctx);
{
enum {EASY, HARD};
static int op = EASY;
static int property = 20;
@ -107,12 +133,22 @@ MainLoop(void* loopArg){
nk_layout_row_dynamic(ctx, 25, 1);
nk_property_int(ctx, "Compression:", 0, &property, 100, 10, 1);
}
}
nk_end(ctx);
/* -------------- EXAMPLES ---------------- */
/*calculator(ctx);*/
/*overview(ctx);*/
/*node_editor(ctx);*/
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif
#ifdef INCLUDE_NODE_EDITOR
node_editor(ctx);
#endif
/* ----------------------------------------- */
/* Draw */
@ -137,6 +173,10 @@ int main(int argc, char* argv[])
/* GUI */
struct nk_context *ctx;
SDL_GLContext glContext;
NK_UNUSED(argc);
NK_UNUSED(argv);
/* SDL setup */
SDL_SetHint(SDL_HINT_VIDEO_HIGHDPI_DISABLED, "0");
/*SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_EVENTS); // - do NOT init SDL on GL ES 2 */

View File

@ -241,7 +241,7 @@ nk_sdl_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b
{NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_sdl_vertex, col)},
{NK_VERTEX_LAYOUT_END}
};
NK_MEMSET(&config, 0, sizeof(config));
memset(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_sdl_vertex);
config.vertex_alignment = NK_ALIGNOF(struct nk_sdl_vertex);

View File

@ -3,7 +3,7 @@ CC = g++
BIN = demo
# Flags
CFLAGS += -s -O2
CFLAGS += -s -Wall -Wextra -pedantic -O2
SRC = main.cpp
OBJ = $(SRC:.cpp=.o)

View File

@ -37,12 +37,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -53,6 +55,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -154,6 +159,9 @@ int main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -114,7 +114,7 @@ nk_sfml_render(enum nk_anti_aliasing AA)
{NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_sfml_vertex, col)},
{NK_VERTEX_LAYOUT_END}
};
NK_MEMSET(&config, 0, sizeof(config));
memset(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_sfml_vertex);
config.vertex_alignment = NK_ALIGNOF(struct nk_sfml_vertex);
@ -189,6 +189,9 @@ nk_sfml_clipboard_paste(nk_handle usr, struct nk_text_edit* edit)
if(text)
nk_textedit_paste(edit, text, nk_strlen(text));
(void)usr;
#else
NK_UNUSED(usr);
NK_UNUSED(edit);
#endif
}
@ -208,6 +211,10 @@ nk_sfml_clipboard_copy(nk_handle usr, const char* text, int len)
sf::Clipboard clipboard(sfml.window);
clipboard.setText(str);
free(str);
#else
NK_UNUSED(usr);
NK_UNUSED(text);
NK_UNUSED(len);
#endif
}

View File

@ -3,7 +3,7 @@ CC = g++
BIN = demo
# Flags
CFLAGS += -s -O2
CFLAGS += -s -Wall -Wextra -pedantic -O2
SRC = main.cpp
OBJ = $(SRC:.cpp=.o)

View File

@ -39,12 +39,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -55,6 +57,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -161,6 +166,9 @@ int main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -244,7 +244,7 @@ nk_sfml_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_
{NK_VERTEX_LAYOUT_END}
};
NK_MEMSET(&config, 0, sizeof(config));
memset(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_sfml_vertex);
config.vertex_alignment = NK_ALIGNOF(struct nk_sfml_vertex);
@ -298,6 +298,9 @@ nk_sfml_clipboard_paste(nk_handle usr, struct nk_text_edit* edit)
sf::Clipboard clipboard(sfml.window);
const char* text = clipboard.getText();
if(text) nk_textedit_paste(edit, text, nk_strlen(text));
#else
NK_UNUSED(usr);
NK_UNUSED(edit);
#endif
}
static void
@ -316,6 +319,10 @@ nk_sfml_clipboard_copy(nk_handle usr, const char* text, int len)
sf::Clipboard clipboard(sfml.window);
clipboard.setText(str);
free(str);
#else
NK_UNUSED(usr);
NK_UNUSED(text);
NK_UNUSED(len);
#endif
}

View File

@ -2,12 +2,12 @@ WAYLAND=`pkg-config wayland-client --cflags --libs`
WAYLAND_SCANNER=wayland-scanner
WAYLAND_PROTOCOLS_DIR=/usr/share/wayland-protocols
CFLAGS?=-std=c11 -Wall -Werror -O3 -fvisibility=hidden
CFLAGS?=-std=c99 -Wall -Wextra -pedantic -Wno-unused-function -O3 -fvisibility=hidden
.PHONY: clean
demo: main.c xdg-shell.c xdg-shell.h
$(CC) -o demo *.c $(WAYLAND) -lrt -lm
$(CC) $(CFLAGS) -o demo *.c $(WAYLAND) -lrt -lm
xdg-shell.c:
$(WAYLAND_SCANNER) code $(WAYLAND_PROTOCOLS_DIR)/stable/xdg-shell/xdg-shell.xml xdg-shell.c

View File

@ -28,25 +28,79 @@
#define DTIME 20
/* ===============================================================
*
* EXAMPLE
*
* ===============================================================*/
/* This are some code examples to provide a small overview of what can be
* done with this library. To try out an example uncomment the defines */
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
#ifdef INCLUDE_STYLE
#include "../style.c"
#endif
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
#ifdef INCLUDE_NODE_EDITOR
#include "../node_editor.c"
#endif
//WAYLAND OUTPUT INTERFACE
static void nk_wayland_output_cb_geometry(void *data, struct wl_output *wl_output, int x, int y, int w, int h, int subpixel, const char *make, const char *model, int transform)
{
NK_UNUSED(data);
NK_UNUSED(wl_output);
NK_UNUSED(subpixel);
NK_UNUSED(make);
NK_UNUSED(model);
NK_UNUSED(transform);
printf("wl_output geometry x=%d, y=%d, w=%d, h=%d make=%s, model=%s \n", x,y,w,h, make, model);
}
static void nk_wayland_output_cb_mode(void *data, struct wl_output *wl_output, unsigned int flags, int w, int h, int refresh)
{
NK_UNUSED(data);
NK_UNUSED(wl_output);
NK_UNUSED(flags);
NK_UNUSED(w);
NK_UNUSED(h);
NK_UNUSED(refresh);
}
static void nk_wayland_output_cb_done(void *data, struct wl_output *output)
{
NK_UNUSED(data);
NK_UNUSED(output);
}
static void nk_wayland_output_cb_scale(void *data, struct wl_output *output, int scale)
{
NK_UNUSED(data);
NK_UNUSED(output);
NK_UNUSED(scale);
}
static const struct wl_output_listener nk_wayland_output_listener =
@ -61,15 +115,29 @@ static const struct wl_output_listener nk_wayland_output_listener =
//WAYLAND POINTER INTERFACE (mouse/touchpad)
static void nk_wayland_pointer_enter (void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y)
{
NK_UNUSED(data);
NK_UNUSED(pointer);
NK_UNUSED(serial);
NK_UNUSED(surface);
NK_UNUSED(surface_x);
NK_UNUSED(surface_y);
}
static void nk_wayland_pointer_leave (void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface)
{
NK_UNUSED(data);
NK_UNUSED(pointer);
NK_UNUSED(serial);
NK_UNUSED(surface);
}
static void nk_wayland_pointer_motion (void *data, struct wl_pointer *pointer, uint32_t time, wl_fixed_t x, wl_fixed_t y)
{
struct nk_wayland* win = (struct nk_wayland*)data;
NK_UNUSED(pointer);
NK_UNUSED(time);
win->mouse_pointer_x = wl_fixed_to_int(x);
win->mouse_pointer_y = wl_fixed_to_int(y);
@ -80,6 +148,10 @@ static void nk_wayland_pointer_button (void *data, struct wl_pointer *pointer, u
{
struct nk_wayland* win = (struct nk_wayland*)data;
NK_UNUSED(pointer);
NK_UNUSED(serial);
NK_UNUSED(time);
if (button == 272){ //left mouse button
if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
// printf("nk_input_button x=%d, y=%d press: 1 \n", win->mouse_pointer_x, win->mouse_pointer_y);
@ -93,6 +165,11 @@ static void nk_wayland_pointer_button (void *data, struct wl_pointer *pointer, u
static void nk_wayland_pointer_axis (void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value)
{
NK_UNUSED(data);
NK_UNUSED(pointer);
NK_UNUSED(time);
NK_UNUSED(axis);
NK_UNUSED(value);
}
static struct wl_pointer_listener nk_wayland_pointer_listener =
@ -101,30 +178,60 @@ static struct wl_pointer_listener nk_wayland_pointer_listener =
&nk_wayland_pointer_leave,
&nk_wayland_pointer_motion,
&nk_wayland_pointer_button,
&nk_wayland_pointer_axis
&nk_wayland_pointer_axis,
NULL,
NULL,
NULL,
NULL
};
//-------------------------------------------------------------------- endof WAYLAND POINTER INTERFACE
//WAYLAND KEYBOARD INTERFACE
static void nk_wayland_keyboard_keymap (void *data, struct wl_keyboard *keyboard, uint32_t format, int32_t fd, uint32_t size)
{
NK_UNUSED(data);
NK_UNUSED(keyboard);
NK_UNUSED(format);
NK_UNUSED(fd);
NK_UNUSED(size);
}
static void nk_wayland_keyboard_enter (void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys)
{
NK_UNUSED(data);
NK_UNUSED(keyboard);
NK_UNUSED(serial);
NK_UNUSED(surface);
NK_UNUSED(keys);
}
static void nk_wayland_keyboard_leave (void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface)
{
NK_UNUSED(data);
NK_UNUSED(keyboard);
NK_UNUSED(serial);
NK_UNUSED(surface);
}
static void nk_wayland_keyboard_key (void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
{
NK_UNUSED(data);
NK_UNUSED(keyboard);
NK_UNUSED(serial);
NK_UNUSED(time);
NK_UNUSED(state);
printf("key: %d \n", key);
}
static void nk_wayland_keyboard_modifiers (void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group)
{
NK_UNUSED(data);
NK_UNUSED(keyboard);
NK_UNUSED(serial);
NK_UNUSED(mods_depressed);
NK_UNUSED(mods_latched);
NK_UNUSED(mods_locked);
NK_UNUSED(group);
}
static struct wl_keyboard_listener nk_wayland_keyboard_listener =
@ -133,7 +240,8 @@ static struct wl_keyboard_listener nk_wayland_keyboard_listener =
&nk_wayland_keyboard_enter,
&nk_wayland_keyboard_leave,
&nk_wayland_keyboard_key,
&nk_wayland_keyboard_modifiers
&nk_wayland_keyboard_modifiers,
NULL
};
//-------------------------------------------------------------------- endof WAYLAND KEYBOARD INTERFACE
@ -154,13 +262,15 @@ static void seat_capabilities (void *data, struct wl_seat *seat, uint32_t capabi
static struct wl_seat_listener seat_listener =
{
&seat_capabilities
&seat_capabilities,
NULL
};
//-------------------------------------------------------------------- endof WAYLAND SEAT INTERFACE
// WAYLAND SHELL INTERFACE
static void nk_wayland_xdg_wm_base_ping (void *data, struct xdg_wm_base *xdg_wm_base, uint32_t serial)
{
NK_UNUSED(data);
xdg_wm_base_pong (xdg_wm_base, serial);
}
@ -171,6 +281,7 @@ static struct xdg_wm_base_listener nk_wayland_xdg_wm_base_listener =
static void nk_wayland_xdg_surface_configure (void *data, struct xdg_surface *xdg_surface, uint32_t serial)
{
NK_UNUSED(data);
xdg_surface_ack_configure(xdg_surface, serial);
}
@ -181,10 +292,17 @@ static struct xdg_surface_listener nk_wayland_xdg_surface_listener =
static void nk_wayland_xdg_toplevel_configure (void *data, struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height, struct wl_array *states)
{
NK_UNUSED(data);
NK_UNUSED(xdg_toplevel);
NK_UNUSED(width);
NK_UNUSED(height);
NK_UNUSED(states);
}
static void nk_wayland_xdg_toplevel_close (void *data, struct xdg_toplevel *xdg_toplevel)
{
NK_UNUSED(data);
NK_UNUSED(xdg_toplevel);
}
static struct xdg_toplevel_listener nk_wayland_xdg_toplevel_listener =
@ -200,6 +318,8 @@ static void nk_wayland_registry_add_object (void *data, struct wl_registry *regi
{
struct nk_wayland* win = (struct nk_wayland*)data;
NK_UNUSED(version);
//printf("looking for %s interface \n", interface);
if (!strcmp(interface,"wl_compositor")) {
win->compositor = wl_registry_bind (registry, name, &wl_compositor_interface, 1);
@ -222,6 +342,9 @@ static void nk_wayland_registry_add_object (void *data, struct wl_registry *regi
static void nk_wayland_registry_remove_object (void *data, struct wl_registry *registry, uint32_t name)
{
NK_UNUSED(data);
NK_UNUSED(registry);
NK_UNUSED(name);
}
static struct wl_registry_listener nk_wayland_registry_listener =
@ -314,8 +437,10 @@ static void redraw(void *data, struct wl_callback *callback, uint32_t time)
{
// printf("redrawing.. 1\n");
struct nk_wayland* win = (struct nk_wayland*)data;
struct nk_color col_red = {0xFF,0x00,0x00,0xA0}; //r,g,b,a
struct nk_color col_green = {0x00,0xFF,0x00,0xA0}; //r,g,b,a
NK_UNUSED(callback);
NK_UNUSED(time);
wl_callback_destroy(win->frame_callback);
wl_surface_damage(win->surface, 0, 0, WIDTH, HEIGHT);
@ -338,7 +463,6 @@ int main ()
long dt;
long started;
struct nk_wayland nk_wayland_ctx;
struct wl_backend *backend;
struct wl_registry *registry;
int running = 1;
@ -418,17 +542,20 @@ int main ()
if (nk_window_is_closed(&(nk_wayland_ctx.ctx), "Demo")) break;
// -------------- EXAMPLES ----------------
//#ifdef INCLUDE_CALCULATOR
// calculator(&rawfb->ctx);
//#endif
// #ifdef INCLUDE_OVERVIEW
// overview(&rawfb->ctx);
// #endif
// #ifdef INCLUDE_NODE_EDITOR
// node_editor(&rawfb->ctx);
//#endif
// -----------------------------------------
/* -------------- EXAMPLES ---------------- */
#ifdef INCLUDE_CALCULATOR
calculator(&(nk_wayland_ctx.ctx));
#endif
#ifdef INCLUDE_CANVAS
canvas(&(nk_wayland_ctx.ctx));
#endif
#ifdef INCLUDE_OVERVIEW
overview(&(nk_wayland_ctx.ctx));
#endif
#ifdef INCLUDE_NODE_EDITOR
node_editor(&(nk_wayland_ctx.ctx));
#endif
/* ----------------------------------------- */
// Draw framebuffer
nk_wayland_render(&nk_wayland_ctx, nk_rgb(30,30,30), 1);

View File

@ -110,7 +110,7 @@ static void nk_wayland_ctx_setpixel(const struct nk_wayland* win,
const short x0, const short y0, const struct nk_color col)
{
uint32_t c = nk_color_to_xrgb8888(col);
uint32_t *pixels = win->data;
uint32_t *pixels = (uint32_t *)win->data;
unsigned int *ptr;
pixels += (y0 * win->width);
@ -252,7 +252,7 @@ static void nk_wayland_img_setpixel(const struct wayland_img *img, const int x0,
unsigned int *pixel;
NK_ASSERT(img);
if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) {
ptr = img->pixels + (img->pitch * y0);
ptr = (unsigned char *)img->pixels + (img->pitch * y0);
pixel = (unsigned int *)ptr;
if (img->format == NK_FONT_ATLAS_ALPHA8) {
@ -267,10 +267,9 @@ static struct nk_color nk_wayland_getpixel(const struct nk_wayland* win, const i
{
struct nk_color col = {0, 0, 0, 0};
uint32_t *ptr;
unsigned int pixel;
if (y0 < win->height && y0 >= 0 && x0 >= 0 && x0 < win->width) {
ptr = win->data + (y0 * win->width);
ptr = (uint32_t *)win->data + (y0 * win->width);
col = nk_wayland_int2color(*ptr, PIXEL_LAYOUT_XRGB_8888);
}
@ -285,7 +284,7 @@ static struct nk_color nk_wayland_img_getpixel(const struct wayland_img *img, co
unsigned int pixel;
NK_ASSERT(img);
if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) {
ptr = img->pixels + (img->pitch * y0);
ptr = (unsigned char *)img->pixels + (img->pitch * y0);
if (img->format == NK_FONT_ATLAS_ALPHA8) {
col.a = ptr[x0];
@ -365,6 +364,8 @@ static void nk_wayland_stroke_line(const struct nk_wayland* win, short x0, short
short tmp;
int dy, dx, stepx, stepy;
NK_UNUSED(line_thickness);
dy = y1 - y0;
dx = x1 - x0;
@ -494,6 +495,8 @@ static void nk_wayland_stroke_arc(const struct nk_wayland* win,
const int fa2 = 4 * a2, fb2 = 4 * b2;
int x, y, sigma;
NK_UNUSED(line_thickness);
if (s != 0 && s != 90 && s != 180 && s != 270) return;
if (w < 1 || h < 1) return;

View File

@ -2,7 +2,7 @@
BIN = zahnrad
# Flags
CFLAGS += -std=c89 -pedantic -O2
CFLAGS += -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -79,12 +79,14 @@ sleep_for(long t)
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -95,6 +97,9 @@ sleep_for(long t)
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -193,6 +198,9 @@ main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -497,6 +497,9 @@ nk_xsurf_draw_image(XSurface *surf, short x, short y, unsigned short w, unsigned
struct nk_image img, struct nk_color col)
{
XImageWithAlpha *aimage = img.handle.ptr;
NK_UNUSED(col);
if (aimage){
if (aimage->clipMask){
XSetClipMask(surf->dpy, surf->gc, aimage->clipMask);
@ -581,6 +584,9 @@ nk_xfont_get_text_width(nk_handle handle, float height, const char *text, int le
{
XFont *font = (XFont*)handle.ptr;
XRectangle r;
NK_UNUSED(height);
if(!font || !text)
return 0;
@ -687,6 +693,8 @@ nk_xlib_handle_event(Display *dpy, int screen, Window win, XEvent *evt)
{
struct nk_context *ctx = &xlib.ctx;
NK_UNUSED(screen);
/* optional grabbing behavior */
if (ctx->input.mouse.grab) {
XDefineCursor(xlib.dpy, xlib.root, xlib.cursor);
@ -864,7 +872,7 @@ nk_xlib_shutdown(void)
nk_xsurf_del(xlib.surf);
nk_free(&xlib.ctx);
XFreeCursor(xlib.dpy, xlib.cursor);
NK_MEMSET(&xlib, 0, sizeof(xlib));
memset(&xlib, 0, sizeof(xlib));
}
NK_API void

View File

@ -6,7 +6,7 @@ CC = clang
DCC = gcc
# Flags
CFLAGS += -std=c99 -pedantic -O2
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -40,12 +40,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -56,6 +58,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -309,6 +314,9 @@ int main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -100,8 +100,11 @@ nk_x11_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b
/* setup global state */
struct nk_x11_device *dev = &x11.ogl;
int width, height;
XWindowAttributes attr;
NK_UNUSED(max_vertex_buffer);
NK_UNUSED(max_element_buffer);
XGetWindowAttributes(x11.dpy, x11.win, &attr);
width = attr.width;
height = attr.height;
@ -146,7 +149,7 @@ nk_x11_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b
{NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_x11_vertex, col)},
{NK_VERTEX_LAYOUT_END}
};
NK_MEMSET(&config, 0, sizeof(config));
memset(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_x11_vertex);
config.vertex_alignment = NK_ALIGNOF(struct nk_x11_vertex);

View File

@ -6,7 +6,7 @@ CC = clang
DCC = gcc
# Flags
CFLAGS += -std=c99 -pedantic -O2
CFLAGS += -std=c89 -Wall -Wextra -pedantic -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -38,12 +38,14 @@
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -54,6 +56,9 @@
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -306,6 +311,9 @@ int main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -265,7 +265,7 @@ nk_load_opengl(struct opengl_info *gl)
glGetIntegerv(GL_MAJOR_VERSION, &gl->major_version);
glGetIntegerv(GL_MINOR_VERSION, &gl->minor_version);
if (gl->major_version < 2) {
fprintf(stderr, "[GL]: Graphics card does not fullfill minimum OpenGL 2.0 support\n");
fprintf(stderr, "[GL]: Graphics card does not fulfill minimum OpenGL 2.0 support\n");
return 0;
}
gl->version = (float)gl->major_version + (float)gl->minor_version * 0.1f;
@ -532,7 +532,7 @@ nk_x11_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b
{NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_x11_vertex, col)},
{NK_VERTEX_LAYOUT_END}
};
NK_MEMSET(&config, 0, sizeof(config));
memset(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_x11_vertex);
config.vertex_alignment = NK_ALIGNOF(struct nk_x11_vertex);

View File

@ -2,7 +2,7 @@
BIN = zahnrad
# Flags
CFLAGS += -std=c89 -pedantic -O2 -Wunused
CFLAGS += -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -113,12 +113,14 @@ sleep_for(long t)
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -129,6 +131,9 @@ sleep_for(long t)
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -230,6 +235,9 @@ main(void)
#ifdef INCLUDE_CALCULATOR
calculator(&rawfb->ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(&rawfb->ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(&rawfb->ctx);
#endif

View File

@ -35,7 +35,7 @@ struct rawfb_context;
typedef enum rawfb_pixel_layout {
PIXEL_LAYOUT_XRGB_8888,
PIXEL_LAYOUT_RGBX_8888,
PIXEL_LAYOUT_RGBX_8888
}
rawfb_pl;
@ -179,7 +179,7 @@ nk_rawfb_img_setpixel(const struct rawfb_image *img,
unsigned int *pixel;
NK_ASSERT(img);
if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) {
ptr = img->pixels + (img->pitch * y0);
ptr = (unsigned char *)img->pixels + (img->pitch * y0);
pixel = (unsigned int *)ptr;
if (img->format == NK_FONT_ATLAS_ALPHA8) {
@ -198,7 +198,7 @@ nk_rawfb_img_getpixel(const struct rawfb_image *img, const int x0, const int y0)
unsigned int pixel;
NK_ASSERT(img);
if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) {
ptr = img->pixels + (img->pitch * y0);
ptr = (unsigned char *)img->pixels + (img->pitch * y0);
if (img->format == NK_FONT_ATLAS_ALPHA8) {
col.a = ptr[x0];
@ -247,6 +247,8 @@ nk_rawfb_stroke_line(const struct rawfb_context *rawfb,
short tmp;
int dy, dx, stepx, stepy;
NK_UNUSED(line_thickness);
dy = y1 - y0;
dx = x1 - x0;
@ -381,6 +383,8 @@ nk_rawfb_stroke_arc(const struct rawfb_context *rawfb,
const int fa2 = 4 * a2, fb2 = 4 * b2;
int x, y, sigma;
NK_UNUSED(line_thickness);
if (s != 0 && s != 90 && s != 180 && s != 270) return;
if (w < 1 || h < 1) return;
@ -747,6 +751,8 @@ nk_rawfb_stroke_circle(const struct rawfb_context *rawfb,
const int fa2 = 4 * a2, fb2 = 4 * b2;
int x, y, sigma;
NK_UNUSED(line_thickness);
/* Convert upper left to center */
h = (h + 1) / 2;
w = (w + 1) / 2;
@ -821,7 +827,7 @@ nk_rawfb_init(void *fb, void *tex_mem, const unsigned int w, const unsigned int
if (!rawfb)
return NULL;
NK_MEMSET(rawfb, 0, sizeof(struct rawfb_context));
memset(rawfb, 0, sizeof(struct rawfb_context));
rawfb->font_tex.pixels = tex_mem;
rawfb->font_tex.format = NK_FONT_ATLAS_ALPHA8;
rawfb->font_tex.w = rawfb->font_tex.h = 0;
@ -1015,7 +1021,7 @@ nk_rawfb_shutdown(struct rawfb_context *rawfb)
{
if (rawfb) {
nk_free(&rawfb->ctx);
NK_MEMSET(rawfb, 0, sizeof(struct rawfb_context));
memset(rawfb, 0, sizeof(struct rawfb_context));
free(rawfb);
}
}

View File

@ -109,7 +109,7 @@ nk_xlib_init(Display *dpy, Visual *vis, int screen, Window root,
break;
}
xlib.xsi.shmaddr = xlib.ximg->data = shmat(xlib.xsi.shmid, NULL, 0);
if ((size_t)xlib.xsi.shmaddr < 0) {
if ((intptr_t)xlib.xsi.shmaddr < 0) {
XDestroyImage(xlib.ximg);
xlib.fallback = True;
break;
@ -254,10 +254,10 @@ nk_xlib_handle_event(Display *dpy, int screen, Window win, XEvent *evt, struct r
} else if (evt->type == Expose || evt->type == ConfigureNotify) {
/* Window resize handler */
void *fb;
rawfb_pl pl;
unsigned int width, height;
XWindowAttributes attr;
XGetWindowAttributes(dpy, win, &attr);
rawfb_pl pl;
width = (unsigned int)attr.width;
height = (unsigned int)attr.height;
@ -287,7 +287,7 @@ nk_xlib_shutdown(void)
XDestroyImage(xlib.ximg);
shmdt(xlib.xsi.shmaddr);
shmctl(xlib.xsi.shmid, IPC_RMID, NULL);
} NK_MEMSET(&xlib, 0, sizeof(xlib));
} memset(&xlib, 0, sizeof(xlib));
}
NK_API void

View File

@ -2,7 +2,7 @@
BIN = zahnrad
# Flags
CFLAGS += -std=c89 -pedantic -O2
CFLAGS += -std=c89 -Wall -Wextra -pedantic -Wno-unused-function -O2
SRC = main.c
OBJ = $(SRC:.c=.o)

View File

@ -79,12 +79,14 @@ sleep_for(long t)
/*#define INCLUDE_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */
#ifdef INCLUDE_ALL
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
@ -95,6 +97,9 @@ sleep_for(long t)
#ifdef INCLUDE_CALCULATOR
#include "../calculator.c"
#endif
#ifdef INCLUDE_CANVAS
#include "../canvas.c"
#endif
#ifdef INCLUDE_OVERVIEW
#include "../overview.c"
#endif
@ -197,6 +202,9 @@ main(void)
#ifdef INCLUDE_CALCULATOR
calculator(ctx);
#endif
#ifdef INCLUDE_CANVAS
canvas(ctx);
#endif
#ifdef INCLUDE_OVERVIEW
overview(ctx);
#endif

View File

@ -420,9 +420,14 @@ NK_INTERN void
nk_xsurf_draw_text(XSurface *surf, short x, short y, unsigned short w, unsigned short h,
const char *text, int len, XFont *font, struct nk_color cbg, struct nk_color cfg)
{
int tx, ty;
unsigned long bg = nk_color_from_byte(&cbg.r);
#ifdef NK_XLIB_USE_XFT
XRenderColor xrc;
XftColor color;
#else
unsigned long fg = nk_color_from_byte(&cfg.r);
#endif
unsigned long bg = nk_color_from_byte(&cbg.r);
int tx, ty;
XSetForeground(surf->dpy, surf->gc, bg);
XFillRectangle(surf->dpy, surf->drawable, surf->gc, (int)x, (int)y, (unsigned)w, (unsigned)h);
@ -431,8 +436,6 @@ nk_xsurf_draw_text(XSurface *surf, short x, short y, unsigned short w, unsigned
tx = (int)x;
ty = (int)y + font->ascent;
#ifdef NK_XLIB_USE_XFT
XRenderColor xrc;
XftColor color;
xrc.red = cfg.r * 257;
xrc.green = cfg.g * 257;
xrc.blue = cfg.b * 257;
@ -541,6 +544,9 @@ nk_xsurf_draw_image(XSurface *surf, short x, short y, unsigned short w, unsigned
struct nk_image img, struct nk_color col)
{
XImageWithAlpha *aimage = img.handle.ptr;
NK_UNUSED(col);
if (aimage){
if (aimage->clipMask){
XSetClipMask(surf->dpy, surf->gc, aimage->clipMask);
@ -640,17 +646,24 @@ nk_xfont_get_text_width(nk_handle handle, float height, const char *text, int le
{
XFont *font = (XFont*)handle.ptr;
if(!font || !text)
return 0;
#ifdef NK_XLIB_USE_XFT
XGlyphInfo g;
NK_UNUSED(height);
if(!font || !text)
return 0;
XftTextExtentsUtf8(xlib.dpy, font->ft, (FcChar8*)text, len, &g);
return g.xOff;
#else
XRectangle r;
NK_UNUSED(height);
if(!font || !text)
return 0;
if(font->set) {
XmbTextExtents(font->set, (const char*)text, len, NULL, &r);
return (float)r.width;
@ -765,6 +778,8 @@ nk_xlib_handle_event(Display *dpy, int screen, Window win, XEvent *evt)
{
struct nk_context *ctx = &xlib.ctx;
NK_UNUSED(screen);
/* optional grabbing behavior */
if (ctx->input.mouse.grab) {
XDefineCursor(xlib.dpy, xlib.root, xlib.cursor);
@ -942,7 +957,7 @@ nk_xlib_shutdown(void)
nk_xsurf_del(xlib.surf);
nk_free(&xlib.ctx);
XFreeCursor(xlib.dpy, xlib.cursor);
NK_MEMSET(&xlib, 0, sizeof(xlib));
memset(&xlib, 0, sizeof(xlib));
}
NK_API void

View File

@ -1,4 +1,2 @@
#!/bin/sh
cat ../nuklear.h|./doc > nuklear.html
cat ../nuklear.h|./doc > index.html

2626
doc/index.html Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -71,7 +71,7 @@ int main() {
/// 1. Numbered
/// 1. List!
///
/// Symbol substitutions: a 45-degree turn; som x -> y arrows; some whoa ==> fancy <==> arrows.
/// Symbol substitutions: a 45-degree turn; some x -> y arrows; some whoa ==> fancy <==> arrows.
///
/// Is this a definition list?
/// : Looks like one to me

View File

@ -1,5 +1,5 @@
# Flags
CFLAGS += -std=c99 -pedantic -O2
CFLAGS += -std=c99 -Wall -Wextra -pedantic -Wno-misleading-indentation -Wno-shift-negative-value -O2
LIBS :=
ifeq ($(OS),Windows_NT)

View File

@ -65,6 +65,8 @@ struct device {
GLuint font_tex;
};
/* function icon_load () is not used to build this file but might still be useful :) */
/*
static void
die(const char *fmt, ...)
{
@ -76,8 +78,6 @@ die(const char *fmt, ...)
exit(EXIT_FAILURE);
}
/* function icon_load () is not used to build this file but might still be useful :) */
/*
static struct nk_image
icon_load(const char *filename)
{
@ -404,6 +404,9 @@ int main(int argc, char *argv[])
struct nk_font_atlas atlas;
struct nk_context ctx;
NK_UNUSED(argc);
NK_UNUSED(argv);
/* GLFW */
glfwSetErrorCallback(error_callback);
if (!glfwInit()) {
@ -477,7 +480,10 @@ int main(int argc, char *argv[])
canvas_end(&ctx, &canvas);}
/* Draw */
glfwGetWindowSize(win, &width, &height);
/* Framebuffer size is used instead of window size because the window size is in screen coordinates instead of pixels.
* See https://www.glfw.org/docs/latest/window_guide.html#window_size for more info
*/
glfwGetFramebufferSize(win, &width, &height);
glViewport(0, 0, width, height);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);

View File

@ -748,6 +748,9 @@ int main(int argc, char *argv[])
struct media media;
struct nk_context ctx;
NK_UNUSED(argc);
NK_UNUSED(argv);
/* GLFW */
glfwSetErrorCallback(error_callback);
if (!glfwInit()) {

View File

@ -149,6 +149,7 @@ die(const char *fmt, ...)
exit(EXIT_FAILURE);
}
#if 0
static char*
file_load(const char* path, size_t* siz)
{
@ -163,6 +164,7 @@ file_load(const char* path, size_t* siz)
fclose(fd);
return buf;
}
#endif
static char*
str_duplicate(const char *src)
@ -200,6 +202,7 @@ dir_list(const char *dir, int return_subdirs, size_t *count)
assert(dir);
assert(count);
strncpy(buffer, dir, MAX_PATH_LEN);
buffer[MAX_PATH_LEN - 1] = 0;
n = strlen(buffer);
if (n > 0 && (buffer[n-1] != '/'))
@ -343,6 +346,7 @@ static void
file_browser_reload_directory_content(struct file_browser *browser, const char *path)
{
strncpy(browser->directory, path, MAX_PATH_LEN);
browser->directory[MAX_PATH_LEN - 1] = 0;
dir_free_list(browser->files, browser->file_count);
dir_free_list(browser->directories, browser->dir_count);
browser->files = dir_list(path, 0, &browser->file_count);
@ -364,6 +368,7 @@ file_browser_init(struct file_browser *browser, struct media *media)
{
size_t l;
strncpy(browser->home, home, MAX_PATH_LEN);
browser->home[MAX_PATH_LEN - 1] = 0;
l = strlen(browser->home);
strcpy(browser->home + l, "/");
strcpy(browser->directory, browser->home);

View File

@ -733,7 +733,6 @@ int main(int argc, char *argv[])
nk_input_end(&ctx);}
/* GUI */
{struct nk_panel layout, tab;
if (nk_begin(&ctx, "Demo", nk_rect(50, 50, 300, 400),
NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_TITLE))
{
@ -805,7 +804,7 @@ int main(int argc, char *argv[])
nk_group_end(&ctx);
}
}
nk_end(&ctx);}
nk_end(&ctx);
/* Draw */
glViewport(0, 0, display_width, display_height);

View File

@ -4081,13 +4081,13 @@ static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 r
// we make a separate pass to expand bits to pixels; for performance,
// this could run two scanlines behind the above code, so it won't
// intefere with filtering but will still be in the cache.
// interfere with filtering but will still be in the cache.
if (depth < 8) {
for (j=0; j < y; ++j) {
stbi_uc *cur = a->out + stride*j;
stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes;
// unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit
// png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop
// png guarantee byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop
stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range
// note that the final byte might overshoot and write more data than desired.
@ -4231,7 +4231,7 @@ static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int
p = (stbi_uc *) stbi__malloc(pixel_count * pal_img_n);
if (p == NULL) return stbi__err("outofmem", "Out of memory");
// between here and free(out) below, exitting would leak
// between here and free(out) below, exiting would leak
temp_out = p;
if (pal_img_n == 3) {
@ -4899,7 +4899,7 @@ static stbi_uc *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int
int RLE_repeating = 0;
int read_next_pixel = 1;
// do a tiny bit of precessing
// do a tiny bit of processing
if ( tga_image_type >= 8 )
{
tga_image_type -= 8;
@ -5161,7 +5161,7 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int
// Else if n is 128, noop.
// Endloop
// The RLE-compressed data is preceeded by a 2-byte data count for each row in the data,
// The RLE-compressed data is preceded by a 2-byte data count for each row in the data,
// which we're going to just skip.
stbi__skip(s, h * channelCount * 2 );
@ -6429,7 +6429,7 @@ STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int
1.31 (2011-06-20)
a few more leak fixes, bug in PNG handling (SpartanJ)
1.30 (2011-06-11)
added ability to load files via callbacks to accomidate custom input streams (Ben Wenger)
added ability to load files via callbacks to accommodate custom input streams (Ben Wenger)
removed deprecated format-specific test/load functions
removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway
error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha)

1036
nuklear.h

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,29 @@
/// ## Changelog
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~none
/// [date][x.yy.zz]-[description]
/// -[date]: date on which the change has been pushed
/// -[x.yy.zz]: Numerical version string representation. Each version number on the right
/// resets back to zero if version on the left is incremented.
/// [date] ([x.y.z]) - [description]
/// - [date]: date on which the change has been pushed
/// - [x.y.z]: Version string, represented in Semantic Versioning format
/// - [x]: Major version with API and library breaking changes
/// - [yy]: Minor version with non-breaking API and library changes
/// - [zz]: Bug fix version with no direct changes to API
/// - [y]: Minor version with non-breaking API and library changes
/// - [z]: Patch version with no direct changes to the API
///
/// - 2021/12/22 (4.9.4) - Fix checking hovering when window is minimized
/// - 2021/12/22 (4.09.3) - Fix layout bounds not accounting for padding.
/// - 2021/12/19 (4.09.2) - Update to stb_rect_pack.h v1.01 and stb_truetype.h v1.26
/// - 2021/12/16 (4.09.1) - Fix the majority of GCC warnings
/// - 2021/10/16 (4.09.0) - Added nk_spacer() widget
/// - 2021/09/22 (4.08.6) - Fix "may be used uninitialized" warnings in nk_widget
/// - 2021/09/22 (4.08.5) - GCC __builtin_offsetof only exists in version 4 and later
/// - 2021/09/15 (4.08.4) - Fix "'num_len' may be used uninitialized" in nk_do_property
/// - 2021/09/15 (4.08.3) - Fix "Templates cannot be declared to have 'C' Linkage"
/// - 2021/09/08 (4.08.2) - Fix warnings in C89 builds
/// - 2021/09/08 (4.08.1) - Use compiler builtins for NK_OFFSETOF when possible
/// - 2021/08/17 (4.08.0) - Implemented 9-slice scaling support for widget styles
/// - 2021/08/16 (4.07.5) - Replace usage of memset in nk_font_atlas_bake with NK_MEMSET
/// - 2021/08/15 (4.07.4) - Fix conversion and sign conversion warnings
/// - 2021/08/08 (4.07.3) - Fix crash when baking merged fonts
/// - 2021/08/08 (4.07.2) - Fix Multiline Edit wrong offset
/// - 2021/03/17 (4.07.1) - Fix warning about unused parameter
/// - 2021/03/17 (4.07.0) - Fix nk_property hover bug
/// - 2021/03/15 (4.06.4) - Change nk_propertyi back to int
/// - 2021/03/15 (4.06.3) - Update documentation for functions that now return nk_bool
@ -52,7 +68,7 @@
/// - 2018/01/31 (3.00.5) - Fixed overcalculation of cursor data in font baking process.
/// - 2018/01/31 (3.00.4) - Removed name collision with stb_truetype.
/// - 2018/01/28 (3.00.3) - Fixed panel window border drawing bug.
/// - 2018/01/12 (3.00.2) - Added `nk_group_begin_titled` for separed group identifier and title.
/// - 2018/01/12 (3.00.2) - Added `nk_group_begin_titled` for separated group identifier and title.
/// - 2018/01/07 (3.00.1) - Started to change documentation style.
/// - 2018/01/05 (3.00.0) - BREAKING CHANGE: The previous color picker API was broken
/// because of conversions between float and byte color representation.
@ -63,13 +79,13 @@
/// - 2017/12/23 (2.00.7) - Fixed small warning.
/// - 2017/12/23 (2.00.7) - Fixed `nk_edit_buffer` behavior if activated to allow input.
/// - 2017/12/23 (2.00.7) - Fixed modifyable progressbar dragging visuals and input behavior.
/// - 2017/12/04 (2.00.6) - Added formated string tooltip widget.
/// - 2017/12/04 (2.00.6) - Added formatted string tooltip widget.
/// - 2017/11/18 (2.00.5) - Fixed window becoming hidden with flag `NK_WINDOW_NO_INPUT`.
/// - 2017/11/15 (2.00.4) - Fixed font merging.
/// - 2017/11/07 (2.00.3) - Fixed window size and position modifier functions.
/// - 2017/09/14 (2.00.2) - Fixed `nk_edit_buffer` and `nk_edit_focus` behavior.
/// - 2017/09/14 (2.00.1) - Fixed window closing behavior.
/// - 2017/09/14 (2.00.0) - BREAKING CHANGE: Modifing window position and size funtions now
/// - 2017/09/14 (2.00.0) - BREAKING CHANGE: Modifying window position and size functions now
/// require the name of the window and must happen outside the window
/// building process (between function call nk_begin and nk_end).
/// - 2017/09/11 (1.40.9) - Fixed window background flag if background window is declared last.
@ -96,7 +112,7 @@
/// - 2017/06/08 (1.39.0) - Added function to retrieve window space without calling a `nk_layout_xxx` function.
/// - 2017/06/06 (1.38.5) - Fixed `nk_convert` return flag for command buffer.
/// - 2017/05/23 (1.38.4) - Fixed activation behavior for widgets partially clipped.
/// - 2017/05/10 (1.38.3) - Fixed wrong min window size mouse scaling over boundries.
/// - 2017/05/10 (1.38.3) - Fixed wrong min window size mouse scaling over boundaries.
/// - 2017/05/09 (1.38.2) - Fixed vertical scrollbar drawing with not enough space.
/// - 2017/05/09 (1.38.1) - Fixed scaler dragging behavior if window size hits minimum size.
/// - 2017/05/06 (1.38.0) - Added platform double-click support.
@ -113,7 +129,7 @@
/// - 2017/03/04 (1.34.2) - Fixed text edit filtering.
/// - 2017/03/04 (1.34.1) - Fixed group closable flag.
/// - 2017/02/25 (1.34.0) - Added custom draw command for better language binding support.
/// - 2017/01/24 (1.33.0) - Added programatic way of remove edit focus.
/// - 2017/01/24 (1.33.0) - Added programmatic way to remove edit focus.
/// - 2017/01/24 (1.32.3) - Fixed wrong define for basic type definitions for windows.
/// - 2017/01/21 (1.32.2) - Fixed input capture from hidden or closed windows.
/// - 2017/01/21 (1.32.1) - Fixed slider behavior and drawing.
@ -158,7 +174,7 @@
/// text in every edit widget if one of them is scrolled.
/// - 2016/09/28 (1.22.3) - Fixed small bug in edit widgets if not active. The wrong
/// text length is passed. It should have been in bytes but
/// was passed as glyphes.
/// was passed as glyphs.
/// - 2016/09/20 (1.22.2) - Fixed color button size calculation.
/// - 2016/09/20 (1.22.1) - Fixed some `nk_vsnprintf` behavior bugs and removed `<stdio.h>`
/// again from `NK_INCLUDE_STANDARD_VARARGS`.
@ -238,13 +254,13 @@
/// - 2016/08/16 (1.09.5) - Fixed ROM mode for deeper levels of popup windows parents.
/// - 2016/08/15 (1.09.4) - Editbox are now still active if enter was pressed with flag
/// `NK_EDIT_SIG_ENTER`. Main reasoning is to be able to keep
/// typing after commiting.
/// typing after committing.
/// - 2016/08/15 (1.09.4) - Removed redundant code.
/// - 2016/08/15 (1.09.4) - Fixed negative numbers in `nk_strtoi` and remove unused variable.
/// - 2016/08/15 (1.09.3) - Fixed `NK_WINDOW_BACKGROUND` flag behavior to select a background
/// window only as selected by hovering and not by clicking.
/// - 2016/08/14 (1.09.2) - Fixed a bug in font atlas which caused wrong loading
/// of glyphes for font with multiple ranges.
/// of glyphs for font with multiple ranges.
/// - 2016/08/12 (1.09.1) - Added additional function to check if window is currently
/// hidden and therefore not visible.
/// - 2016/08/12 (1.09.1) - nk_window_is_closed now queries the correct flag `NK_WINDOW_CLOSED`
@ -260,8 +276,8 @@
/// precision.
/// - 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
/// to wrong wiget width calculation which results in widgets falsly
/// becomming tagged as not inside window and cannot be accessed.
/// to wrong wiget width calculation which results in widgets falsely
/// 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
/// closing a window (NK_WINDOW_CLOSED). A window can be hidden/shown
/// by using `nk_window_show` and closed by either clicking the close
@ -308,6 +324,6 @@
/// - 2016/07/15 (1.01.0) - Removed internal font baking API and simplified
/// font atlas memory management by converting pointer
/// arrays for fonts and font configurations to lists.
/// - 2016/07/15 (1.00.0) - Changed button API to use context dependend button
/// - 2016/07/15 (1.00.0) - Changed button API to use context dependent button
/// behavior instead of passing it for every function call.
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -76,7 +76,7 @@
/// and does not contain the actual implementation. <br /><br />
///
/// The implementation mode requires to define the preprocessor macro
/// NK_IMPLEMENTATION in *one* .c/.cpp file before #includeing this file, e.g.:
/// NK_IMPLEMENTATION in *one* .c/.cpp file before #including this file, e.g.:
///
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~C
/// #define NK_IMPLEMENTATION

View File

@ -259,7 +259,8 @@ struct nk_rect {float x,y,w,h;};
struct nk_recti {short x,y,w,h;};
typedef char nk_glyph[NK_UTF_SIZE];
typedef union {void *ptr; int id;} nk_handle;
struct nk_image {nk_handle handle;unsigned short w,h;unsigned short region[4];};
struct nk_image {nk_handle handle; nk_ushort w, h; nk_ushort region[4];};
struct nk_nine_slice {struct nk_image img; nk_ushort l, t, r, b;};
struct nk_cursor {struct nk_image img; struct nk_vec2 size, offset;};
struct nk_scroll {nk_uint x, y;};
@ -490,7 +491,7 @@ NK_API void nk_set_user_data(struct nk_context*, nk_handle handle);
///
/// #### Usage
/// Input state needs to be provided to nuklear by first calling `nk_input_begin`
/// which resets internal state like delta mouse position and button transistions.
/// which resets internal state like delta mouse position and button transitions.
/// After `nk_input_begin` all current input state needs to be provided. This includes
/// mouse motion, button and key pressed and released, text input and scrolling.
/// Both event- or state-based input handling are supported by this API
@ -1033,7 +1034,7 @@ NK_API const struct nk_command* nk__next(struct nk_context*, const struct nk_com
/// NK_CONVERT_INVALID_PARAM | An invalid argument was passed in the function call
/// NK_CONVERT_COMMAND_BUFFER_FULL | The provided buffer for storing draw commands is full or failed to allocate more memory
/// NK_CONVERT_VERTEX_BUFFER_FULL | The provided buffer for storing vertices is full or failed to allocate more memory
/// NK_CONVERT_ELEMENT_BUFFER_FULL | The provided buffer for storing indicies is full or failed to allocate more memory
/// NK_CONVERT_ELEMENT_BUFFER_FULL | The provided buffer for storing indices is full or failed to allocate more memory
*/
NK_API nk_flags nk_convert(struct nk_context*, struct nk_buffer *cmds, struct nk_buffer *vertices, struct nk_buffer *elements, const struct nk_convert_config*);
/*/// #### nk__draw_begin
@ -1240,8 +1241,8 @@ NK_API const struct nk_draw_command* nk__draw_next(const struct nk_draw_command*
/// #### nk_collapse_states
/// State | Description
/// ----------------|-----------------------------------------------------------
/// __NK_MINIMIZED__| UI section is collased and not visibile until maximized
/// __NK_MAXIMIZED__| UI section is extended and visibile until minimized
/// __NK_MINIMIZED__| UI section is collased and not visible until maximized
/// __NK_MAXIMIZED__| UI section is extended and visible until minimized
/// <br /><br />
*/
enum nk_panel_flags {
@ -2355,6 +2356,21 @@ NK_API struct nk_rect nk_layout_space_rect_to_screen(struct nk_context*, struct
/// Returns transformed `nk_rect` in layout space coordinates
*/
NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context*, struct nk_rect);
/*/// #### nk_spacer
/// Spacer is a dummy widget that consumes space as usual but doesn't draw anything
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// void nk_spacer(struct nk_context* );
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
///
/// Parameter | Description
/// ------------|-----------------------------------------------------------
/// __ctx__ | Must point to an previously initialized `nk_context` struct after call `nk_layout_space_begin`
///
*/
NK_API void nk_spacer(struct nk_context* );
/* =============================================================================
*
* GROUP
@ -2375,7 +2391,7 @@ NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context*, struct n
/// widgets inside the window if the value is not 0.
/// Nesting groups is possible and even encouraged since many layouting schemes
/// can only be achieved by nesting. Groups, unlike windows, need `nk_group_end`
/// to be only called if the corosponding `nk_group_begin_xxx` call does not return 0:
/// to be only called if the corresponding `nk_group_begin_xxx` call does not return 0:
///
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// if (nk_group_begin_xxx(ctx, ...) {
@ -2435,7 +2451,7 @@ NK_API struct nk_rect nk_layout_space_rect_to_local(struct nk_context*, struct n
/// Function | Description
/// --------------------------------|-------------------------------------------
/// nk_group_begin | Start a new group with internal scrollbar handling
/// nk_group_begin_titled | Start a new group with separeted name and title and internal scrollbar handling
/// nk_group_begin_titled | Start a new group with separated name and title and internal scrollbar handling
/// nk_group_end | Ends a group. Should only be called if nk_group_begin returned non-zero
/// nk_group_scrolled_offset_begin | Start a new group with manual separated handling of scrollbar x- and y-offset
/// nk_group_scrolled_begin | Start a new group with manual scrollbar handling
@ -2565,13 +2581,13 @@ NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_of
*
* =============================================================================
/// ### Tree
/// Trees represent two different concept. First the concept of a collapsable
/// UI section that can be either in a hidden or visibile state. They allow the UI
/// Trees represent two different concept. First the concept of a collapsible
/// UI section that can be either in a hidden or visible state. They allow the UI
/// user to selectively minimize the current set of visible UI to comprehend.
/// The second concept are tree widgets for visual UI representation of trees.<br /><br />
///
/// Trees thereby can be nested for tree representations and multiple nested
/// collapsable UI sections. All trees are started by calling of the
/// collapsible UI sections. All trees are started by calling of the
/// `nk_tree_xxx_push_tree` functions and ended by calling one of the
/// `nk_tree_xxx_pop_xxx()` functions. Each starting functions takes a title label
/// and optionally an image to be displayed and the initial collapse state from
@ -2586,7 +2602,7 @@ NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_of
///
/// #### Usage
/// To create a tree you have to call one of the seven `nk_tree_xxx_push_xxx`
/// functions to start a collapsable UI section and `nk_tree_xxx_pop` to mark the
/// functions to start a collapsible UI section and `nk_tree_xxx_pop` to mark the
/// end.
/// Each starting function will either return `false(0)` if the tree is collapsed
/// or hidden and therefore does not need to be filled with content or `true(1)`
@ -2611,28 +2627,28 @@ NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_of
/// #### Reference
/// Function | Description
/// ----------------------------|-------------------------------------------
/// nk_tree_push | Start a collapsable UI section with internal state management
/// nk_tree_push_id | Start a collapsable UI section with internal state management callable in a look
/// nk_tree_push_hashed | Start a collapsable UI section with internal state management with full control over internal unique ID use to store state
/// nk_tree_image_push | Start a collapsable UI section with image and label header
/// nk_tree_image_push_id | Start a collapsable UI section with image and label header and internal state management callable in a look
/// nk_tree_image_push_hashed | Start a collapsable UI section with image and label header and internal state management with full control over internal unique ID use to store state
/// nk_tree_pop | Ends a collapsable UI section
/// nk_tree_push | Start a collapsible UI section with internal state management
/// nk_tree_push_id | Start a collapsible UI section with internal state management callable in a look
/// nk_tree_push_hashed | Start a collapsible UI section with internal state management with full control over internal unique ID use to store state
/// nk_tree_image_push | Start a collapsible UI section with image and label header
/// nk_tree_image_push_id | Start a collapsible UI section with image and label header and internal state management callable in a look
/// nk_tree_image_push_hashed | Start a collapsible UI section with image and label header and internal state management with full control over internal unique ID use to store state
/// nk_tree_pop | Ends a collapsible UI section
//
/// nk_tree_state_push | Start a collapsable UI section with external state management
/// nk_tree_state_image_push | Start a collapsable UI section with image and label header and external state management
/// nk_tree_state_push | Start a collapsible UI section with external state management
/// nk_tree_state_image_push | Start a collapsible UI section with image and label header and external state management
/// nk_tree_state_pop | Ends a collapsabale UI section
///
/// #### nk_tree_type
/// Flag | Description
/// ----------------|----------------------------------------
/// NK_TREE_NODE | Highlighted tree header to mark a collapsable UI section
/// NK_TREE_TAB | Non-highighted tree header closer to tree representations
/// NK_TREE_NODE | Highlighted tree header to mark a collapsible UI section
/// NK_TREE_TAB | Non-highlighted tree header closer to tree representations
*/
/*/// #### nk_tree_push
/// Starts a collapsable UI section with internal state management
/// Starts a collapsible UI section with internal state management
/// !!! WARNING
/// To keep track of the runtime tree collapsable state this function uses
/// To keep track of the runtime tree collapsible state this function uses
/// defines `__FILE__` and `__LINE__` to generate a unique ID. If you want
/// to call this function in a loop please use `nk_tree_push_id` or
/// `nk_tree_push_hashed` instead.
@ -2652,7 +2668,7 @@ NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_of
*/
#define nk_tree_push(ctx, type, title, state) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
/*/// #### nk_tree_push_id
/// Starts a collapsable UI section with internal state management callable in a look
/// Starts a collapsible UI section with internal state management callable in a look
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// #define nk_tree_push_id(ctx, type, title, state, id)
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -2669,7 +2685,7 @@ NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_of
*/
#define nk_tree_push_id(ctx, type, title, state, id) nk_tree_push_hashed(ctx, type, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
/*/// #### nk_tree_push_hashed
/// Start a collapsable UI section with internal state management with full
/// Start a collapsible UI section with internal state management with full
/// control over internal unique ID used to store state
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// nk_bool nk_tree_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
@ -2689,9 +2705,9 @@ NK_API void nk_group_set_scroll(struct nk_context*, const char *id, nk_uint x_of
*/
NK_API nk_bool nk_tree_push_hashed(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
/*/// #### nk_tree_image_push
/// Start a collapsable UI section with image and label header
/// Start a collapsible UI section with image and label header
/// !!! WARNING
/// To keep track of the runtime tree collapsable state this function uses
/// To keep track of the runtime tree collapsible state this function uses
/// defines `__FILE__` and `__LINE__` to generate a unique ID. If you want
/// to call this function in a loop please use `nk_tree_image_push_id` or
/// `nk_tree_image_push_hashed` instead.
@ -2712,7 +2728,7 @@ NK_API nk_bool nk_tree_push_hashed(struct nk_context*, enum nk_tree_type, const
*/
#define nk_tree_image_push(ctx, type, img, title, state) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),__LINE__)
/*/// #### nk_tree_image_push_id
/// Start a collapsable UI section with image and label header and internal state
/// Start a collapsible UI section with image and label header and internal state
/// management callable in a look
///
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
@ -2732,7 +2748,7 @@ NK_API nk_bool nk_tree_push_hashed(struct nk_context*, enum nk_tree_type, const
*/
#define nk_tree_image_push_id(ctx, type, img, title, state, id) nk_tree_image_push_hashed(ctx, type, img, title, state, NK_FILE_LINE,nk_strlen(NK_FILE_LINE),id)
/*/// #### nk_tree_image_push_hashed
/// Start a collapsable UI section with internal state management with full
/// Start a collapsible UI section with internal state management with full
/// control over internal unique ID used to store state
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// nk_bool nk_tree_image_push_hashed(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states initial_state, const char *hash, int len,int seed);
@ -2764,7 +2780,7 @@ NK_API nk_bool nk_tree_image_push_hashed(struct nk_context*, enum nk_tree_type,
*/
NK_API void nk_tree_pop(struct nk_context*);
/*/// #### nk_tree_state_push
/// Start a collapsable UI section with external state management
/// Start a collapsible UI section with external state management
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// nk_bool nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -2780,7 +2796,7 @@ NK_API void nk_tree_pop(struct nk_context*);
*/
NK_API nk_bool nk_tree_state_push(struct nk_context*, enum nk_tree_type, const char *title, enum nk_collapse_states *state);
/*/// #### nk_tree_state_image_push
/// Start a collapsable UI section with image and label header and external state management
/// Start a collapsible UI section with image and label header and external state management
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~c
/// nk_bool nk_tree_state_image_push(struct nk_context*, enum nk_tree_type, struct nk_image, const char *title, enum nk_collapse_states *state);
/// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -3007,10 +3023,10 @@ NK_API nk_bool nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_colo
/// or by directly typing a number.
///
/// #### Usage
/// Each property requires a unique name for identifaction that is also used for
/// Each property requires a unique name for identification that is also used for
/// displaying a label. If you want to use the same name multiple times make sure
/// add a '#' before your name. The '#' will not be shown but will generate a
/// unique ID. Each propery also takes in a minimum and maximum value. If you want
/// unique ID. Each property also takes in a minimum and maximum value. If you want
/// to make use of the complete number range of a type just use the provided
/// type limits from `limits.h`. For example `INT_MIN` and `INT_MAX` for
/// `nk_property_int` and `nk_propertyi`. In additional each property takes in
@ -3064,16 +3080,16 @@ NK_API nk_bool nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_colo
/// #### Reference
/// Function | Description
/// --------------------|-------------------------------------------
/// nk_property_int | Integer property directly modifing a passed in value
/// nk_property_float | Float property directly modifing a passed in value
/// nk_property_double | Double property directly modifing a passed in value
/// nk_property_int | Integer property directly modifying a passed in value
/// nk_property_float | Float property directly modifying a passed in value
/// nk_property_double | Double property directly modifying a passed in value
/// nk_propertyi | Integer property returning the modified int value
/// nk_propertyf | Float property returning the modified float value
/// nk_propertyd | Double property returning the modified double value
///
*/
/*/// #### nk_property_int
/// Integer property directly modifing a passed in value
/// Integer property directly modifying a passed in value
/// !!! WARNING
/// To generate a unique property ID using the same label make sure to insert
/// a `#` at the beginning. It will not be shown but guarantees correct behavior.
@ -3094,7 +3110,7 @@ NK_API nk_bool nk_color_pick(struct nk_context*, struct nk_colorf*, enum nk_colo
*/
NK_API void nk_property_int(struct nk_context*, const char *name, int min, int *val, int max, int step, float inc_per_pixel);
/*/// #### nk_property_float
/// Float property directly modifing a passed in value
/// Float property directly modifying a passed in value
/// !!! WARNING
/// To generate a unique property ID using the same label make sure to insert
/// a `#` at the beginning. It will not be shown but guarantees correct behavior.
@ -3115,7 +3131,7 @@ NK_API void nk_property_int(struct nk_context*, const char *name, int min, int *
*/
NK_API void nk_property_float(struct nk_context*, const char *name, float min, float *val, float max, float step, float inc_per_pixel);
/*/// #### nk_property_double
/// Double property directly modifing a passed in value
/// Double property directly modifying a passed in value
/// !!! WARNING
/// To generate a unique property ID using the same label make sure to insert
/// a `#` at the beginning. It will not be shown but guarantees correct behavior.
@ -3136,7 +3152,7 @@ NK_API void nk_property_float(struct nk_context*, const char *name, float min, f
*/
NK_API void nk_property_double(struct nk_context*, const char *name, double min, double *val, double max, double step, float inc_per_pixel);
/*/// #### nk_propertyi
/// Integer property modifing a passed in value and returning the new value
/// Integer property modifying a passed in value and returning the new value
/// !!! WARNING
/// To generate a unique property ID using the same label make sure to insert
/// a `#` at the beginning. It will not be shown but guarantees correct behavior.
@ -3159,7 +3175,7 @@ NK_API void nk_property_double(struct nk_context*, const char *name, double min,
*/
NK_API int nk_propertyi(struct nk_context*, const char *name, int min, int val, int max, int step, float inc_per_pixel);
/*/// #### nk_propertyf
/// Float property modifing a passed in value and returning the new value
/// Float property modifying a passed in value and returning the new value
/// !!! WARNING
/// To generate a unique property ID using the same label make sure to insert
/// a `#` at the beginning. It will not be shown but guarantees correct behavior.
@ -3182,7 +3198,7 @@ NK_API int nk_propertyi(struct nk_context*, const char *name, int min, int val,
*/
NK_API float nk_propertyf(struct nk_context*, const char *name, float min, float val, float max, float step, float inc_per_pixel);
/*/// #### nk_propertyd
/// Float property modifing a passed in value and returning the new value
/// Float property modifying a passed in value and returning the new value
/// !!! WARNING
/// To generate a unique property ID using the same label make sure to insert
/// a `#` at the beginning. It will not be shown but guarantees correct behavior.
@ -3493,9 +3509,21 @@ NK_API struct nk_image nk_image_handle(nk_handle);
NK_API struct nk_image nk_image_ptr(void*);
NK_API struct nk_image nk_image_id(int);
NK_API nk_bool nk_image_is_subimage(const struct nk_image* img);
NK_API struct nk_image nk_subimage_ptr(void*, unsigned short w, unsigned short h, struct nk_rect sub_region);
NK_API struct nk_image nk_subimage_id(int, unsigned short w, unsigned short h, struct nk_rect sub_region);
NK_API struct nk_image nk_subimage_handle(nk_handle, unsigned short w, unsigned short h, struct nk_rect sub_region);
NK_API struct nk_image nk_subimage_ptr(void*, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
NK_API struct nk_image nk_subimage_id(int, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
NK_API struct nk_image nk_subimage_handle(nk_handle, nk_ushort w, nk_ushort h, struct nk_rect sub_region);
/* =============================================================================
*
* 9-SLICE
*
* ============================================================================= */
NK_API struct nk_nine_slice nk_nine_slice_handle(nk_handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
NK_API struct nk_nine_slice nk_nine_slice_ptr(void*, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
NK_API struct nk_nine_slice nk_nine_slice_id(int, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
NK_API int nk_nine_slice_is_sub9slice(const struct nk_nine_slice* img);
NK_API struct nk_nine_slice nk_sub9slice_ptr(void*, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
NK_API struct nk_nine_slice nk_sub9slice_id(int, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
NK_API struct nk_nine_slice nk_sub9slice_handle(nk_handle, nk_ushort w, nk_ushort h, struct nk_rect sub_region, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b);
/* =============================================================================
*
* MATH
@ -3763,7 +3791,7 @@ struct nk_font_config {
unsigned char pixel_snap;
/* align every character to pixel boundary (if true set oversample (1,1)) */
unsigned char oversample_v, oversample_h;
/* rasterize at hight quality for sub-pixel position */
/* rasterize at high quality for sub-pixel position */
unsigned char padding[3];
float size;
@ -4387,6 +4415,7 @@ NK_API void nk_fill_polygon(struct nk_command_buffer*, float*, int point_count,
/* misc */
NK_API void nk_draw_image(struct nk_command_buffer*, struct nk_rect, const struct nk_image*, struct nk_color);
NK_API void nk_draw_nine_slice(struct nk_command_buffer*, struct nk_rect, const struct nk_nine_slice*, struct nk_color);
NK_API void nk_draw_text(struct nk_command_buffer*, struct nk_rect, const char *text, int len, const struct nk_user_font*, struct nk_color, struct nk_color);
NK_API void nk_push_scissor(struct nk_command_buffer*, struct nk_rect);
NK_API void nk_push_custom(struct nk_command_buffer*, struct nk_rect, nk_command_custom_callback, nk_handle usr);
@ -4604,12 +4633,14 @@ NK_API void nk_draw_list_push_userdata(struct nk_draw_list*, nk_handle userdata)
* ===============================================================*/
enum nk_style_item_type {
NK_STYLE_ITEM_COLOR,
NK_STYLE_ITEM_IMAGE
NK_STYLE_ITEM_IMAGE,
NK_STYLE_ITEM_NINE_SLICE
};
union nk_style_item_data {
struct nk_image image;
struct nk_color color;
struct nk_image image;
struct nk_nine_slice slice;
};
struct nk_style_item {
@ -5035,8 +5066,9 @@ struct nk_style {
struct nk_style_window window;
};
NK_API struct nk_style_item nk_style_item_image(struct nk_image img);
NK_API struct nk_style_item nk_style_item_color(struct nk_color);
NK_API struct nk_style_item nk_style_item_image(struct nk_image img);
NK_API struct nk_style_item nk_style_item_nine_slice(struct nk_nine_slice slice);
NK_API struct nk_style_item nk_style_item_hide(void);
/*==============================================================
@ -5459,9 +5491,11 @@ struct nk_context {
#define NK_ALIGN_PTR_BACK(x, mask)\
(NK_UINT_TO_PTR((NK_PTR_TO_UINT((nk_byte*)(x)) & ~(mask-1))))
#if (defined(__GNUC__) && __GNUC__ >= 4) || defined(__clang__)
#define NK_OFFSETOF(st,m) (__builtin_offsetof(st,m))
#else
#define NK_OFFSETOF(st,m) ((nk_ptr)&(((st*)0)->m))
#define NK_CONTAINER_OF(ptr,type,member)\
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
#endif
#ifdef __cplusplus
}
@ -5474,10 +5508,13 @@ template<typename T> struct nk_helper<T,0>{enum {value = nk_alignof<T>::value};}
template<typename T> struct nk_alignof{struct Big {T x; char c;}; enum {
diff = sizeof(Big) - sizeof(T), value = nk_helper<Big, diff>::value};};
#define NK_ALIGNOF(t) (nk_alignof<t>::value)
#elif defined(_MSC_VER)
#define NK_ALIGNOF(t) (__alignof(t))
#else
#define NK_ALIGNOF(t) ((char*)(&((struct {char c; t _h;}*)0)->_h) - (char*)0)
#define NK_ALIGNOF(t) NK_OFFSETOF(struct {char c; t _h;}, _h)
#endif
#define NK_CONTAINER_OF(ptr,type,member)\
(type*)((void*)((char*)(1 ? (ptr): &((type*)0)->member) - NK_OFFSETOF(type, member)))
#endif /* NK_NUKLEAR_H_ */

106
src/nuklear_9slice.c Normal file
View File

@ -0,0 +1,106 @@
#include "nuklear.h"
#include "nuklear_internal.h"
/* ===============================================================
*
* 9-SLICE
*
* ===============================================================*/
NK_API struct nk_nine_slice
nk_sub9slice_ptr(void *ptr, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
{
struct nk_nine_slice s;
struct nk_image *i = &s.img;
nk_zero(&s, sizeof(s));
i->handle.ptr = ptr;
i->w = w; i->h = h;
i->region[0] = (nk_ushort)rgn.x;
i->region[1] = (nk_ushort)rgn.y;
i->region[2] = (nk_ushort)rgn.w;
i->region[3] = (nk_ushort)rgn.h;
s.l = l; s.t = t; s.r = r; s.b = b;
return s;
}
NK_API struct nk_nine_slice
nk_sub9slice_id(int id, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
{
struct nk_nine_slice s;
struct nk_image *i = &s.img;
nk_zero(&s, sizeof(s));
i->handle.id = id;
i->w = w; i->h = h;
i->region[0] = (nk_ushort)rgn.x;
i->region[1] = (nk_ushort)rgn.y;
i->region[2] = (nk_ushort)rgn.w;
i->region[3] = (nk_ushort)rgn.h;
s.l = l; s.t = t; s.r = r; s.b = b;
return s;
}
NK_API struct nk_nine_slice
nk_sub9slice_handle(nk_handle handle, nk_ushort w, nk_ushort h, struct nk_rect rgn, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
{
struct nk_nine_slice s;
struct nk_image *i = &s.img;
nk_zero(&s, sizeof(s));
i->handle = handle;
i->w = w; i->h = h;
i->region[0] = (nk_ushort)rgn.x;
i->region[1] = (nk_ushort)rgn.y;
i->region[2] = (nk_ushort)rgn.w;
i->region[3] = (nk_ushort)rgn.h;
s.l = l; s.t = t; s.r = r; s.b = b;
return s;
}
NK_API struct nk_nine_slice
nk_nine_slice_handle(nk_handle handle, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
{
struct nk_nine_slice s;
struct nk_image *i = &s.img;
nk_zero(&s, sizeof(s));
i->handle = handle;
i->w = 0; i->h = 0;
i->region[0] = 0;
i->region[1] = 0;
i->region[2] = 0;
i->region[3] = 0;
s.l = l; s.t = t; s.r = r; s.b = b;
return s;
}
NK_API struct nk_nine_slice
nk_nine_slice_ptr(void *ptr, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
{
struct nk_nine_slice s;
struct nk_image *i = &s.img;
nk_zero(&s, sizeof(s));
NK_ASSERT(ptr);
i->handle.ptr = ptr;
i->w = 0; i->h = 0;
i->region[0] = 0;
i->region[1] = 0;
i->region[2] = 0;
i->region[3] = 0;
s.l = l; s.t = t; s.r = r; s.b = b;
return s;
}
NK_API struct nk_nine_slice
nk_nine_slice_id(int id, nk_ushort l, nk_ushort t, nk_ushort r, nk_ushort b)
{
struct nk_nine_slice s;
struct nk_image *i = &s.img;
nk_zero(&s, sizeof(s));
i->handle.id = id;
i->w = 0; i->h = 0;
i->region[0] = 0;
i->region[1] = 0;
i->region[2] = 0;
i->region[3] = 0;
s.l = l; s.t = t; s.r = r; s.b = b;
return s;
}
NK_API int
nk_nine_slice_is_sub9slice(const struct nk_nine_slice* slice)
{
NK_ASSERT(slice);
return !(slice->img.w == 0 && slice->img.h == 0);
}

View File

@ -98,11 +98,17 @@ nk_draw_button(struct nk_command_buffer *out,
background = &style->active;
else background = &style->normal;
if (background->type == NK_STYLE_ITEM_IMAGE) {
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, *bounds, &background->data.image, nk_white);
} else {
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, *bounds, style->rounding, background->data.color);
nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color);
break;
}
return background;
}

View File

@ -56,12 +56,19 @@ nk_chart_begin_colored(struct nk_context *ctx, enum nk_chart_type type,
/* draw chart background */
background = &style->background;
if (background->type == NK_STYLE_ITEM_IMAGE) {
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(&win->buffer, bounds, &background->data.image, nk_white);
} else {
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(&win->buffer, bounds, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(&win->buffer, bounds, style->rounding, style->border_color);
nk_fill_rect(&win->buffer, nk_shrink_rect(bounds, style->border),
style->rounding, style->background.data.color);
break;
}
return 1;
}

View File

@ -82,13 +82,21 @@ nk_combo_begin_text(struct nk_context *ctx, const char *selected, int len,
background = &style->combo.normal;
text.text = style->combo.label_normal;
}
if (background->type == NK_STYLE_ITEM_IMAGE) {
text.background = nk_rgba(0,0,0,0);
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
text.background = nk_rgba(0, 0, 0, 0);
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
} else {
break;
case NK_STYLE_ITEM_NINE_SLICE:
text.background = nk_rgba(0, 0, 0, 0);
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
text.background = background->data.color;
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
break;
}
{
/* print currently selected text item */
@ -178,11 +186,17 @@ nk_combo_begin_color(struct nk_context *ctx, struct nk_color color, struct nk_ve
background = &style->combo.hover;
else background = &style->combo.normal;
if (background->type == NK_STYLE_ITEM_IMAGE) {
nk_draw_image(&win->buffer, header, &background->data.image,nk_white);
} else {
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
break;
}
{
struct nk_rect content;
@ -270,13 +284,20 @@ nk_combo_begin_symbol(struct nk_context *ctx, enum nk_symbol_type symbol, struct
symbol_color = style->combo.symbol_hover;
}
if (background->type == NK_STYLE_ITEM_IMAGE) {
sym_background = nk_rgba(0,0,0,0);
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
sym_background = nk_rgba(0, 0, 0, 0);
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
} else {
break;
case NK_STYLE_ITEM_NINE_SLICE:
sym_background = nk_rgba(0, 0, 0, 0);
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
sym_background = background->data.color;
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
break;
}
{
struct nk_rect bounds = {0,0,0,0};
@ -359,13 +380,21 @@ nk_combo_begin_symbol_text(struct nk_context *ctx, const char *selected, int len
symbol_color = style->combo.symbol_normal;
text.text = style->combo.label_normal;
}
if (background->type == NK_STYLE_ITEM_IMAGE) {
text.background = nk_rgba(0,0,0,0);
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
text.background = nk_rgba(0, 0, 0, 0);
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
} else {
break;
case NK_STYLE_ITEM_NINE_SLICE:
text.background = nk_rgba(0, 0, 0, 0);
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
text.background = background->data.color;
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
break;
}
{
struct nk_rect content;
@ -446,11 +475,17 @@ nk_combo_begin_image(struct nk_context *ctx, struct nk_image img, struct nk_vec2
background = &style->combo.hover;
else background = &style->combo.normal;
if (background->type == NK_STYLE_ITEM_IMAGE) {
switch (background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
} else {
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
break;
}
{
struct nk_rect bounds = {0,0,0,0};
@ -536,13 +571,21 @@ nk_combo_begin_image_text(struct nk_context *ctx, const char *selected, int len,
background = &style->combo.normal;
text.text = style->combo.label_normal;
}
if (background->type == NK_STYLE_ITEM_IMAGE) {
text.background = nk_rgba(0,0,0,0);
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
text.background = nk_rgba(0, 0, 0, 0);
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
} else {
break;
case NK_STYLE_ITEM_NINE_SLICE:
text.background = nk_rgba(0, 0, 0, 0);
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
text.background = background->data.color;
nk_fill_rect(&win->buffer, header, style->combo.rounding, background->data.color);
nk_stroke_rect(&win->buffer, header, style->combo.rounding, style->combo.border, style->combo.border_color);
break;
}
{
struct nk_rect content;

View File

@ -415,6 +415,83 @@ nk_draw_image(struct nk_command_buffer *b, struct nk_rect r,
cmd->col = col;
}
NK_API void
nk_draw_nine_slice(struct nk_command_buffer *b, struct nk_rect r,
const struct nk_nine_slice *slc, struct nk_color col)
{
struct nk_image img;
const struct nk_image *slcimg = (const struct nk_image*)slc;
nk_ushort rgnX, rgnY, rgnW, rgnH;
rgnX = slcimg->region[0];
rgnY = slcimg->region[1];
rgnW = slcimg->region[2];
rgnH = slcimg->region[3];
/* top-left */
img.handle = slcimg->handle;
img.w = slcimg->w;
img.h = slcimg->h;
img.region[0] = rgnX;
img.region[1] = rgnY;
img.region[2] = slc->l;
img.region[3] = slc->t;
nk_draw_image(b,
nk_rect(r.x, r.y, (float)slc->l, (float)slc->t),
&img, col);
#define IMG_RGN(x, y, w, h) img.region[0] = (nk_ushort)(x); img.region[1] = (nk_ushort)(y); img.region[2] = (nk_ushort)(w); img.region[3] = (nk_ushort)(h);
/* top-center */
IMG_RGN(rgnX + slc->l, rgnY, rgnW - slc->l - slc->r, slc->t);
nk_draw_image(b,
nk_rect(r.x + (float)slc->l, r.y, (float)(r.w - slc->l - slc->r), (float)slc->t),
&img, col);
/* top-right */
IMG_RGN(rgnX + rgnW - slc->r, rgnY, slc->r, slc->t);
nk_draw_image(b,
nk_rect(r.x + r.w - (float)slc->r, r.y, (float)slc->r, (float)slc->t),
&img, col);
/* center-left */
IMG_RGN(rgnX, rgnY + slc->t, slc->l, rgnH - slc->t - slc->b);
nk_draw_image(b,
nk_rect(r.x, r.y + (float)slc->t, (float)slc->l, (float)(r.h - slc->t - slc->b)),
&img, col);
/* center */
IMG_RGN(rgnX + slc->l, rgnY + slc->t, rgnW - slc->l - slc->r, rgnH - slc->t - slc->b);
nk_draw_image(b,
nk_rect(r.x + (float)slc->l, r.y + (float)slc->t, (float)(r.w - slc->l - slc->r), (float)(r.h - slc->t - slc->b)),
&img, col);
/* center-right */
IMG_RGN(rgnX + rgnW - slc->r, rgnY + slc->t, slc->r, rgnH - slc->t - slc->b);
nk_draw_image(b,
nk_rect(r.x + r.w - (float)slc->r, r.y + (float)slc->t, (float)slc->r, (float)(r.h - slc->t - slc->b)),
&img, col);
/* bottom-left */
IMG_RGN(rgnX, rgnY + rgnH - slc->b, slc->l, slc->b);
nk_draw_image(b,
nk_rect(r.x, r.y + r.h - (float)slc->b, (float)slc->l, (float)slc->b),
&img, col);
/* bottom-center */
IMG_RGN(rgnX + slc->l, rgnY + rgnH - slc->b, rgnW - slc->l - slc->r, slc->b);
nk_draw_image(b,
nk_rect(r.x + (float)slc->l, r.y + r.h - (float)slc->b, (float)(r.w - slc->l - slc->r), (float)slc->b),
&img, col);
/* bottom-right */
IMG_RGN(rgnX + rgnW - slc->r, rgnY + rgnH - slc->b, slc->r, slc->b);
nk_draw_image(b,
nk_rect(r.x + r.w - (float)slc->r, r.y + r.h - (float)slc->b, (float)slc->r, (float)slc->b),
&img, col);
#undef IMG_RGN
}
NK_API void
nk_push_custom(struct nk_command_buffer *b, struct nk_rect r,
nk_command_custom_callback cb, nk_handle usr)
{

View File

@ -329,10 +329,19 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
else background = &style->normal;
/* draw background frame */
if (background->type == NK_STYLE_ITEM_COLOR) {
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, bounds, &background->data.image, nk_white);
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, bounds, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, bounds, style->rounding, background->data.color);
nk_stroke_rect(out, bounds, style->rounding, style->border, style->border_color);
} else nk_draw_image(out, bounds, &background->data.image, nk_white);}
break;
}}
area.w = NK_MAX(0, area.w - style->cursor_size);
if (edit->active)
@ -471,7 +480,7 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
/* vertical scroll */
if (cursor_pos.y < edit->scrollbar.y)
edit->scrollbar.y = NK_MAX(0.0f, cursor_pos.y - row_height);
if (cursor_pos.y >= edit->scrollbar.y + area.h)
if (cursor_pos.y >= edit->scrollbar.y + row_height)
edit->scrollbar.y = edit->scrollbar.y + row_height;
} else edit->scrollbar.y = 0;
}
@ -535,7 +544,8 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
}
if (background->type == NK_STYLE_ITEM_IMAGE)
background_color = nk_rgba(0,0,0,0);
else background_color = background->data.color;
else
background_color = background->data.color;
if (edit->select_start == edit->select_end) {
@ -642,7 +652,8 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
}
if (background->type == NK_STYLE_ITEM_IMAGE)
background_color = nk_rgba(0,0,0,0);
else background_color = background->data.color;
else
background_color = background->data.color;
nk_edit_draw_text(out, style, area.x - edit->scrollbar.x,
area.y - edit->scrollbar.y, 0, begin, l, row_height, font,
background_color, text_color, nk_false);

View File

@ -189,10 +189,12 @@ nk_font_bake_pack(struct nk_font_baker *baker,
}
/* setup font baker from temporary memory */
for (config_iter = config_list; config_iter; config_iter = config_iter->next) {
struct stbtt_fontinfo *font_info = &baker->build[i++].info;
it = config_iter;
do {
struct stbtt_fontinfo *font_info = &baker->build[i++].info;
font_info->userdata = alloc;
do {if (!stbtt_InitFont(font_info, (const unsigned char*)it->ttf_blob, 0))
if (!stbtt_InitFont(font_info, (const unsigned char*)it->ttf_blob, 0))
return nk_false;
} while ((it = it->n) != config_iter);
}
@ -1183,7 +1185,7 @@ nk_font_atlas_bake(struct nk_font_atlas *atlas, int *width, int *height,
tmp = atlas->temporary.alloc(atlas->temporary.userdata,0, tmp_size);
NK_ASSERT(tmp);
if (!tmp) goto failed;
memset(tmp,0,tmp_size);
NK_MEMSET(tmp,0,tmp_size);
/* allocate glyph memory for all fonts */
baker = nk_font_baker(tmp, atlas->glyph_count, atlas->font_num, &atlas->temporary);

View File

@ -22,43 +22,42 @@ nk_handle_id(int id)
return handle;
}
NK_API struct nk_image
nk_subimage_ptr(void *ptr, unsigned short w, unsigned short h, struct nk_rect r)
nk_subimage_ptr(void *ptr, nk_ushort w, nk_ushort h, struct nk_rect r)
{
struct nk_image s;
nk_zero(&s, sizeof(s));
s.handle.ptr = ptr;
s.w = w; s.h = h;
s.region[0] = (unsigned short)r.x;
s.region[1] = (unsigned short)r.y;
s.region[2] = (unsigned short)r.w;
s.region[3] = (unsigned short)r.h;
s.region[0] = (nk_ushort)r.x;
s.region[1] = (nk_ushort)r.y;
s.region[2] = (nk_ushort)r.w;
s.region[3] = (nk_ushort)r.h;
return s;
}
NK_API struct nk_image
nk_subimage_id(int id, unsigned short w, unsigned short h, struct nk_rect r)
nk_subimage_id(int id, nk_ushort w, nk_ushort h, struct nk_rect r)
{
struct nk_image s;
nk_zero(&s, sizeof(s));
s.handle.id = id;
s.w = w; s.h = h;
s.region[0] = (unsigned short)r.x;
s.region[1] = (unsigned short)r.y;
s.region[2] = (unsigned short)r.w;
s.region[3] = (unsigned short)r.h;
s.region[0] = (nk_ushort)r.x;
s.region[1] = (nk_ushort)r.y;
s.region[2] = (nk_ushort)r.w;
s.region[3] = (nk_ushort)r.h;
return s;
}
NK_API struct nk_image
nk_subimage_handle(nk_handle handle, unsigned short w, unsigned short h,
struct nk_rect r)
nk_subimage_handle(nk_handle handle, nk_ushort w, nk_ushort h, struct nk_rect r)
{
struct nk_image s;
nk_zero(&s, sizeof(s));
s.handle = handle;
s.w = w; s.h = h;
s.region[0] = (unsigned short)r.x;
s.region[1] = (unsigned short)r.y;
s.region[2] = (unsigned short)r.w;
s.region[3] = (unsigned short)r.h;
s.region[0] = (nk_ushort)r.x;
s.region[1] = (nk_ushort)r.y;
s.region[2] = (nk_ushort)r.w;
s.region[3] = (nk_ushort)r.h;
return s;
}
NK_API struct nk_image

View File

@ -49,6 +49,8 @@ nk_layout_row_calculate_usable_space(const struct nk_style *style, enum nk_panel
struct nk_vec2 spacing;
NK_UNUSED(type);
spacing = style->window.spacing;
/* calculate the usable panel space */
@ -599,7 +601,7 @@ nk_layout_widget_space(struct nk_rect *bounds, const struct nk_context *ctx,
panel_space = nk_layout_row_calculate_usable_space(&ctx->style, layout->type,
layout->bounds.w, layout->row.columns);
#define NK_FRAC(x) (x - (int)x) /* will be used to remove fookin gaps */
#define NK_FRAC(x) (x - (float)(int)x) /* will be used to remove fookin gaps */
/* calculate the width of one item inside the current layout space */
switch (layout->row.type) {
case NK_LAYOUT_DYNAMIC_FIXED: {
@ -738,8 +740,10 @@ nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx)
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
NK_ASSERT(ctx->current->layout);
if (!ctx || !ctx->current || !ctx->current->layout)
if (!ctx || !ctx->current || !ctx->current->layout) {
*bounds = nk_rect(0,0,0,0);
return;
}
win = ctx->current;
layout = win->layout;
@ -756,4 +760,9 @@ nk_layout_peek(struct nk_rect *bounds, struct nk_context *ctx)
layout->at_y = y;
layout->row.index = index;
}
NK_API void
nk_spacer(struct nk_context *ctx )
{
struct nk_rect dummy_rect = { 0, 0, 0, 0 };
nk_panel_alloc_space( &dummy_rect, ctx );
}

View File

@ -122,8 +122,8 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
/* window movement */
if ((win->flags & NK_WINDOW_MOVABLE) && !(win->flags & NK_WINDOW_ROM)) {
int left_mouse_down;
int left_mouse_clicked;
nk_bool left_mouse_down;
unsigned int left_mouse_clicked;
int left_mouse_click_in_cursor;
/* calculate draggable window space */
@ -138,7 +138,7 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
/* window movement by dragging */
left_mouse_down = in->mouse.buttons[NK_BUTTON_LEFT].down;
left_mouse_clicked = (int)in->mouse.buttons[NK_BUTTON_LEFT].clicked;
left_mouse_clicked = in->mouse.buttons[NK_BUTTON_LEFT].clicked;
left_mouse_click_in_cursor = nk_input_has_mouse_click_down_in_rect(in,
NK_BUTTON_LEFT, header, nk_true);
if (left_mouse_down && left_mouse_click_in_cursor && !left_mouse_clicked) {
@ -156,6 +156,8 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
layout->bounds = win->bounds;
layout->bounds.x += panel_padding.x;
layout->bounds.w -= 2*panel_padding.x;
layout->bounds.y += panel_padding.y;
layout->bounds.h -= 2*panel_padding.y;
if (win->flags & NK_WINDOW_BORDER) {
layout->border = nk_panel_get_border(style, win->flags, panel_type);
layout->bounds = nk_shrink_rect(layout->bounds, layout->border);
@ -216,12 +218,20 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
/* draw header background */
header.h += 1.0f;
if (background->type == NK_STYLE_ITEM_IMAGE) {
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
text.background = nk_rgba(0,0,0,0);
nk_draw_image(&win->buffer, header, &background->data.image, nk_white);
} else {
break;
case NK_STYLE_ITEM_NINE_SLICE:
text.background = nk_rgba(0, 0, 0, 0);
nk_draw_nine_slice(&win->buffer, header, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
text.background = background->data.color;
nk_fill_rect(out, header, 0, background->data.color);
break;
}
/* window close button */
@ -282,7 +292,7 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
label.h = font->height + 2 * style->window.header.label_padding.y;
label.w = t + 2 * style->window.header.spacing.x;
label.w = NK_CLAMP(0, label.w, header.x + header.w - label.x);
nk_widget_text(out, label,(const char*)title, text_len, &text, NK_TEXT_LEFT, font);}
nk_widget_text(out, label, (const char*)title, text_len, &text, NK_TEXT_LEFT, font);}
}
/* draw window background */
@ -292,9 +302,18 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
body.w = win->bounds.w;
body.y = (win->bounds.y + layout->header_height);
body.h = (win->bounds.h - layout->header_height);
if (style->window.fixed_background.type == NK_STYLE_ITEM_IMAGE)
switch(style->window.fixed_background.type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, body, &style->window.fixed_background.data.image, nk_white);
else nk_fill_rect(out, body, 0, style->window.fixed_background.data.color);
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, body, &style->window.fixed_background.data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, body, 0, style->window.fixed_background.data.color);
break;
}
}
/* set clipping rectangle */

View File

@ -37,7 +37,7 @@ nk_pool_init_fixed(struct nk_pool *pool, void *memory, nk_size size)
NK_ASSERT(size >= sizeof(struct nk_page));
if (size < sizeof(struct nk_page)) return;
/* first nk_page_element is embedded in nk_page, additional elements follow in adjacent space */
pool->capacity = 1 + (unsigned)(size - sizeof(struct nk_page)) / sizeof(struct nk_page_element);
pool->capacity = (unsigned)(1 + (size - sizeof(struct nk_page)) / sizeof(struct nk_page_element));
pool->pages = (struct nk_page*)memory;
pool->type = NK_BUFFER_FIXED;
pool->size = size;

View File

@ -60,16 +60,32 @@ nk_draw_progress(struct nk_command_buffer *out, nk_flags state,
}
/* draw background */
if (background->type == NK_STYLE_ITEM_COLOR) {
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, *bounds, &background->data.image, nk_white);
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, *bounds, style->rounding, background->data.color);
nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color);
} else nk_draw_image(out, *bounds, &background->data.image, nk_white);
break;
}
/* draw cursor */
if (cursor->type == NK_STYLE_ITEM_COLOR) {
switch(cursor->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, *scursor, &cursor->data.image, nk_white);
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, *scursor, &cursor->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, *scursor, style->rounding, cursor->data.color);
nk_stroke_rect(out, *scursor, style->rounding, style->border, style->border_color);
} else nk_draw_image(out, *scursor, &cursor->data.image, nk_white);
break;
}
}
NK_LIB nk_size
nk_do_progress(nk_flags *state,

View File

@ -86,13 +86,20 @@ nk_draw_property(struct nk_command_buffer *out, const struct nk_style_property *
}
/* draw background */
if (background->type == NK_STYLE_ITEM_IMAGE) {
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
text.background = nk_rgba(0, 0, 0, 0);
nk_draw_image(out, *bounds, &background->data.image, nk_white);
text.background = nk_rgba(0,0,0,0);
} else {
break;
case NK_STYLE_ITEM_NINE_SLICE:
text.background = nk_rgba(0, 0, 0, 0);
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
text.background = background->data.color;
nk_fill_rect(out, *bounds, style->rounding, background->data.color);
nk_stroke_rect(out, *bounds, style->rounding, style->border, background->data.color);
break;
}
/* draw label */
@ -115,7 +122,7 @@ nk_do_property(nk_flags *ws,
nk_filter_float
};
nk_bool active, old;
int num_len, name_len;
int num_len = 0, name_len;
char string[NK_MAX_NUMBER_BUFFER];
float size;

View File

@ -15,7 +15,7 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
{
nk_flags ws = 0;
int left_mouse_down;
int left_mouse_clicked;
unsigned int left_mouse_clicked;
int left_mouse_click_in_cursor;
float scroll_delta;
@ -103,18 +103,32 @@ nk_draw_scrollbar(struct nk_command_buffer *out, nk_flags state,
}
/* draw background */
if (background->type == NK_STYLE_ITEM_COLOR) {
switch (background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, *bounds, &background->data.image, nk_white);
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, *bounds, style->rounding, background->data.color);
nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color);
} else {
nk_draw_image(out, *bounds, &background->data.image, nk_white);
break;
}
/* draw cursor */
if (cursor->type == NK_STYLE_ITEM_COLOR) {
switch (cursor->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, *scroll, &cursor->data.image, nk_white);
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, *scroll, &cursor->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, *scroll, style->rounding_cursor, cursor->data.color);
nk_stroke_rect(out, *scroll, style->rounding_cursor, style->border_cursor, style->cursor_border_color);
} else nk_draw_image(out, *scroll, &cursor->data.image, nk_white);
break;
}
}
NK_LIB float
nk_do_scrollbarv(nk_flags *state,

View File

@ -42,12 +42,19 @@ nk_draw_selectable(struct nk_command_buffer *out,
}
}
/* draw selectable background and text */
if (background->type == NK_STYLE_ITEM_IMAGE) {
switch (background->type) {
case NK_STYLE_ITEM_IMAGE:
text.background = nk_rgba(0, 0, 0, 0);
nk_draw_image(out, *bounds, &background->data.image, nk_white);
text.background = nk_rgba(0,0,0,0);
} else {
nk_fill_rect(out, *bounds, style->rounding, background->data.color);
break;
case NK_STYLE_ITEM_NINE_SLICE:
text.background = nk_rgba(0, 0, 0, 0);
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
text.background = background->data.color;
nk_fill_rect(out, *bounds, style->rounding, background->data.color);
break;
}
if (icon) {
if (img) nk_draw_image(out, *icon, img, nk_white);

View File

@ -91,11 +91,17 @@ nk_draw_slider(struct nk_command_buffer *out, nk_flags state,
fill.h = bar.h;
/* draw background */
if (background->type == NK_STYLE_ITEM_IMAGE) {
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, *bounds, &background->data.image, nk_white);
} else {
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, *bounds, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, *bounds, style->rounding, background->data.color);
nk_stroke_rect(out, *bounds, style->rounding, style->border, style->border_color);
break;
}
/* draw slider bar */
@ -105,7 +111,8 @@ nk_draw_slider(struct nk_command_buffer *out, nk_flags state,
/* draw cursor */
if (cursor->type == NK_STYLE_ITEM_IMAGE)
nk_draw_image(out, *visual_cursor, &cursor->data.image, nk_white);
else nk_fill_circle(out, *visual_cursor, cursor->data.color);
else
nk_fill_circle(out, *visual_cursor, cursor->data.color);
}
NK_LIB float
nk_do_slider(nk_flags *state,

View File

@ -55,6 +55,14 @@ nk_style_get_color_by_name(enum nk_style_colors c)
return nk_color_names[c];
}
NK_API struct nk_style_item
nk_style_item_color(struct nk_color col)
{
struct nk_style_item i;
i.type = NK_STYLE_ITEM_COLOR;
i.data.color = col;
return i;
}
NK_API struct nk_style_item
nk_style_item_image(struct nk_image img)
{
struct nk_style_item i;
@ -63,11 +71,11 @@ nk_style_item_image(struct nk_image img)
return i;
}
NK_API struct nk_style_item
nk_style_item_color(struct nk_color col)
nk_style_item_nine_slice(struct nk_nine_slice slice)
{
struct nk_style_item i;
i.type = NK_STYLE_ITEM_COLOR;
i.data.color = col;
i.type = NK_STYLE_ITEM_NINE_SLICE;
i.data.slice = slice;
return i;
}
NK_API struct nk_style_item

View File

@ -49,14 +49,19 @@ nk_tree_state_base(struct nk_context *ctx, enum nk_tree_type type,
widget_state = nk_widget(&header, ctx);
if (type == NK_TREE_TAB) {
const struct nk_style_item *background = &style->tab.background;
if (background->type == NK_STYLE_ITEM_IMAGE) {
switch(background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, header, &background->data.image, nk_white);
text.background = nk_rgba(0,0,0,0);
} else {
text.background = background->data.color;
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, header, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, header, 0, style->tab.border_color);
nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
style->tab.rounding, background->data.color);
break;
}
} else text.background = style->window.background;
@ -234,12 +239,19 @@ nk_tree_element_image_push_hashed_base(struct nk_context *ctx, enum nk_tree_type
widget_state = nk_widget(&header, ctx);
if (type == NK_TREE_TAB) {
const struct nk_style_item *background = &style->tab.background;
if (background->type == NK_STYLE_ITEM_IMAGE) {
switch (background->type) {
case NK_STYLE_ITEM_IMAGE:
nk_draw_image(out, header, &background->data.image, nk_white);
} else {
break;
case NK_STYLE_ITEM_NINE_SLICE:
nk_draw_nine_slice(out, header, &background->data.slice, nk_white);
break;
case NK_STYLE_ITEM_COLOR:
nk_fill_rect(out, header, 0, style->tab.border_color);
nk_fill_rect(out, nk_shrink_rect(header, style->tab.border),
style->tab.rounding, background->data.color);
break;
}
}

View File

@ -227,14 +227,14 @@ nk_draw_list_alloc_vertices(struct nk_draw_list *list, nk_size count)
/* This assert triggers because your are drawing a lot of stuff and nuklear
* defined `nk_draw_index` as `nk_ushort` to safe space be default.
*
* So you reached the maximum number of indicies or rather vertexes.
* To solve this issue please change typdef `nk_draw_index` to `nk_uint`
* So you reached the maximum number of indices or rather vertexes.
* To solve this issue please change typedef `nk_draw_index` to `nk_uint`
* and don't forget to specify the new element size in your drawing
* backend (OpenGL, DirectX, ...). For example in OpenGL for `glDrawElements`
* instead of specifing `GL_UNSIGNED_SHORT` you have to define `GL_UNSIGNED_INT`.
* instead of specifying `GL_UNSIGNED_SHORT` you have to define `GL_UNSIGNED_INT`.
* Sorry for the inconvenience. */
if(sizeof(nk_draw_index)==2) NK_ASSERT((list->vertex_count < NK_USHORT_MAX &&
"To many verticies for 16-bit vertex indicies. Please read comment above on how to solve this problem"));
"To many vertices for 16-bit vertex indices. Please read comment above on how to solve this problem"));
return vtx;
}
NK_INTERN nk_draw_index*

View File

@ -431,10 +431,15 @@ nk_window_is_hovered(struct nk_context *ctx)
{
NK_ASSERT(ctx);
NK_ASSERT(ctx->current);
if (!ctx || !ctx->current) return 0;
if(ctx->current->flags & NK_WINDOW_HIDDEN)
if (!ctx || !ctx->current || (ctx->current->flags & NK_WINDOW_HIDDEN))
return 0;
return nk_input_is_mouse_hovering_rect(&ctx->input, ctx->current->bounds);
else {
struct nk_rect actual_bounds = ctx->current->bounds;
if (ctx->begin->flags & NK_WINDOW_MINIMIZED) {
actual_bounds.h = ctx->current->layout->header_height;
}
return nk_input_is_mouse_hovering_rect(&ctx->input, actual_bounds);
}
}
NK_API nk_bool
nk_window_is_any_hovered(struct nk_context *ctx)

View File

@ -1 +1 @@
build.py --macro NK --intro HEADER --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS > ..\nuklear.h
build.py --macro NK --intro HEADER --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_9slice.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS > ..\nuklear.h

View File

@ -1,3 +1,3 @@
#!/bin/sh
python build.py --macro NK --intro HEADER --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS > ../nuklear.h
python build.py --macro NK --intro HEADER --pub nuklear.h --priv1 nuklear_internal.h,nuklear_math.c,nuklear_util.c,nuklear_color.c,nuklear_utf8.c,nuklear_buffer.c,nuklear_string.c,nuklear_draw.c,nuklear_vertex.c --extern stb_rect_pack.h,stb_truetype.h --priv2 nuklear_font.c,nuklear_input.c,nuklear_style.c,nuklear_context.c,nuklear_pool.c,nuklear_page_element.c,nuklear_table.c,nuklear_panel.c,nuklear_window.c,nuklear_popup.c,nuklear_contextual.c,nuklear_menu.c,nuklear_layout.c,nuklear_tree.c,nuklear_group.c,nuklear_list_view.c,nuklear_widget.c,nuklear_text.c,nuklear_image.c,nuklear_9slice.c,nuklear_button.c,nuklear_toggle.c,nuklear_selectable.c,nuklear_slider.c,nuklear_progress.c,nuklear_scrollbar.c,nuklear_text_editor.c,nuklear_edit.c,nuklear_property.c,nuklear_chart.c,nuklear_color_picker.c,nuklear_combo.c,nuklear_tooltip.c --outro LICENSE,CHANGELOG,CREDITS > ../nuklear.h

Some files were not shown because too many files have changed in this diff Show More