Closed raphael10-collab closed 9 months ago
In basic.cc file :
basic.cc
#define NK_IMPLEMENTATION #include "../../Nuklear/nuklear.h" // https://immediate-mode-ui.github.io/Nuklear/doc/#nuklear/example /* init gui state */ struct nk_context ctx; //nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font); nk_bool nk_init_default(struct nk_context *ctx, const struct nk_user_font *font); // init gui state enum {EASY, HARD}; static int op = EASY; static float value = 0.6f; static int i = 20; //nk_init_fixed(... &ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font); nk_bool nk_init_default(struct nk_context *ctx, const struct nk_user_font *font); if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) { // fixed widget pixel width nk_layout_row_static(&ctx, 30, 80, 1); if (nk_button_label(&ctx, "button")) { // event handling } // fixed widget window ratio width nk_layout_row_dynamic(&ctx, 30, 2); if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY; if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD; // custom widget pixel width nk_layout_row_begin(&ctx, NK_STATIC, 30, 2); { nk_layout_row_push(&ctx, 50); nk_label(&ctx, "Volume:", NK_TEXT_LEFT); nk_layout_row_push(&ctx, 110); nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f); } nk_layout_row_end(&ctx); } nk_end(ctx);
Compiling:
cmake --build cmakebuilddir/ [ 14%] Building CXX object CMakeFiles/basic.dir/src/basic.cc.o /home/raphy/webview-prj/src/basic.cc:40:1: error: expected unqualified-id before ‘if’ 40 | if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220), | ^~ /home/raphy/webview-prj/src/basic.cc:61:7: error: expected constructor, destructor, or type conversion before ‘(’ token 61 | nk_end(ctx); | ^ gmake[2]: *** [CMakeFiles/basic.dir/build.make:76: CMakeFiles/basic.dir/src/basic.cc.o] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/basic.dir/all] Error 2 gmake: *** [Makefile:91: all] Error 2
In
basic.cc
file :Compiling: