Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

center window title at the middle #565

Closed
azc5OQ opened this issue Jul 13, 2023 · 2 comments
Closed

center window title at the middle #565

azc5OQ opened this issue Jul 13, 2023 · 2 comments

Comments

@azc5OQ
Copy link

azc5OQ commented Jul 13, 2023

I want to align window title to the center of the window bar, window title is rendered on the left side by default
Can somebody please point me to the right location?

with this code

if (nk_begin(ctx_nuklear, "menu", nk_rect(menu__position_x, menu__position_y, 750, 400), NK_WINDOW_MOVABLE | NK_WINDOW_BORDER))

Is there some way to add NK_TEXT_CENTERED to it?

thank you

@dosshell
Copy link

I changed the defaults to center the title with the following patch to master:

@@ -19727,9 +19727,8 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
         label.x += style->window.header.label_padding.x;
         label.y = header.y + style->window.header.label_padding.y;
         label.h = font->height + 2 * style->window.header.label_padding.y;
-        label.w = t + 2 * style->window.header.spacing.x;
-        label.w = NK_CLAMP(0, label.w, header.x + header.w - label.x);
-        nk_widget_text(out, label, (const char*)title, text_len, &text, NK_TEXT_LEFT, font);}
+        label.w = header.w - 2 * (style->window.header.padding.x + style->window.header.label_padding.x);
+        nk_widget_text(out, label, (const char*)title, text_len, &text, NK_TEXT_CENTERED, font);}
     }

The text widget should also have the correct size after this (the clamp max value was a missing the padding), right alignment should also work now.

@azc5OQ
Copy link
Author

azc5OQ commented Sep 3, 2023

worked, thank you

@azc5OQ azc5OQ closed this as completed Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants