Integrate the canvas example with the demos
This commit is contained in:
parent
24912785b7
commit
459ba9c48c
@ -29,18 +29,44 @@
|
||||
#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
|
||||
|
||||
/* ===============================================================
|
||||
*
|
||||
@ -139,9 +165,18 @@ int main(void)
|
||||
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 */
|
||||
|
84
demo/canvas.c
Normal file
84
demo/canvas.c
Normal file
@ -0,0 +1,84 @@
|
||||
/* 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 + 180, 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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
canvas_end(ctx, &canvas);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
@ -269,6 +274,9 @@ int main(void)
|
||||
#ifdef INCLUDE_CALCULATOR
|
||||
calculator(ctx);
|
||||
#endif
|
||||
#ifdef INCLUDE_CANVAS
|
||||
canvas(ctx);
|
||||
#endif
|
||||
#ifdef INCLUDE_OVERVIEW
|
||||
overview(ctx);
|
||||
#endif
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -22,6 +22,44 @@
|
||||
#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 */
|
||||
@ -187,6 +225,21 @@ int main(int argc, char **argv)
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
|
@ -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
|
||||
@ -168,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
|
||||
|
@ -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
|
||||
@ -178,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
|
||||
|
@ -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
|
||||
|
||||
/* ===============================================================
|
||||
*
|
||||
@ -112,9 +137,18 @@ MainLoop(void* loopArg){
|
||||
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 */
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -28,6 +28,44 @@
|
||||
|
||||
#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)
|
||||
@ -504,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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user