fix keyboard nav tree traversal
This commit is contained in:
71
src/ui/ui.c
71
src/ui/ui.c
@@ -616,7 +616,6 @@ fn ui_box_t *ui__label(ui_code_loc_t loc, char *str, ...) {
|
|||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ui_tree_table() defer_block(ui_tree_table_begin(UILOC), ui_tree_table_end())
|
|
||||||
fn void ui_tree_table_begin(ui_code_loc_t loc) {
|
fn void ui_tree_table_begin(ui_code_loc_t loc) {
|
||||||
ui_box_t *box = ui_box(.loc = loc, .rect = ui_next_rect(ui_top_lop(), ui_top_rectp(), v2f32_null), .flags = { .draw_border = true, .children_sum_y = true });
|
ui_box_t *box = ui_box(.loc = loc, .rect = ui_next_rect(ui_top_lop(), ui_top_rectp(), v2f32_null), .flags = { .draw_border = true, .children_sum_y = true });
|
||||||
ui_push_top(box);
|
ui_push_top(box);
|
||||||
@@ -655,40 +654,54 @@ fn ui_signal_t ui_tree_table_push_expandable(ui_code_loc_t loc, char *str, ...)
|
|||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ui_box_t *ui_get_prev_box(ui_box_t *box, b32 (*match)(ui_box_t *)) {
|
fn ui_box_t *ui_get_next_box_ex(ui_box_t *box) {
|
||||||
for (ui_box_t *it = box; it;) {
|
if (box->first) {
|
||||||
if (it->last) {
|
return box->first;
|
||||||
it = it->last;
|
|
||||||
if (match(it)) return it;
|
|
||||||
else continue;
|
|
||||||
}
|
|
||||||
if (it->prev) {
|
|
||||||
it = it->prev;
|
|
||||||
if (match(it)) return it;
|
|
||||||
else continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
it = it->parent;
|
|
||||||
if (it) it = it->prev;
|
|
||||||
}
|
}
|
||||||
return box;
|
|
||||||
|
if (box->next) {
|
||||||
|
return box->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ui_box_t *it = box->parent; it; it = it->parent) {
|
||||||
|
if (it->next != NULL) {
|
||||||
|
return it->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ui_box_t *ui_get_prev_box_ex(ui_box_t *box) {
|
||||||
|
if (box->last) {
|
||||||
|
return box->last;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (box->prev) {
|
||||||
|
return box->prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ui_box_t *it = box->parent; it; it = it->parent) {
|
||||||
|
if (it->prev != NULL) {
|
||||||
|
return it->prev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ui_box_t *ui_get_next_box(ui_box_t *box, b32 (*match)(ui_box_t *)) {
|
fn ui_box_t *ui_get_next_box(ui_box_t *box, b32 (*match)(ui_box_t *)) {
|
||||||
for (ui_box_t *it = box; it;) {
|
for (ui_box_t *it = box; it;) {
|
||||||
if (it->first) {
|
it = ui_get_next_box_ex(it);
|
||||||
it = it->first;
|
if (it && match(it)) return it;
|
||||||
if (match(it)) return it;
|
}
|
||||||
else continue;
|
return box;
|
||||||
}
|
}
|
||||||
if (it->next) {
|
|
||||||
it = it->next;
|
|
||||||
if (match(it)) return it;
|
|
||||||
else continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
it = it->parent;
|
fn ui_box_t *ui_get_prev_box(ui_box_t *box, b32 (*match)(ui_box_t *)) {
|
||||||
if (it) it = it->next;
|
for (ui_box_t *it = box; it;) {
|
||||||
|
it = ui_get_prev_box_ex(it);
|
||||||
|
if (it && match(it)) return it;
|
||||||
}
|
}
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user