ui: dialogue: fixes positioning
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
|
#include <ncurses.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ncurses.h>
|
|
||||||
|
|
||||||
#include "../app.h"
|
#include "../app.h"
|
||||||
#include "../widget/dialogue.h"
|
#include "../widget/dialogue.h"
|
||||||
@@ -41,8 +41,8 @@ dialogue_t *init_login_credentials_modal(app_t *app) {
|
|||||||
if (app == NULL)
|
if (app == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
group_el_init_t content[] = {
|
group_el_init_t content[] = {
|
||||||
{.type = w_input, .label = "Username", .length = 10},
|
{.type = w_input, .label = "Username", .length = 15},
|
||||||
{.type = w_input, .label = "Password", .length = 10},
|
{.type = w_input, .label = "Password", .length = 15},
|
||||||
{.type = w_end}};
|
{.type = w_end}};
|
||||||
|
|
||||||
group_el_init_t actions[] = {
|
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_button, .label = "Cancel", .is_default = 0},
|
||||||
{.type = w_end}};
|
{.type = w_end}};
|
||||||
|
|
||||||
init_dialogue(&(app->modal), "Credentials",
|
init_dialogue(&(app->modal), "Credentials", "There is information needed",
|
||||||
"There is information needed", &(app->coordinates));
|
&(app->coordinates));
|
||||||
dialogue_t *d = &(app->modal);
|
dialogue_t *d = &(app->modal);
|
||||||
|
|
||||||
d->w.callback = init_login_credentials_modal_cb;
|
d->w.callback = init_login_credentials_modal_cb;
|
||||||
|
|||||||
@@ -44,10 +44,11 @@ dialogue_t *init_login_option_modal(app_t *app) {
|
|||||||
"Select your login "
|
"Select your login "
|
||||||
"option",
|
"option",
|
||||||
&(app->coordinates));
|
&(app->coordinates));
|
||||||
app->modal.g_content =
|
app->modal.g_action =
|
||||||
init_group(&(app->modal.win), &(app->modal.w), children,
|
init_group(&(app->modal.win), &(app->modal.w), children,
|
||||||
horizontal);
|
horizontal);
|
||||||
app->modal.w.callback = login_modal_option_cb;
|
app->modal.w.callback = login_modal_option_cb;
|
||||||
|
dialogue_init_active_id(&(app->modal));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -155,9 +155,9 @@ void dialogue_init_active_id(dialogue_t *dialogue) {
|
|||||||
group->w.m_y = y; \
|
group->w.m_y = y; \
|
||||||
if (line_max_len < group->w.x) { \
|
if (line_max_len < group->w.x) { \
|
||||||
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 { \
|
} else { \
|
||||||
/* TODO: centering */ \
|
group->w.m_x = (line_max_len - group->w.x) / 2; \
|
||||||
} \
|
} \
|
||||||
y += group->w.y; \
|
y += group->w.y; \
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
group_t *init_group(WINDOW **win, widget_t *w_parent, group_el_init_t *children,
|
||||||
enum g_direction direction) {
|
enum g_direction direction) {
|
||||||
group_t *group = malloc(sizeof(group_t));
|
group_t *group = malloc(sizeof(group_t));
|
||||||
|
init_widget(&(group->w), w_parent, win, "");
|
||||||
/* count elements */
|
/* count elements */
|
||||||
group->count = 0;
|
group->count = 0;
|
||||||
for (; children[group->count].type != w_end; group->count++)
|
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
|
// set dimensions
|
||||||
elements[i].id = w->id;
|
elements[i].id = w->id;
|
||||||
if (direction == horizontal) {
|
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;
|
w->m_y = group->w.m_y;
|
||||||
group->w.x += w->x + 1;
|
group->w.x += w->x + 1;
|
||||||
if (group->w.y < w->y)
|
if (group->w.y < w->y)
|
||||||
|
|||||||
Reference in New Issue
Block a user