Open StrikerMan780 opened 6 months ago
I need some help with this one if anyone can. I've been at this one for a few days now and I'm losing my mind. Video in first post demonstrating what's going on.
Help? Please? This problem is still happening with the latest version, and I've been struggling with it since getting the library back in May. I'm running out of ideas, and time. Going to have to abandon Nuklear before long if there's no solution.
I'm noticing the biggest culprits are buttons and sliders. If I just use labels, it's a tiny bit less prone to this problem.
And upon even further inspection, it seems to be related more specifically to NK_TEXT_CENTERED. There seems to be some kind of bug with how it calculates the width of the element. Because if I use centered text with labels, it behaves exactly like buttons do. (Aka. Borked)
If I comment out line 23660 in nuklear.h, in nk_widget_text. The line that reads: if (label.w >= label.x) label.w -= label.x;
It seemingly fixes the bug. Consider giving this a look over.
@StrikerMan780 I am having this exact issue in my project as well. But it doesn't happen in the allegro5 demo I tested, so that indicates to me that I am doing something wrong, but idk..
This exhibits the strange text clipping
https://github.com/user-attachments/assets/83255a41-a3d1-4b77-92ed-6e19a0f13bfa
This works as expected
https://github.com/user-attachments/assets/e7d6c091-f756-42b7-a94c-54fa96ba2d71
I managed to fix this by correcting the nk.height
value I set in my_font_create_from_file
and the width returned from my_font_get_text_width
. In my case I was scaling them to handle high DPI, so I just changed them to return unscaled values, and then I only apply scaling factor when rendering the text in NK_COMMAND_TEXT
.
No strange clipping anymore🎉 https://github.com/user-attachments/assets/e59acbc5-a66d-4b37-bf10-16a06cb3fbb1
Still can't find a way to fix it on my end without altering that line in Nuklear. The values I return from my text width functions are correct, it's the width of the text in pixels.
The text seems to randomly clip for whatever reason, when I drag the window around my screen. Not entirely sure why.
Most of the code is based on the demo.
Link to the video demonstrating the problem: https://shadowmavericks.com/files/ShareX/tfury_2024-05-25_22-41-40.mp4 Alt: https://github.com/Immediate-Mode-UI/Nuklear/assets/1618721/8099e1ff-450a-486f-9282-a82584c83bbd
My code thus far: