-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Layouting using groups #906
Comments
I can't think of any such option - that's why it's called complex and why you have to do everything manually 😢. Feel free though to look e.g. at a separate layouting library from the original author of Nuklear to maybe get some inspiration on how to do it yourself in a manageable way (the linked library is about 2 years newer design than Nuklear). |
Hmm. So there is really no way to remove the inner padding of group 2 to get the desired effect then. I guess I'll play around with |
I don't know off the top of my head, I would need to dive into the code, it's been already few years since the layouting was added 😉. Feel free to take a look, it's not that complicated, but I'm still too constrained to look into it myself 😢. |
Playing with it a little more, I actually managed to get the desired result: nk_layout_row_dynamic(ctx, 50, 2);
if (nk_group_begin(ctx, "1", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
nk_group_end(ctx);
}
struct nk_style_window old = ctx->style.window;
ctx->style.window.group_padding = nk_vec2(0, 0);
if (nk_group_begin(ctx, "2", NK_WINDOW_NO_SCROLLBAR)) {
nk_layout_row_dynamic(ctx, 23, 1);
if (nk_group_begin(ctx, "3", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
nk_group_end(ctx);
}
if (nk_group_begin(ctx, "4", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
nk_group_end(ctx);
}
nk_group_end(ctx);
}
ctx->style.window = old; Ofc, this also removes group 3 and 4's padding. nk_layout_row_dynamic(ctx, 100, 2);
if (nk_group_begin(ctx, "1", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
nk_layout_row_dynamic(ctx, 0, 1);
nk_label(ctx, "test", NK_TEXT_LEFT);
nk_group_end(ctx);
}
struct nk_style_window old = ctx->style.window;
ctx->style.window.group_padding = nk_vec2(0, 0);
if (nk_group_begin(ctx, "2", NK_WINDOW_NO_SCROLLBAR)) {
nk_layout_row_dynamic(ctx, 48, 1);
if (nk_group_begin(ctx, "3", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
nk_layout_row_dynamic(ctx, 0, 1);
nk_label(ctx, "test", NK_TEXT_LEFT);
nk_group_end(ctx);
}
if (nk_group_begin(ctx, "4", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
nk_layout_row_dynamic(ctx, 0, 1);
nk_label(ctx, "test", NK_TEXT_LEFT);
nk_group_end(ctx);
}
nk_group_end(ctx);
}
ctx->style.window = old; |
I'll try playing a little more. I can probably restore the padding again. |
Hmm. Restoring the padding inside 3 and 4 doesn't work as I thought it would. nk_layout_row_dynamic(ctx, 100, 2);
if (nk_group_begin(ctx, "1", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
nk_layout_row_dynamic(ctx, 0, 1);
nk_label(ctx, "test", NK_TEXT_LEFT);
nk_group_end(ctx);
}
struct nk_style_window old = ctx->style.window;
ctx->style.window.group_padding = nk_vec2(0, 0);
if (nk_group_begin(ctx, "2", NK_WINDOW_NO_SCROLLBAR)) {
ctx->style.window = old;
nk_layout_row_dynamic(ctx, 48, 1);
ctx->style.window.group_padding = nk_vec2(0, 0);
if (nk_group_begin(ctx, "3", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
ctx->style.window = old;
nk_layout_row_dynamic(ctx, 0, 1);
nk_label(ctx, "test", NK_TEXT_LEFT);
ctx->style.window.group_padding = nk_vec2(0, 0);
nk_group_end(ctx);
}
if (nk_group_begin(ctx, "4", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
ctx->style.window = old;
nk_layout_row_dynamic(ctx, 0, 1);
nk_label(ctx, "test", NK_TEXT_LEFT);
ctx->style.window.group_padding = nk_vec2(0, 0);
nk_group_end(ctx);
}
nk_group_end(ctx);
}
ctx->style.window = old; It seems I don't understand padding.
|
Ooh. A simpler, near perfect solution nk_layout_row_dynamic(ctx, 50, 2);
if (nk_group_begin(ctx, "1", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
nk_group_end(ctx);
}
struct nk_style_window old = ctx->style.window;
ctx->style.window.group_padding = nk_vec2(0, 0);
int is_showing = nk_group_begin(ctx, "2", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR);
ctx->style.window = old;
if (is_showing) {
nk_layout_row_dynamic(ctx, 22, 1);
if (nk_group_begin(ctx, "3", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
nk_group_end(ctx);
}
if (nk_group_begin(ctx, "4", NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR)) {
nk_group_end(ctx);
}
ctx->style.window.group_padding = nk_vec2(0, 0);
nk_group_end(ctx);
ctx->style.window = old;
} Now I only need to figure out how to get rid of those small gaps to the left and right of 3 and 4. |
I will have a look tonight 😉. |
Hey @Hejsil can you send me a snippet of your last template that reproduce the issue. Is this only occuring wtih specific |
@Hejsil If you have any information, let me know. It would be cool to fix window problems/internal drawing first, then investigate on elements implementation (such as layouts). |
@eax0r If the problems pointed out in my last comment are fixed, then I don't need any new layouts to be implemented, as I can use what is currently in nuklear to do the layouting the way I want. I haven't looked into the window padding problem yet, so I don't know what would cause that. |
So, I want to layout my widgets like this:
I see in
overview.c
that there is aComplex
section that lays out widgets in a similar way usingnk_layout_space_xxx
. Butnk_layout_space_xxx
requires that I do the entire structure and style myself.So my thought was to just use groups to achieve this.
I get this.
This seems to be what I want, I just need to remove group 2's border and inner padding and I would get what I want.
Here is my first attempt
Hmm. The top padding is gone, but the spacing between 1 and 2 is now gone to.
I'll try removing the padding from within the group instead.
This removes some of the left and right padding, but still not what I'm looking for.
Is there a way to get the desired outcome without over complicating my UI with
nk_layout_space_xxx
?The text was updated successfully, but these errors were encountered: