Immediate-Mode-UI / Immediate-Mode-UI/Nuklear
nk_spacer for empty space in layout
- Dominant language
- C
- Stars
- 11.4k
- Forks
- 686
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 3
Description
I added a `nk_spacer(ctx)` function in my local fork, which just allocates panel space without adding any widget. This is pretty useful to me, for example: to make a button with some space around it instead of a ginormous button that takes a whole row you can do
```
nk_layout_row_dynamic( ctx, 50, 3 );
nk_spacer();
nk_button_label("Okay"); // Button takes the middle 3rd of the row
```
more importantly you can add empty space to a panel where there are widgets that sometimes appear and sometimes don't so the layout stays consistent. All it does is this:
```
NK_API void
nk_spacer( const struct nk_context *ctx )
{
struct nk_rect dummy_rect = {};
nk_panel_alloc_space( &dummy_rect, ctx );
}
```
Is there an existing way to do this that I'm missing? If not, should I make a pull request for this?
Thx!
Contributor guide
Research direction
Start by inspecting the existing layout APIs and the nk_panel_alloc_space entry point in Nuklear's single-header implementation. Check whether an API already reserves an empty panel slot; if not, verify the proposed spacer behavior with the button and conditional-widget layout examples described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100