Skip to content

Commit

Permalink
Merge pull request #635 from Immediate-Mode-UI/xcb-cairo
Browse files Browse the repository at this point in the history
Add XCB-Cairo
  • Loading branch information
RobLoach authored Apr 27, 2024
2 parents 31b5729 + 7f5c642 commit a10a830
Show file tree
Hide file tree
Showing 25 changed files with 1,057 additions and 290 deletions.
16 changes: 1 addition & 15 deletions demo/allegro5/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
#define INCLUDE_OVERVIEW
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */

#ifdef INCLUDE_ALL
Expand Down Expand Up @@ -114,20 +114,6 @@ int main(void)

ctx = nk_allegro5_init(font, display, WINDOW_WIDTH, WINDOW_HEIGHT);

/* style.c */
#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

while(1)
{
bool get_event;
Expand Down
23 changes: 22 additions & 1 deletion demo/common/overview.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ overview(struct nk_context *ctx)
/* window flags */
static nk_bool show_menu = nk_true;
static nk_flags window_flags = NK_WINDOW_TITLE|NK_WINDOW_BORDER|NK_WINDOW_SCALABLE|NK_WINDOW_MOVABLE|NK_WINDOW_MINIMIZABLE;
nk_flags actual_window_flags;
nk_flags actual_window_flags = 0;

/* widget flags */
static nk_bool disable_widgets = nk_false;
Expand All @@ -13,6 +13,13 @@ overview(struct nk_context *ctx)
static enum nk_style_header_align header_align = NK_HEADER_RIGHT;
static nk_bool show_app_about = nk_false;

#ifdef INCLUDE_STYLE
/* styles */
static const char* themes[] = {"Black", "White", "Red", "Blue", "Dark"};
static int current_theme = 0;
#endif

/* window flags */
ctx->style.window.header.align = header_align;

actual_window_flags = window_flags;
Expand Down Expand Up @@ -121,6 +128,20 @@ overview(struct nk_context *ctx)
} else show_app_about = nk_false;
}

#ifdef INCLUDE_STYLE
/* style selector */
nk_layout_row_dynamic(ctx, 0, 2);
{
int new_theme;
nk_label(ctx, "Style:", NK_TEXT_LEFT);
new_theme = nk_combo(ctx, themes, NK_LEN(themes), current_theme, 25, nk_vec2(200, 200));
if (new_theme != current_theme) {
current_theme = new_theme;
set_style(ctx, current_theme);
}
}
#endif

/* window flags */
if (nk_tree_push(ctx, NK_TREE_TAB, "Window", NK_MINIMIZED)) {
nk_layout_row_dynamic(ctx, 30, 2);
Expand Down
14 changes: 0 additions & 14 deletions demo/d3d11/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,6 @@ int main(void)
/*nk_style_load_all_cursors(ctx, atlas->cursors);*/
/*nk_style_set_font(ctx, &droid->handle)*/;}

/* style.c */
#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
while (running)
{
Expand Down
14 changes: 0 additions & 14 deletions demo/d3d12/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,6 @@ int main(void)
/* Now we can cleanup all resources consumed by font stashing that are no longer used */
nk_d3d12_font_stash_cleanup();

/* style.c */
#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
while (running)
{
Expand Down
14 changes: 0 additions & 14 deletions demo/d3d9/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,6 @@ int main(void)
/*nk_style_load_all_cursors(ctx, atlas->cursors);*/
/*nk_style_set_font(ctx, &droid->handle)*/;}

/* style.c */
#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
while (running)
{
Expand Down
14 changes: 0 additions & 14 deletions demo/gdi/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,6 @@ int main(void)
font = nk_gdifont_create("Arial", 14);
ctx = nk_gdi_init(font, dc, WINDOW_WIDTH, WINDOW_HEIGHT);

/* style.c */
#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

while (running)
{
/* Input */
Expand Down
14 changes: 0 additions & 14 deletions demo/gdip/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,6 @@ int main(void)
font = nk_gdipfont_create("Arial", 12);
nk_gdip_set_font(font);

/* style.c */
#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

while (running)
{
/* Input */
Expand Down
16 changes: 2 additions & 14 deletions demo/glfw_opengl2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/* #define INCLUDE_ALL */
/* #define INCLUDE_STYLE */
/* #define INCLUDE_CALCULATOR */
#define INCLUDE_CANVAS
/* #define INCLUDE_CANVAS */
/* #define INCLUDE_FILE_BROWSER */
/* #define INCLUDE_OVERVIEW */
/* #define INCLUDE_NODE_EDITOR */
Expand All @@ -49,6 +49,7 @@
#define INCLUDE_STYLE
#define INCLUDE_CALCULATOR
#define INCLUDE_CANVAS
#define INCLUDE_FILE_BROWSER
#define INCLUDE_OVERVIEW
#define INCLUDE_NODE_EDITOR
#endif
Expand Down Expand Up @@ -120,19 +121,6 @@ int main(void)
/*nk_style_load_all_cursors(ctx, atlas->cursors);*/
/*nk_style_set_font(ctx, &droid->handle);*/}

#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;

#ifdef INCLUDE_FILE_BROWSER
Expand Down
15 changes: 1 addition & 14 deletions demo/glfw_opengl3/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
#define INCLUDE_OVERVIEW
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */

#ifdef INCLUDE_ALL
Expand Down Expand Up @@ -125,19 +125,6 @@ int main(void)
/*nk_style_load_all_cursors(ctx, atlas->cursors);*/
/*nk_style_set_font(ctx, &droid->handle);*/}

#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
while (!glfwWindowShouldClose(win))
{
Expand Down
15 changes: 1 addition & 14 deletions demo/glfw_opengl4/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
#define INCLUDE_OVERVIEW
/*#define INCLUDE_OVERVIEW */
/*#define INCLUDE_NODE_EDITOR */

#ifdef INCLUDE_ALL
Expand Down Expand Up @@ -125,19 +125,6 @@ int main(void)
/*nk_style_load_all_cursors(ctx, atlas->cursors);*/
/*nk_style_set_font(ctx, &droid->handle);*/}

#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

/* Create bindless texture.
* The index returned is not the opengl resource id.
* IF you need the GL resource id use: nk_glfw3_get_tex_ogl_id() */
Expand Down
16 changes: 1 addition & 15 deletions demo/glfw_vulkan/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* ===============================================================*/
/* 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_ALL */
/*#define INCLUDE_STYLE */
/*#define INCLUDE_CALCULATOR */
/*#define INCLUDE_CANVAS */
Expand Down Expand Up @@ -2104,20 +2104,6 @@ int main(void) {
/*nk_style_load_all_cursors(ctx, atlas->cursors);*/
/*nk_style_set_font(ctx, &droid->handle);*/}

#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for
* anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

img = nk_image_ptr(demo.demo_texture_image_view);
bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
while (!glfwWindowShouldClose(demo.win)) {
Expand Down
13 changes: 0 additions & 13 deletions demo/rawfb/x11/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,6 @@ main(void)
rawfb = nk_rawfb_init(fb, tex_scratch, xw.width, xw.height, xw.width * 4, pl);
if (!rawfb) running = 0;

#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(&rawfb->ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(&rawfb->ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(&rawfb->ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(&rawfb->ctx, THEME_DARK);
#endif
#endif

while (running) {
/* Input */
XEvent evt;
Expand Down
13 changes: 0 additions & 13 deletions demo/sdl_opengl2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,6 @@ main(int argc, char *argv[])
/*nk_style_load_all_cursors(ctx, atlas->cursors);*/
/*nk_style_set_font(ctx, &roboto->handle)*/;}

#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
while (running)
{
Expand Down
14 changes: 0 additions & 14 deletions demo/sdl_opengl3/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,6 @@ int main(int argc, char *argv[])
/*nk_style_load_all_cursors(ctx, atlas->cursors);*/
/*nk_style_set_font(ctx, &roboto->handle);*/}

/* style.c */
#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

bg.r = 0.10f, bg.g = 0.18f, bg.b = 0.24f, bg.a = 1.0f;
while (running)
{
Expand Down
14 changes: 0 additions & 14 deletions demo/sdl_opengles2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,6 @@ int main(int argc, char* argv[])
/*nk_style_load_all_cursors(ctx, atlas->cursors);*/
/*nk_style_set_font(ctx, &roboto->handle)*/;}

/* style.c */
#ifdef INCLUDE_STYLE
/* ease regression testing during Nuklear release process; not needed for anything else */
#ifdef STYLE_WHITE
set_style(ctx, THEME_WHITE);
#elif defined(STYLE_RED)
set_style(ctx, THEME_RED);
#elif defined(STYLE_BLUE)
set_style(ctx, THEME_BLUE);
#elif defined(STYLE_DARK)
set_style(ctx, THEME_DARK);
#endif
#endif

#if defined(__EMSCRIPTEN__)
#include <emscripten.h>
emscripten_set_main_loop_arg(MainLoop, (void*)ctx, 0, nk_true);
Expand Down
Loading

0 comments on commit a10a830

Please sign in to comment.