From ba33bab4d1f77f81202da1149932c382e3f69ee3 Mon Sep 17 00:00:00 2001 From: Alexander Zhylin Date: Tue, 16 Dec 2025 13:48:41 +0200 Subject: [PATCH] ui: dialogue: fixes positioning --- src/ui/modals/login_credentials.c | 10 +++++----- src/ui/modals/login_option.c | 3 ++- src/ui/widget/dialogue.c | 4 ++-- src/ui/widget/group.c | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/ui/modals/login_credentials.c b/src/ui/modals/login_credentials.c index bb343be..bf06d85 100644 --- a/src/ui/modals/login_credentials.c +++ b/src/ui/modals/login_credentials.c @@ -1,7 +1,7 @@ +#include #include #include #include -#include #include "../app.h" #include "../widget/dialogue.h" @@ -41,8 +41,8 @@ dialogue_t *init_login_credentials_modal(app_t *app) { if (app == NULL) return NULL; group_el_init_t content[] = { - {.type = w_input, .label = "Username", .length = 10}, - {.type = w_input, .label = "Password", .length = 10}, + {.type = w_input, .label = "Username", .length = 15}, + {.type = w_input, .label = "Password", .length = 15}, {.type = w_end}}; group_el_init_t actions[] = { @@ -50,8 +50,8 @@ dialogue_t *init_login_credentials_modal(app_t *app) { {.type = w_button, .label = "Cancel", .is_default = 0}, {.type = w_end}}; - init_dialogue(&(app->modal), "Credentials", - "There is information needed", &(app->coordinates)); + init_dialogue(&(app->modal), "Credentials", "There is information needed", + &(app->coordinates)); dialogue_t *d = &(app->modal); d->w.callback = init_login_credentials_modal_cb; diff --git a/src/ui/modals/login_option.c b/src/ui/modals/login_option.c index 17088dc..6f33a00 100644 --- a/src/ui/modals/login_option.c +++ b/src/ui/modals/login_option.c @@ -44,10 +44,11 @@ dialogue_t *init_login_option_modal(app_t *app) { "Select your login " "option", &(app->coordinates)); - app->modal.g_content = + app->modal.g_action = init_group(&(app->modal.win), &(app->modal.w), children, horizontal); app->modal.w.callback = login_modal_option_cb; + dialogue_init_active_id(&(app->modal)); return NULL; } \ No newline at end of file diff --git a/src/ui/widget/dialogue.c b/src/ui/widget/dialogue.c index 211efde..3f54427 100644 --- a/src/ui/widget/dialogue.c +++ b/src/ui/widget/dialogue.c @@ -155,9 +155,9 @@ void dialogue_init_active_id(dialogue_t *dialogue) { group->w.m_y = y; \ if (line_max_len < group->w.x) { \ line_max_len = group->w.x; \ - group->w.m_x = 1; /* when uses box */ \ + group->w.m_x = 0; /* when uses box */ \ } else { \ - /* TODO: centering */ \ + group->w.m_x = (line_max_len - group->w.x) / 2; \ } \ y += group->w.y; \ } diff --git a/src/ui/widget/group.c b/src/ui/widget/group.c index ad4bb16..076c891 100644 --- a/src/ui/widget/group.c +++ b/src/ui/widget/group.c @@ -53,7 +53,7 @@ void group_default_callback(callback_args_t *args) { group_t *init_group(WINDOW **win, widget_t *w_parent, group_el_init_t *children, enum g_direction direction) { group_t *group = malloc(sizeof(group_t)); - + init_widget(&(group->w), w_parent, win, ""); /* count elements */ group->count = 0; for (; children[group->count].type != w_end; group->count++) @@ -91,7 +91,7 @@ group_t *init_group(WINDOW **win, widget_t *w_parent, group_el_init_t *children, // set dimensions elements[i].id = w->id; if (direction == horizontal) { - w->m_x = group->w.x + 1; + w->m_x = group->w.m_x + 1 + group->w.x; w->m_y = group->w.m_y; group->w.x += w->x + 1; if (group->w.y < w->y)