Nuklear icon indicating copy to clipboard operation
Nuklear copied to clipboard

xlib: Images cause scrollable content to break

Open purpasmart96 opened this issue 1 year ago • 0 comments

In the pure x11 demo, after enabling stb_image and loading your images via the nk_xsurf_load_image_from_file function

You then use that loaded image later on in for example nk_button_image_label(ctx, icon, "text1", NK_TEXT_CENTERED);

However if any content in that window is scrollable it causes weird rendering/clipping issues.

Here it is when there is scrolling

Screenshot_20241108_125410

And when there is no scrolling

Screenshot_20241108_125601

This issue goes away if I forgo the image/icon by doing nk_button_label(ctx, "text1"); instead, but that kinda defeats the whole point of having image loading support.

To reproduce my examples add the following to demo/x11/main.c line 17: #define NK_XLIB_INCLUDE_STB_IMAGE #define NK_XLIB_IMPLEMENT_STB_IMAGE

line 154:

// Make sure the is a image file named 'image.png' in the directory you launch the demo
struct nk_image icon = nk_xsurf_load_image_from_file("image.png");

line 177:

nk_layout_row_dynamic(ctx, 64, 3);
nk_button_image_label(ctx, icon, "text1", NK_TEXT_CENTERED);
nk_button_image_label(ctx, icon, "text1", NK_TEXT_CENTERED);
nk_button_image_label(ctx, icon, "text1", NK_TEXT_CENTERED);

I believe I also had change the makefile to use C99 instead of C89 so that stb_image would compile.

Please let me know if I'm doing anything, wrong or if you guys need more info.

purpasmart96 avatar Nov 08 '24 21:11 purpasmart96