Immediate-Mode-UI / Immediate-Mode-UI/Nuklear
NK_WINDOW_HIDDEN + nk_begin() is a broken combo
- Dominant language
- C
- Stars
- 11.4k
- Forks
- 686
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 3
Description
Since the very first time I used Nuklear years ago, this has been driving me mad.
If you put NK_WINDOW_HIDDEN as an attribute on window creation, the window will always be hidden. Because if the window is made visible, it is being hidden the next time it comes across the window definition in the main render loop.
> Windows by default are visible unless explicitly being defined with flag NK_WINDOW_HIDDEN
The documentation here is just wrong. The only reliable way to make a program with multiple windows being operated, closed and opened is by defining all windows as open and closing them on the next line of the render loop, in it's first iteration. (Or defining the windows before the main loop) This workaround works great, but is kinda annoying.
```
if(first_loop){
nk_window_show(ctx, "2nd Window", NK_HIDDEN);
nk_window_show(ctx, "3rd Window", NK_HIDDEN);
nk_window_set_focus(ctx, "Main Window");
first_loop = false;
}
```
I'll will attempt to fix this and post a PR, but I do wonder if such a basic issue has not been solved by someone else already...
Contributor guide
Research direction
Start at nk_begin() and trace how NK_WINDOW_HIDDEN is handled when a window definition is encountered in the render loop; compare that behavior with nk_window_show() and the documented visibility rule. Done means a window can be created hidden and later shown without being hidden again on subsequent nk_begin() calls, with the documentation matching the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100