ui: finishes nested groups; +email field in registration modal
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
|
||||
typedef enum {
|
||||
modal_color_pair = 3,
|
||||
modal_border_color_pair = 4,
|
||||
} color;
|
||||
|
||||
typedef enum {
|
||||
|
||||
+23
-18
@@ -95,7 +95,8 @@ void dialogue_default_callback(callback_args_t *args) {
|
||||
if (d->active_el->g_type == g_action) {
|
||||
new_args.element = d->g_action;
|
||||
group_default_callback(&new_args);
|
||||
mempcpy(&(args->resp_data), &(new_args.resp_data), sizeof(new_args.resp_data));
|
||||
mempcpy(&(args->resp_data), &(new_args.resp_data),
|
||||
sizeof(new_args.resp_data));
|
||||
} else if (d->g_action != NULL) {
|
||||
for (int i = 0; i < d->g_action->count; i++) {
|
||||
if (d->g_action->elements[i].is_default) {
|
||||
@@ -105,7 +106,6 @@ void dialogue_default_callback(callback_args_t *args) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* TODO: temp solution, improve */
|
||||
args->resp_data.code = cbrp_val;
|
||||
args->resp_data.val.val.num = d->active_el->idx;
|
||||
return;
|
||||
@@ -160,27 +160,32 @@ void init_dialogue(dialogue_t *dialogue, const char title[], const char text[],
|
||||
dialogue->text[t_size - 1] = '\0';
|
||||
}
|
||||
|
||||
void dialogue_init_active_id(dialogue_t *dialogue) {
|
||||
enum w_type widget_type;
|
||||
int group_init_active_id(group_t *g, dialogue_t *d) {
|
||||
enum w_type wt;
|
||||
|
||||
for (int i = 0; i < g->count; i++) {
|
||||
wt = g->elements[i].type;
|
||||
if (wt == w_button || wt == w_input ||
|
||||
wt == w_fs_file_list) { /* Add here new types */
|
||||
d->active_el = g->elements + i;
|
||||
return 1;
|
||||
} else if (wt == w_group) {
|
||||
group_t *child_g = g->elements[i].element;
|
||||
return group_init_active_id(child_g, d);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dialogue_init_active_id(dialogue_t *dialogue) {
|
||||
if (dialogue->g_content != NULL) {
|
||||
for (int i = 0; i < dialogue->g_content->count; i++) {
|
||||
widget_type = dialogue->g_content->elements[i].type;
|
||||
if (widget_type == w_button || widget_type == w_input ||
|
||||
widget_type == w_fs_file_list) { /* Add here new types */
|
||||
dialogue->active_el = dialogue->g_content->elements + i;
|
||||
return;
|
||||
}
|
||||
if (group_init_active_id(dialogue->g_content, dialogue)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (dialogue->g_action != NULL) {
|
||||
for (int i = 0; i < dialogue->g_action->count; i++) {
|
||||
widget_type = dialogue->g_action->elements[i].type;
|
||||
if (widget_type == w_button || widget_type == w_input ||
|
||||
widget_type == w_fs_file_list) {
|
||||
dialogue->active_el = dialogue->g_action->elements + i;
|
||||
return;
|
||||
}
|
||||
if (group_init_active_id(dialogue->g_action, dialogue)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-6
@@ -31,7 +31,7 @@ int32_t draw_input(input_t *input, uint32_t active_id) {
|
||||
WINDOW *win = *(input->w.parent_win);
|
||||
uint32_t margin_y = input->w.m_y;
|
||||
uint32_t margin_x = input->w.m_x;
|
||||
|
||||
|
||||
/* counts margins of the ancestors of the same window */
|
||||
widget_t *w_par = input->w.w_parent;
|
||||
while (w_par->parent_win == input->w.parent_win) {
|
||||
@@ -40,13 +40,15 @@ int32_t draw_input(input_t *input, uint32_t active_id) {
|
||||
w_par = w_par->w_parent;
|
||||
}
|
||||
|
||||
wattrset(win, COLOR_PAIR(modal_color_pair));
|
||||
if (input->w.id == active_id) {
|
||||
wattrset(win, COLOR_PAIR(3));
|
||||
} else {
|
||||
wattrset(win, COLOR_PAIR(0) | A_REVERSE | A_BOLD);
|
||||
}
|
||||
|
||||
mvwhline(win, margin_y, margin_x, 0, input->w.x);
|
||||
mvwhline(win, margin_y + 2, margin_x, 0, input->w.x);
|
||||
|
||||
mvwprintw(win, margin_y, margin_x + 1, " %s ", input->w.title);
|
||||
|
||||
// left
|
||||
mvwvline(win, margin_y, margin_x, ACS_ULCORNER, 1);
|
||||
mvwvline(win, margin_y + 1, margin_x, 0, 1);
|
||||
@@ -56,6 +58,9 @@ int32_t draw_input(input_t *input, uint32_t active_id) {
|
||||
mvwvline(win, margin_y + 1, margin_x + input->w.x - 1, 0, 1);
|
||||
mvwvline(win, margin_y + 2, margin_x + input->w.x - 1, ACS_LRCORNER, 1);
|
||||
|
||||
wattrset(win, COLOR_PAIR(0) | A_REVERSE);
|
||||
mvwprintw(win, margin_y, margin_x + 1, " %s ", input->w.title);
|
||||
|
||||
margin_x++;
|
||||
|
||||
if (input->w.id == active_id) {
|
||||
@@ -66,10 +71,10 @@ int32_t draw_input(input_t *input, uint32_t active_id) {
|
||||
|
||||
if (input->is_hidden) {
|
||||
mvwprintw(win, margin_y + 1, margin_x, "%.*s%*s", (int)input->value_len,
|
||||
stars, input->w.x - input->value_len - 2, "");
|
||||
stars, (int)(input->w.x - input->value_len - 2), "");
|
||||
} else {
|
||||
mvwprintw(win, margin_y + 1, margin_x, "%s%*s", input->value,
|
||||
input->w.x - input->value_len - 2, "");
|
||||
(int)(input->w.x - input->value_len - 2), "");
|
||||
}
|
||||
|
||||
input->w.cur.y = margin_y + 1;
|
||||
|
||||
Reference in New Issue
Block a user