buffer16 api work

This commit is contained in:
Krzosa Karol
2025-04-10 22:07:14 +02:00
parent 13295a2fcd
commit c8a4d19a72
13 changed files with 342 additions and 240 deletions

View File

@@ -367,7 +367,7 @@ fn ui_signal_t ui_signal_from_box(ui_box_t *box) {
}
fn v2f32_t ui_aligned_text_pos(f32 offset, ui_text_align_t text_align, r2f32_t rect, s8_t string, v2f32_t string_size) {
v2f32_t rect_size = r2f32_get_size(rect);
v2f32_t rect_size = r2f32_size(rect);
v2f32_t rect_string_diff = v2f32_sub(rect_size, string_size);
v2f32_t center_pos = v2f32_divs(rect_string_diff, 2);
v2f32_t pos_in_rect = v2f32(0, center_pos.y);
@@ -390,7 +390,7 @@ struct ui_draw_compute_t {
fn r2f32_t ui_get_appear_rect(ui_box_t *box) {
r2f32_t result = box->rect;
if (box->flags.animate_appear && !ui_id_is_null(box->id)) {
v2f32_t size = v2f32_muls(r2f32_get_size(result), 0.15f);
v2f32_t size = v2f32_muls(r2f32_size(result), 0.15f);
r2f32_t smaller_rect = r2f32_shrink(result, size);
f32 appear_t = f32_ease_out_n(f32_clamp01(box->appear_t * 2), 10);
result = r2f32_lerp(smaller_rect, result, appear_t);
@@ -634,7 +634,7 @@ fn void ui_tree_table_begin(ui_code_loc_t loc) {
fn void ui_tree_table_end(void) {
ui_box_t *box = ui_pop_top();
ui_set_children_sums(box);
ui_next_rect(ui_top_lop(), ui_top_rectp(), r2f32_get_size(box->rect));
ui_next_rect(ui_top_lop(), ui_top_rectp(), r2f32_size(box->rect));
}
#define ui_tree_table_expandable(...) defer_if (ui_tree_table_push_expandable(UILOC, __VA_ARGS__).clicked, ui_tree_table_pop_expandable())
@@ -998,7 +998,7 @@ struct ui_scroller_t {
fn void ui_scroller_calc_vertical(ui_scroller_t s) {
ui_set_top(s.verti.box) {
f32 scroller_rect_pixels = r2f32_get_size(s.verti.box->rect).y;
f32 scroller_rect_pixels = r2f32_size(s.verti.box->rect).y;
f32 all_items_size = s.p.verti.max_size;
f32 scroller_size = f32_clamp01(s.verti.item_box_pixels / (all_items_size + s.verti.item_box_pixels));
f32 scrollable_space = (1 - scroller_size);
@@ -1023,7 +1023,7 @@ fn void ui_scroller_calc_vertical(ui_scroller_t s) {
}
if (upper_box_signal.dragging || down_box_signal.dragging) {
s.p.verti.value[0] = (ev->mouse_pos.y - upper_box->rect.min.y) * coef;
s.p.verti.value[0] -= (r2f32_get_size(slider_box->rect).y / 2) * coef;
s.p.verti.value[0] -= (r2f32_size(slider_box->rect).y / 2) * coef;
}
if (ev->kind == app_event_kind_mouse_wheel) {
s.p.verti.value[0] -= ev->mouse_wheel_delta.y;
@@ -1038,7 +1038,7 @@ fn ui_scroller_t ui_begin_scroller(ui_code_loc_t loc, ui_scroller_params_t p) {
if (p.verti.enabled) {
s.verti.box = ui_box(.loc = loc, .rect = r2f32_cut_right(&p.parent->rect, ui_dm(0.5f)), .flags = {.draw_rect = true});
r2f32_cut_bottom(&s.verti.box->rect, ui_dm(0.5f));
s.verti.item_box_pixels = r2f32_get_size(p.parent->rect).y;
s.verti.item_box_pixels = r2f32_size(p.parent->rect).y;
if (p.verti.item_count) {
s.p.verti.max_size = s.p.verti.item_pixels * s.p.verti.item_count;
ui_scroller_calc_vertical(s);
@@ -1077,7 +1077,7 @@ fn void ui_end_scroller(ui_scroller_t s) {
if (s.p.hori.enabled) {
ui_set_top(s.hori.box) {
f32 scroller_rect_pixels = r2f32_get_size(s.hori.box->rect).x;
f32 scroller_rect_pixels = r2f32_size(s.hori.box->rect).x;
f32 scroller_button_size_norm = f32_clamp01(scroller_rect_pixels / s.p.hori.max_size);
f32 scrollable_space = (1.f - scroller_button_size_norm);
@@ -1101,7 +1101,7 @@ fn void ui_end_scroller(ui_scroller_t s) {
}
if (left_box_sig.dragging || right_box_sig.dragging) {
s.p.hori.value[0] = (ev->mouse_pos.x - left_box->rect.min.x) * coef;
s.p.hori.value[0] -= (r2f32_get_size(slider_box->rect).x / 2) * coef;
s.p.hori.value[0] -= (r2f32_size(slider_box->rect).x / 2) * coef;
}
if (ev->kind == app_event_kind_mouse_wheel) {
s.p.hori.value[0] -= ev->mouse_wheel_delta.x;
@@ -1399,7 +1399,7 @@ fn void ui_demo_update(app_frame_t *frame, mt_tweak_t *tweak_table, i32 tweak_co
ui_serial_type(UILOC, &ui_test_event, type(app_event_t));
r2f32_t scroll_rect = r2f32_fix(ui_top_rect());
scroller.p.verti.max_size = r2f32_get_size(scroll_rect).y;
scroller.p.verti.max_size = r2f32_size(scroll_rect).y;
}
ui_end_scroller(scroller);