clipping to intersect of parent and box
This commit is contained in:
@@ -40,8 +40,6 @@ fn b32 app_update(app_frame_t *frame) {
|
||||
assert(frame != NULL);
|
||||
ui_begin_frame(frame);
|
||||
|
||||
v2f32_t size = rn_measure_string(&rn_state.main_font, s8_lit("a"));
|
||||
unused(size);
|
||||
assert(frame->first_event);
|
||||
|
||||
for (app_event_t *ev = frame->first_event; ev; ev = ev->next) {
|
||||
@@ -127,7 +125,6 @@ fn b32 app_update(app_frame_t *frame) {
|
||||
|
||||
// scroller
|
||||
{
|
||||
|
||||
f32 all_items_size = (f32)item_box->node_count * get_font_size();
|
||||
f32 item_box_size = r2f32_get_size(item_box->rect).y;
|
||||
|
||||
|
||||
@@ -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, flag2(ui_box_flag_draw_rect, ui_box_flag_draw_text), string);
|
||||
ui_box_t *box = ui_build_box_from_string(loc, flag1(ui_box_flag_draw_text), string);
|
||||
ui_set_semantic_size(box, ui_percent(1), ui_text());
|
||||
|
||||
if (box->created_new) box->expanded = true;
|
||||
@@ -262,7 +262,7 @@ fn void ui_pop_exp(void) {
|
||||
|
||||
fn ui_box_t *ui_label(ui_code_loc_t loc, char *fmt, ...) {
|
||||
S8_FMT(tcx.temp, fmt, string);
|
||||
ui_box_t *box = ui_build_box_from_id(loc, flag2(ui_box_flag_draw_rect, ui_box_flag_draw_text), ui_null_id);
|
||||
ui_box_t *box = ui_build_box_from_id(loc, flag1(ui_box_flag_draw_text), ui_null_id);
|
||||
ui_set_indented_string(box, string);
|
||||
ui_set_semantic_size(box, ui_text(), ui_text());
|
||||
return box;
|
||||
@@ -364,16 +364,23 @@ fn void ui_draw(void) {
|
||||
// actually draw
|
||||
for (ui_preorder_iter_t it = ui_iterate_preorder(ui->root); ui_preorder_iter_is_valid(it); ui_iter_advance_preorder(&it)) {
|
||||
ui_box_t *box = it.box;
|
||||
r2f32_t clip_rect = box->rect;
|
||||
if (box->parent) {
|
||||
clip_rect = r2f32_intersect(clip_rect, box->parent->rect);
|
||||
}
|
||||
|
||||
v4f32_t rect_color = primary_color_global;
|
||||
v4f32_t text_color = black_color_global;
|
||||
if (ui_is_hot_box(box)) {
|
||||
rect_color = secondary_color_global;
|
||||
text_color = accent2_color_global;
|
||||
}
|
||||
if (ui_is_active_box(box)) {
|
||||
rect_color = accent1_color_global;
|
||||
text_color = accent1_color_global;
|
||||
}
|
||||
|
||||
// rn_set_clip(box->parent->rect);
|
||||
rn_set_clip(clip_rect);
|
||||
if (is_flag_set(box->flags, ui_box_flag_draw_rect)) {
|
||||
rn_draw_rect(box->rect, rect_color);
|
||||
}
|
||||
@@ -381,7 +388,7 @@ fn void ui_draw(void) {
|
||||
rn_draw_rect_border(box->rect, accent2_color_global);
|
||||
}
|
||||
if (is_flag_set(box->flags, ui_box_flag_draw_text)) {
|
||||
rn_draw_string(font, box->rect.min, black_color_global, box->string);
|
||||
rn_draw_string(font, box->rect.min, text_color, box->string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user