ui: advanced positioning system (not finished)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user