UI: nested groups: fixes first and last IDs in a parent

This commit is contained in:
2026-02-20 16:59:56 +02:00
parent 8c765191fb
commit acd03b2769
4 changed files with 38 additions and 13 deletions
+6 -1
View File
@@ -1,15 +1,20 @@
# TODO: # TODO:
## Current:
- [ ] UI: vertical layout (needs for email in registration)
- [ ] Nested groups
- [ ] Create dynamic map of elements IDs and their pointers
## Features: ## Features:
- [x] Search files - [x] Search files
- [x] Correct spacing in the search bar - [x] Correct spacing in the search bar
- [x] Finish registration - [x] Finish registration
- [ ] UI: vertical layout (needs for email in registration)
- [ ] Get rid of old notification mechanism - [ ] Get rid of old notification mechanism
- [ ] Privilege settings for files - [ ] Privilege settings for files
- [ ] Files removal - [ ] Files removal
- [ ] Encryption - [ ] Encryption
- [ ] UTF-8 support - [ ] UTF-8 support
## Fixes: ## Fixes:
- [ ] Check and fix registration and login - [ ] Check and fix registration and login
- [ ] Hotkeys for buttons - [ ] Hotkeys for buttons
+3 -3
View File
@@ -20,9 +20,9 @@ typedef struct {
enum g_type type; enum g_type type;
} active; } active;
char text[DIALOGUE_TEXT]; char text[DIALOGUE_TEXT];
uint32_t is_initiated : 1; bool is_initiated;
uint32_t needs_update : 1; bool needs_update;
uint32_t needs_destroy : 1; bool needs_destroy;
coordinates_t *p_coordinates; coordinates_t *p_coordinates;
enum d_color_scheme color_scheme; enum d_color_scheme color_scheme;
} dialogue_t; } dialogue_t;
+26 -7
View File
@@ -77,9 +77,17 @@ void group_default_callback(callback_args_t *args) {
} }
} }
union current_element {
group_t *group;
enum w_type type;
};
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));
union current_element current;
group->parent_group = NULL;
current.type = w_end;
init_widget(&(group->w), w_parent, win, ""); init_widget(&(group->w), w_parent, win, "");
/* count elements */ /* count elements */
group->count = 0; group->count = 0;
@@ -111,7 +119,16 @@ group_t *init_group(WINDOW **win, widget_t *w_parent, group_el_init_t *children,
case w_group: case w_group:
elements[i].element = init_group(win, &(group->w), children[i].children, elements[i].element = init_group(win, &(group->w), children[i].children,
children[i].direction); children[i].direction);
w = &(((input_t *)elements[i].element)->w); w = &(((group_t *)elements[i].element)->w);
current.group = (group_t *)elements[i].element;
current.group->parent_group = group;
if (i == 0) {
group->first_id = current.group->first_id;
group->last_id = current.group->last_id;
} else {
group->last_id = current.group->last_id;
}
current.type = w_group;
break; break;
case w_input: case w_input:
elements[i].element = elements[i].element =
@@ -128,6 +145,14 @@ group_t *init_group(WINDOW **win, widget_t *w_parent, group_el_init_t *children,
w = &(((ui_progress_bar_t *)elements[i].element)->w); w = &(((ui_progress_bar_t *)elements[i].element)->w);
break; break;
} }
if (current.type != w_group) {
if (i == 0) {
group->first_id = w->id;
group->last_id = w->id;
} else {
group->last_id = w->id;
}
}
/* set dimensions */ /* set dimensions */
elements[i].id = w->id; elements[i].id = w->id;
if (direction == horizontal) { if (direction == horizontal) {
@@ -143,12 +168,6 @@ group_t *init_group(WINDOW **win, widget_t *w_parent, group_el_init_t *children,
if (group->w.x < w->x) if (group->w.x < w->x)
group->w.x = w->x; group->w.x = w->x;
} }
if (i == 0) {
group->first_id = w->id;
group->last_id = w->id;
} else {
group->last_id = w->id;
}
} }
if (direction == vertical) if (direction == vertical)
+3 -2
View File
@@ -13,7 +13,7 @@ typedef struct {
uint32_t id; uint32_t id;
void *element; void *element;
enum w_type type; enum w_type type;
uint32_t is_default : 1; bool is_default;
} group_el_t; } group_el_t;
typedef struct group_el_init_t { typedef struct group_el_init_t {
@@ -26,12 +26,13 @@ typedef struct group_el_init_t {
struct group_el_init_t *children; struct group_el_init_t *children;
} group_el_init_t; } group_el_init_t;
typedef struct { typedef struct group_t{
widget_t w; widget_t w;
group_el_t *elements; group_el_t *elements;
enum g_direction direction; enum g_direction direction;
uint32_t count; uint32_t count;
uint32_t first_id, last_id; uint32_t first_id, last_id;
struct group_t *parent_group;
} group_t; } group_t;
#define FIND_ACTIVE_ELEMENT(g, active_id, element_ptr, element_idx) \ #define FIND_ACTIVE_ELEMENT(g, active_id, element_ptr, element_idx) \