Immediate-Mode-UI / Immediate-Mode-UI/Nuklear
Resizing main nuklear window's height depending on inner content size
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.4k
- Forks
- 686
- Avg merge
- 4d 1h
- Merged PRs (30d)
- 3
Description
I am sure this has been asked before, but I can't find anything.
Let's say I have this code:
```c
#define MENU_FLAGS NK_WINDOW_BORDER | NK_WINDOW_TITLE | NK_WINDOW_MOVABLE | NK_WINDOW_NO_SCROLLBAR
#define ITEMS 5
const char* strings[ITEMS];
if (nk_begin(ctx, "Main window", nk_rect(X, Y, W, 45 + ITEMS * 15), MENU_FLAGS)) {
nk_layout_row_dynamic(ctx, 15, 1);
for (int i = 0; i < ITEMS; i++)
nk_label(ctx, strings[i], NK_TEXT_LEFT);
}
nk_end(ctx);
```
In there, I want to display N strings (as labels) inside the window. In this case, I am manually calculating the window height based on the number of items in my array + the base window size (*which I don't know if it's really 45 by the way*).
Is there any way the window can resize itself automatically based on the number of items?
Also, side note: With the code I sent, if I render N items, and then I remove 1 (e.g. render 5 labels and then 4), the window size remains as it was when I rendered 5.
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 the nk_begin, nk_layout_row_dynamic, nk_label, and nk_end calls shown in the issue, then trace how Nuklear determines window dimensions and handles changed content between frames. Done means the window height follows the number of labels without a hard-coded base height and shrinks when an item is removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100