ui: advanced positioning system (not finished)

This commit is contained in:
2026-03-10 18:51:56 +02:00
parent 575cc4d93a
commit 791c3055ba
13 changed files with 123 additions and 108 deletions
+11 -4
View File
@@ -10,10 +10,17 @@ int32_t rsize_to_value(int32_t size, enum rsize rsize);
void init_widget(widget_t *w, widget_t *w_parent, WINDOW **win, char *title) {
w->id = m_id++;
w->x = 0;
w->y = 0;
w->m_x = 0;
w->m_y = 0;
w->sz.x = 0;
w->sz.y = 0;
w->ps.x = 0;
w->ps.y = 0;
if (w_parent != NULL && w_parent->w_parent != NULL) { /* not root element of the window */
w->m.x = w_parent->m.x;
w->m.y = w_parent->m.y;
} else {
w->m.x = 0;
w->m.y = 0;
}
w->parent_win = win;
w->w_parent = w_parent;
w->callback = NULL;
+13 -5
View File
@@ -77,14 +77,22 @@ enum rsize {
typedef struct widget_t {
int64_t id;
char title[DIALOGUE_TITLE];
int64_t x;
int64_t y;
int64_t m_x;
int64_t m_y;
struct {
int64_t y;
int64_t x;
} cur;
} cur; /* cursor position */
struct {
int64_t y;
int64_t x;
} sz; /* size */
struct {
int64_t y;
int64_t x;
} m; /* margin (relative to the parent) */
struct {
int64_t y;
int64_t x;
} ps; /* position (relative to the window) */
WINDOW *const *parent_win;
struct widget_t *w_parent;
void (*callback)(callback_args_t *args);