#966

[SDL3+Emscripten] 2 issues: nk_label_wrap bleeds and ui unresponsive?

Openshabbah11opened 4mo ago

Hi, I have 2 problems: after using esc or q key for quitting the about popup, the whole ui is responsive and the first line manifest is bleeding?

code:

SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event* event) {
[...]
 /* Remember to always rescale the event coordinates,
     * if your renderer uses custom scale. */
    SDL_ConvertEventToRenderCoordinates(app->renderer, event);

    nk_sdl_handle_event(app->ctx, event);
if ( event->key.key == SDLK_Q | event->key.key == SDLK_ESCAPE ) {
//SDL_Log("q pressed");
if ( show_app_about == nk_true ) {
        show_app_about = nk_false;
        return SDL_APP_CONTINUE;
}
if ( Show_Search_Menu == nk_true ) {
        Show_Search_Menu = nk_false;
        return SDL_APP_CONTINUE;
}
fprintf(stdout, "nk_false: %d\n", show_app_about);
        return SDL_APP_CONTINUE;
SDL_Log("exited show_app_about state and returned");
}
if ( event->key.key == SDLK_A ) {
//SDL_Log("q pressed");
        show_app_about = nk_true;
   fprintf(stdout, "nk_true: %d\n", show_app_about);
        return SDL_APP_CONTINUE;
}
if ( event->key.key == SDLK_SLASH ) {
SDL_Log("search key invoked");
//if ( Show_Search_Menu == nk_false ) {
Show_Search_Menu = nk_true;
//SDL_Log("search menu turned on");
//}
//if ( Show_Search_Menu == nk_true ) {
//Show_Search_Menu = nk_false;
//SDL_Log("search menu turned on");
//}
fprintf(stdout, "Show_Search_Menu: %d\n", Show_Search_Menu);
        return SDL_APP_CONTINUE;
}

    //SDL_Log("exiting event");
    return SDL_APP_CONTINUE;
}

SDL_AppResult
SDL_AppIterate(void *appstate)
{
    //SDL_Log("Aber i iterate");
    struct nk_sdl_app* app = (struct nk_sdl_app*)appstate;
    struct nk_context* ctx = app->ctx;

    nk_input_end(ctx);

    /* GUI */
if (nk_begin(ctx, "ic.wiki", nk_rect(0, 0, width, height), NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_SCALABLE|NK_WINDOW_MINIMIZABLE|NK_WINDOW_TITLE) ) {

        nk_layout_row_static(ctx, (height/40), (width/20), 1);
        if ( nk_button_label(ctx, "About") ) {
   show_app_about = nk_true;
   fprintf(stdout, "nk_true: %d\n", show_app_about);
   //Open_Full_Dataset();
            SDL_Log("button pressed");
        }
    }
[...]
            if (show_app_about)
        {
            /* about popup */
            if (nk_popup_begin(ctx, NK_POPUP_DYNAMIC, "About", NK_WINDOW_CLOSABLE|NK_WINDOW_SCALABLE, nk_rect( (width / 20) , (height / 20) , (width / 4), (height / 4) )))
            {
                nk_layout_row_dynamic(ctx, 10, 1);
//nk_layout_row_static(ctx, (height / 10), (width / 8.5), 50);
if (nk_tree_push(ctx, NK_TREE_NODE, "Manifest", NK_MAXIMIZED)) {
                nk_label_wrap(ctx, "\176 ic.wiki is a site made by me to compare (hopefully) all of ic in the world in a flat fashion; tired to dumpster dive in to hundreds of nothingness pdf pages");
                nk_label_wrap(ctx, "\176 The full dataset can be downloaded below:");
        if ( nk_button_label(ctx, "https://ic.wiki/public/dataset-latest.csv.zstd") ) {
Open_Full_Dataset();
}
nk_tree_pop(ctx);
}
if (nk_tree_push(ctx, NK_TREE_NODE, "Open Source License & Credits", NK_MINIMIZED))
                {
if (nk_tree_push(ctx, NK_TREE_NODE, "Powering Site", NK_MINIMIZED)) {
                    //nk_layout_row_dynamic(ctx, 55, 1);
        if ( nk_button_label(ctx, "SDL3\54 Zlib\54 Sam Lantinga\54 1997-2026") ) {
Open_SDL_Credits();
}
        if ( nk_button_label(ctx, "Nuklear ui\54 MIT\54 Micha Mettke\54 2017") ) {
Open_Nuklear_Credits();
}
        if ( nk_button_label(ctx, "Emscripten\54 MIT University of Illinois NCSA Open Source License\54 Emscripten authors 2010-2014") ) {
Open_Emscripten_Credits();
}
        if ( nk_button_label(ctx, "SQLite\54 Open License") ) {
Open_SQLite_Credits();
}
    nk_tree_pop(ctx);
}
if (nk_tree_push(ctx, NK_TREE_NODE, "Curation of Dataset", NK_MINIMIZED)) {
        if ( nk_button_label(ctx, "LibreOffice Calc") ) {
Open_LibreOffice_Credits();
}
    nk_tree_pop(ctx);
}
nk_tree_pop(ctx);
                }
nk_popup_end(ctx);
            } else show_app_about = nk_false;
        }
    nk_end(ctx);

Activity

17
sleeptightAnsiC4mo ago

Could you provide minimal repro by modifying demo/sdl3_renderer/main.c alone?

The snippet is incomplete and has bunch of variables/functions coming from elsewhere. It's impossible to tell what's going. It may as well be a bug in your code. Hard to tell...

Also, did you report it for [SDL3+Emscripten] because it only reproduces under Emscripten, or because you simply didn't test with anything else?

sleeptightAnsiC4mo ago

Could you provide minimal repro by modifying demo/sdl3_renderer/main.c alone?

The snippet is incomplete and has bunch of variables/functions coming from elsewhere. It's impossible to tell what's going on. It may as well be a bug in your code.

Also, did you report it for [SDL3+Emscripten] because it only reproduces under Emscripten, or because you simply didn't test with anything else?

sleeptightAnsiC4mo ago

Could you provide minimal repro by modifying demo/sdl3_renderer/main.c alone?

The snippet is incomplete and has bunch of variables/functions coming from elsewhere. It's impossible to tell what's going on. It may as well be a bug in your code.

Also, did you report it for [SDL3+Emscripten] because it only reproduces under Emscripten, or because you simply didn't test with anything else?

sleeptightAnsiC4mo ago

Could you provide minimal repro by modifying demo/sdl3_renderer/main.c alone?

The snippet is incomplete and has bunch of variables/functions coming from elsewhere. It's impossible to tell what's going on. It may as well be a bug in your code.

Also, did you report it for [SDL3+Emscripten] because it only reproduces under Emscripten, or because you simply didn't test with anything else?

shabbah114mo ago

Also, did you report it for [SDL3+Emscripten] because it only reproduces under Emscripten, or because you simply didn't test with anything else?

No just what platform using, haven't tried otherwise.

The full file:

main.c

Edit: metasdl.h is the sdl3 init boiler moved out

shabbah114mo ago

Also, did you report it for [SDL3+Emscripten] because it only reproduces under Emscripten, or because you simply didn't test with anything else?

No just what platform using, haven't tried otherwise.

The full file:

main.c

Edit: metasdl.h is the sdl3 init boiler moved out

shabbah114mo ago

Also, did you report it for [SDL3+Emscripten] because it only reproduces under Emscripten, or because you simply didn't test with anything else?

No just what platform using, haven't tried otherwise.

The full file:

main.c

Edit: metasdl.h is the sdl3 init boiler moved out

shabbah114mo ago

Also, did you report it for [SDL3+Emscripten] because it only reproduces under Emscripten, or because you simply didn't test with anything else?

No just what platform using, haven't tried otherwise.

The full file:

main.c

Edit: metasdl.h is the sdl3 init boiler moved out

RobLoach4mo ago

Haven't tested this fully, but from a quick look...

event->key.key == SDLK_Q | event->key.key == SDLK_ESCAPE

That should likely be ||.

You're also passing CLI input directly into sqlite, which I'd be worried about from security perspective, but that's another point.

There's a SDL_Log() that's called every frame when width < height. While not a big thing, it could cause lag.

RobLoach4mo ago

Haven't tested this fully, but from a quick look...

event->key.key == SDLK_Q | event->key.key == SDLK_ESCAPE

That should likely be ||.

You're also passing CLI input directly into sqlite, which I'd be worried about from security perspective, but that's another point.

There's a SDL_Log() that's called every frame when width < height. While not a big thing, it could cause lag.

RobLoach4mo ago

Haven't tested this fully, but from a quick look...

event->key.key == SDLK_Q | event->key.key == SDLK_ESCAPE

That should likely be ||.

You're also passing CLI input directly into sqlite, which I'd be worried about from security perspective, but that's another point.

There's a SDL_Log() that's called every frame when width < height. While not a big thing, it could cause lag.

shabbah114mo ago

Played around a bit and changed it ultimately to:

if ( event->key.key == SDLK_ESCAPE || event->key.key == SDLK_Q ) {
        //show_app_about = nk_false;
Show_Search_Menu = nk_false;
}
if ( event->key.key == SDLK_A ) {
        show_app_about = nk_true;
}
if ( event->key.key == SDLK_SLASH ) {
Show_Search_Menu = nk_true;
}

Weird because nuklear seems only to freeze when closing a window? works perfectly fine to open a window and in right corner the extend corner is not showing when closing with a bind so seems like the handover back to ui nk_input is bricking somewhere?

You're also passing CLI input directly into sqlite, which I'd be worried about from security perspective, but that's another point. There's a SDL_Log() that's called every frame when width < height. While not a big thing, it could cause lag.

Removed all of that now but just trying sqlite out and tried to detect if on mobile or not and act accordingly but realized its a diminishing return battle.

Edit: spelling mistake

shabbah114mo ago

Played around a bit and changed it ultimately to:

if ( event->key.key == SDLK_ESCAPE || event->key.key == SDLK_Q ) {
        //show_app_about = nk_false;
Show_Search_Menu = nk_false;
}
if ( event->key.key == SDLK_A ) {
        show_app_about = nk_true;
}
if ( event->key.key == SDLK_SLASH ) {
Show_Search_Menu = nk_true;
}

Weird because nuklear seems only to freeze when closing a window? works perfectly fine to open a window and in right corner the extend corner is not showing when closing with a bind so seems like the handover back to ui nk_input is bricking somewhere?

You're also passing CLI input directly into sqlite, which I'd be worried about from security perspective, but that's another point. There's a SDL_Log() that's called every frame when width < height. While not a big thing, it could cause lag.

Removed all of that now but just trying sqlite out and tried to detect if on mobile or not and act accordingly but realized its a diminishing return battle.

Edit: spelling mistake

shabbah114mo ago

Played around a bit and changed it ultimately to:

if ( event->key.key == SDLK_ESCAPE || event->key.key == SDLK_Q ) {
        //show_app_about = nk_false;
Show_Search_Menu = nk_false;
}
if ( event->key.key == SDLK_A ) {
        show_app_about = nk_true;
}
if ( event->key.key == SDLK_SLASH ) {
Show_Search_Menu = nk_true;
}

Weird because nuklear seems only to freeze when closing a window? works perfectly fine to open a window and in right corner the extend corner is not showing when closing with a bind so seems like the handover back to ui nk_input is bricking somewhere?

You're also passing CLI input directly into sqlite, which I'd be worried about from security perspective, but that's another point. There's a SDL_Log() that's called every frame when width < height. While not a big thing, it could cause lag.

Removed all of that now but just trying sqlite out and tried to detect if on mobile or not and act accordingly but realized its a diminishing return battle.

Edit: spelling mistake

saiprasadhakki2mo ago

@shabbah11 sorry for the earlier message, i did not realize you were already using the available template

Now coming to the problem it seems that width and height variables are being used globally by other blocks as well, that means there are multiple blocks driving the same variable and hence you are unable to resize or minimize your UI try statically assigning rects to begin functions. example :nk_rect(20, 20, 100, 100).

Again toggle to close logic is dirty, you are not calling nk_popup_close still latches focus onto the closed popup (not rendered), and here it is fine to declare the boolean globally.

As for the text bleeding you are missing 1 line of code before the text, just add this before: nk_layout_row_static(ctx, 100, 200, 1);

NOTE: I have tested this against sdl3_renderer demo and everything works fine.

@shabbah11 I would highly recommend you go through the overview function the implements and shows how to use features to debug.

saiprasadhakki2mo ago

@shabbah11 sorry for the earlier message, i did not realize you were already using the available template

Now coming to the problem it seems that width and height variables are being used globally by other blocks as well, that means there are multiple blocks driving the same variable and hence you are unable to resize or minimize your UI try statically assigning rects to begin functions. example :nk_rect(20, 20, 100, 100).

Again toggle to close logic is dirty, you are not calling nk_popup_close still latches focus onto the closed popup (not rendered), and here it is fine to declare the boolean globally.

As for the text bleeding you are missing 1 line of code before the text, just add this before: nk_layout_row_static(ctx, 100, 200, 1);

NOTE: I have tested this against sdl3_renderer demo and everything works fine.

@shabbah11 I would highly recommend you go through the overview function the implements and shows how to use features to debug.

saiprasadhakki2mo ago

@shabbah11 here is the example main.c file, I have corrected your stuff.

Place this in the demo/sdl3_renderer folder and build.

Please reach out to me in case you can't figure it out, do read the last line of my previous comment.

This issue is good to be closed.