scroller working
This commit is contained in:
@@ -235,7 +235,7 @@ fn void ui_set_indented_string(ui_box_t *box, s8_t string) { box->string = s8_pr
|
||||
fn ui_signal_t ui_push_exp(ui_code_loc_t loc, char *str, ...) {
|
||||
S8_FMT(tcx.temp, str, string);
|
||||
ui_box_t *box = ui_build_box_from_string(loc, string, flag2(ui_box_flag_draw_rect, ui_box_flag_draw_text));
|
||||
ui_set_semantic_size(box, ui_percent(100), ui_text());
|
||||
ui_set_semantic_size(box, ui_percent(1), ui_text());
|
||||
|
||||
if (box->created_new) box->expanded = true;
|
||||
|
||||
@@ -275,9 +275,8 @@ fn void ui_end_frame(void) {
|
||||
}
|
||||
}
|
||||
|
||||
fn void ui_draw(void) {
|
||||
fn void ui_layout(void) {
|
||||
rn_font_t *font = &rn_state.main_font;
|
||||
ui_test_iterator();
|
||||
|
||||
// compute standalone sizes: (pixels, text_content)
|
||||
for (ui_preorder_iter_t it = ui_iterate_preorder(ui->root); ui_preorder_iter_is_valid(it); ui_iter_advance_preorder(&it)) {
|
||||
@@ -301,11 +300,11 @@ fn void ui_draw(void) {
|
||||
for (ui_axis2_t axis = 0; axis < ui_axis2_count; axis += 1) {
|
||||
ui_size_t sem = box->semantic_size[axis];
|
||||
if (sem.kind == ui_size_kind_percent_of_parent) {
|
||||
// assert(sem.value >= 0 && sem.value <= 100.0);
|
||||
assert(sem.value >= 0 && sem.value <= 1.0);
|
||||
assert(parent->semantic_size[axis].kind == ui_size_kind_pixels ||
|
||||
parent->semantic_size[axis].kind == ui_size_kind_text_content ||
|
||||
parent->semantic_size[axis].kind == ui_size_kind_percent_of_parent);
|
||||
box->computed_size[axis] = (sem.value / 100.0f) * parent->computed_size[axis];
|
||||
box->computed_size[axis] = (sem.value) * parent->computed_size[axis];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -344,6 +343,10 @@ fn void ui_draw(void) {
|
||||
f32 *iter_pos = &parent->iter_pos[axis];
|
||||
|
||||
*pos = parent_pos + *iter_pos;
|
||||
if (is_flag_set(parent->flags, ui_box_flag_scroll)) {
|
||||
*pos -= parent->view_offset.e[axis];
|
||||
}
|
||||
|
||||
if (parent->grow_axis == axis) *iter_pos += size;
|
||||
}
|
||||
|
||||
@@ -351,6 +354,12 @@ fn void ui_draw(void) {
|
||||
v2f32_t size = v2f32(box->computed_size[0], box->computed_size[1]);
|
||||
box->rect = r2f32_mindim(pos, size);
|
||||
}
|
||||
}
|
||||
|
||||
fn void ui_draw(void) {
|
||||
rn_font_t *font = &rn_state.main_font;
|
||||
ui_test_iterator();
|
||||
ui_layout();
|
||||
|
||||
// actually draw
|
||||
for (ui_preorder_iter_t it = ui_iterate_preorder(ui->root); ui_preorder_iter_is_valid(it); ui_iter_advance_preorder(&it)) {
|
||||
|
||||
Reference in New Issue
Block a user