|
|
@@ -23805,16 +23805,15 @@ nk_widget_text(struct nk_command_buffer *o, struct nk_rect b,
|
|
|
if (!o || !t) return;
|
|
|
|
|
|
b.h = NK_MAX(b.h, 2 * t->padding.y);
|
|
|
- label.x = 0; label.w = 0;
|
|
|
- label.y = b.y + t->padding.y;
|
|
|
- label.h = NK_MIN(f->height, b.h - 2 * t->padding.y);
|
|
|
|
|
|
text_width = f->width(f->userdata, f->height, (const char*)string, len);
|
|
|
text_width += (2.0f * t->padding.x);
|
|
|
|
|
|
- /* align to left in x-axis by default */
|
|
|
+ /* use top-left alignment by default */
|
|
|
if (!(a & (NK_TEXT_ALIGN_LEFT | NK_TEXT_ALIGN_CENTERED | NK_TEXT_ALIGN_RIGHT)))
|
|
|
a |= NK_TEXT_ALIGN_LEFT;
|
|
|
+ if (!(a & (NK_TEXT_ALIGN_TOP | NK_TEXT_ALIGN_MIDDLE | NK_TEXT_ALIGN_BOTTOM)))
|
|
|
+ a |= NK_TEXT_ALIGN_TOP;
|
|
|
|
|
|
/* align in x-axis */
|
|
|
if (a & NK_TEXT_ALIGN_LEFT) {
|
|
|
@@ -23832,13 +23831,17 @@ nk_widget_text(struct nk_command_buffer *o, struct nk_rect b,
|
|
|
}
|
|
|
|
|
|
/* align in y-axis */
|
|
|
- if (a & NK_TEXT_ALIGN_MIDDLE) {
|
|
|
+ if (a & NK_TEXT_ALIGN_TOP) {
|
|
|
+ label.y = b.y + t->padding.y;
|
|
|
+ label.h = NK_MIN(f->height, b.h - 2 * t->padding.y);
|
|
|
+ } else if (a & NK_TEXT_ALIGN_MIDDLE) {
|
|
|
label.y = b.y + b.h/2.0f - (float)f->height/2.0f;
|
|
|
label.h = NK_MAX(b.h/2.0f, b.h - (b.h/2.0f + f->height/2.0f));
|
|
|
} else if (a & NK_TEXT_ALIGN_BOTTOM) {
|
|
|
label.y = b.y + b.h - f->height;
|
|
|
label.h = f->height;
|
|
|
}
|
|
|
+
|
|
|
nk_draw_text(o, label, (const char*)string, len, f, t->background, t->text);
|
|
|
}
|
|
|
NK_LIB void
|
|
|
@@ -30721,7 +30724,8 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
|
|
|
/// - [z]: Patch version with no direct changes to the API
|
|
|
///
|
|
|
/// - 2025/10/08 (4.12.8) - Fix nk_widget_text to use NK_TEXT_ALIGN_LEFT by default,
|
|
|
-/// instead of silently failing when no x-axis alignment is provided
|
|
|
+/// instead of silently failing when no x-axis alignment is provided,
|
|
|
+/// and refactor this function to keep the code style consistent
|
|
|
/// - 2025/04/06 (4.12.7) - Fix text input navigation and mouse scrolling
|
|
|
/// - 2025/03/29 (4.12.6) - Fix unitialized data in nk_input_char
|
|
|
/// - 2025/03/05 (4.12.5) - Fix scrolling knob also scrolling parent window, remove dead code
|