Immediate-Mode-UI / Immediate-Mode-UI/Nuklear
xlib: Images cause scrollable content to break
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.4k
- Forks
- 686
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 3
Description
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

And when there is no scrolling

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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with demo/x11/main.c and reproduce the issue using NK_XLIB_INCLUDE_STB_IMAGE, NK_XLIB_IMPLEMENT_STB_IMAGE, nk_xsurf_load_image_from_file, and nk_button_image_label. Compare the rendering with and without scrolling, then trace the image path involved in those entry points. Done means image buttons render correctly in scrollable and non-scrollable content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100