Immediate-Mode-UI / Immediate-Mode-UI/Nuklear

nk_widget() and nk_widget_bounds() do not return the same values

Open
#258 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
11.4k
Forks
686
Avg merge
4d 1h
Merged PRs (30d)
3

Description

The nk_widget() function inexplicably returns truncated values for the bounds, unlike nk_widget_bounds(). The guilty code in nk_widget() is:

````
/* need to convert to int here to remove floating point errors */
bounds->x = (float)((int)bounds->x);
bounds->y = (float)((int)bounds->y);
bounds->w = (float)((int)bounds->w);
bounds->h = (float)((int)bounds->h);
````
Can anyone explain what "floating point errors" it might be guarding against, and why does nk_widget_bounds() give a different value?

Contributor guide

Open the contributing guide

Research direction

Compare the nk_widget() implementation with nk_widget_bounds(), focusing on the shown integer conversions and the values each function returns. Determine which behavior is intended and document or correct the discrepancy so both functions have consistent bounds results.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.