From e8bb35811ae9b309643f8904d89c5458bf0c7ea6 Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Mon, 14 Jul 2025 13:15:21 +0200 Subject: [PATCH] renamed position_element() to layout_element() --- TODO | 2 +- lib/ugui.c3l/src/ugui_button.c3 | 6 +++--- lib/ugui.c3l/src/ugui_div.c3 | 2 +- lib/ugui.c3l/src/ugui_layout.c3 | 2 +- lib/ugui.c3l/src/ugui_slider.c3 | 4 ++-- lib/ugui.c3l/src/ugui_sprite.c3 | 2 +- lib/ugui.c3l/src/ugui_text.c3 | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/TODO b/TODO index 24cfa94..07b3bfb 100644 --- a/TODO +++ b/TODO @@ -60,7 +60,7 @@ to maintain focus until mouse release (fix scroll bars) of elements [ ] Center elements to div (center children_bounds to the center of the div bounds and shift the origin accordingly) [x] Use containing_rect() in position_element() to skip some computing and semplify the function -[ ] Rename position_element() to layout_element() +[x] Rename position_element() to layout_element() [ ] Make functions to mark rows/columns as full, to fix the calculator demo ## Input diff --git a/lib/ugui.c3l/src/ugui_button.c3 b/lib/ugui.c3l/src/ugui_button.c3 index 321434f..064a350 100644 --- a/lib/ugui.c3l/src/ugui_button.c3 +++ b/lib/ugui.c3l/src/ugui_button.c3 @@ -44,7 +44,7 @@ fn ElemEvents? Ctx.button_id(&ctx, Id id, String label, String icon) .h = (short)max(min_size.h, max(icon_size.h, text_size.h)), }; - elem.bounds = ctx.position_element(parent, tot_size, style); + elem.bounds = ctx.layout_element(parent, tot_size, style); if (elem.bounds.is_null()) return {}; elem.events = ctx.get_elem_events(elem); Rect content_bounds = elem.content_bounds(style); @@ -94,7 +94,7 @@ fn void? Ctx.checkbox_id(&ctx, Id id, String description, Point off, bool* activ Style* style = ctx.styles.get_style(@str_hash("checkbox")); Rect size = {off.x, off.y, style.size, style.size}; - elem.bounds = ctx.position_element(parent, size, style); + elem.bounds = ctx.layout_element(parent, size, style); // if the bounds are null the element is outside the div view, // no interaction should occur so just return @@ -133,7 +133,7 @@ fn void? Ctx.toggle_id(&ctx, Id id, String description, Point off, bool* active) Style* style = ctx.styles.get_style(@str_hash("toggle")); Rect size = {off.x, off.y, style.size*2, style.size}; - elem.bounds = ctx.position_element(parent, size, style); + elem.bounds = ctx.layout_element(parent, size, style); // if the bounds are null the element is outside the div view, // no interaction should occur so just return diff --git a/lib/ugui.c3l/src/ugui_div.c3 b/lib/ugui.c3l/src/ugui_div.c3 index b56eaca..fb1e42a 100644 --- a/lib/ugui.c3l/src/ugui_div.c3 +++ b/lib/ugui.c3l/src/ugui_div.c3 @@ -53,7 +53,7 @@ fn void? Ctx.div_begin_id(&ctx, Id id, Rect size, bool scroll_x, bool scroll_y) .w = size.w < 0 ? max(elem.div.pcb.w, (short)-size.w) : size.w, .h = size.h < 0 ? max(elem.div.pcb.h, (short)-size.h) : size.h, }; - elem.bounds = ctx.position_element(parent, wanted_size, style); + elem.bounds = ctx.layout_element(parent, wanted_size, style); elem.div.children_bounds = {}; // update the ctx scissor diff --git a/lib/ugui.c3l/src/ugui_layout.c3 b/lib/ugui.c3l/src/ugui_layout.c3 index a81eb22..4315e61 100644 --- a/lib/ugui.c3l/src/ugui_layout.c3 +++ b/lib/ugui.c3l/src/ugui_layout.c3 @@ -76,7 +76,7 @@ macro Point Elem.get_view_off(&elem) @require ctx != null @require parent.type == ETYPE_DIV *> -fn Rect Ctx.position_element(&ctx, Elem *parent, Rect rect, Style* style) +fn Rect Ctx.layout_element(&ctx, Elem *parent, Rect rect, Style* style) { ElemDiv* div = &parent.div; diff --git a/lib/ugui.c3l/src/ugui_slider.c3 b/lib/ugui.c3l/src/ugui_slider.c3 index 645f4e3..bacd4b6 100644 --- a/lib/ugui.c3l/src/ugui_slider.c3 +++ b/lib/ugui.c3l/src/ugui_slider.c3 @@ -28,7 +28,7 @@ fn ElemEvents? Ctx.slider_hor_id(&ctx, Id id, Rect size, float* value, float hpe Style* style = ctx.styles.get_style(@str_hash("slider")); // 2. Layout - elem.bounds = ctx.position_element(parent, size, style); + elem.bounds = ctx.layout_element(parent, size, style); if (elem.bounds.is_null()) return {}; Rect content_bounds = elem.content_bounds(style); @@ -95,7 +95,7 @@ fn ElemEvents? Ctx.slider_ver_id(&ctx, Id id, Rect size, float* value, float hpe } // 2. Layout - elem.bounds = ctx.position_element(parent, size, style); + elem.bounds = ctx.layout_element(parent, size, style); if (elem.bounds.is_null()) return {}; Rect content_bounds = elem.content_bounds(style); diff --git a/lib/ugui.c3l/src/ugui_sprite.c3 b/lib/ugui.c3l/src/ugui_sprite.c3 index 724262d..152f109 100644 --- a/lib/ugui.c3l/src/ugui_sprite.c3 +++ b/lib/ugui.c3l/src/ugui_sprite.c3 @@ -126,7 +126,7 @@ fn void? Ctx.sprite_id(&ctx, Id id, String name, Point off) Rect uv = { sprite.u, sprite.v, sprite.w, sprite.h }; Rect bounds = { 0, 0, sprite.w, sprite.h }; - elem.bounds = ctx.position_element(parent, bounds.off(off), style); + elem.bounds = ctx.layout_element(parent, bounds.off(off), style); elem.sprite.id = ctx.get_sprite_atlas_id(name); // if the bounds are null the element is outside the div view, diff --git a/lib/ugui.c3l/src/ugui_text.c3 b/lib/ugui.c3l/src/ugui_text.c3 index f9afcb0..f1513a9 100644 --- a/lib/ugui.c3l/src/ugui_text.c3 +++ b/lib/ugui.c3l/src/ugui_text.c3 @@ -27,7 +27,7 @@ fn void? Ctx.text_unbounded_id(&ctx, Id id, String text) elem.text.hash = text_hash; // 2. Layout - elem.bounds = ctx.position_element(parent, elem.text.bounds, style); + elem.bounds = ctx.layout_element(parent, elem.text.bounds, style); if (elem.bounds.is_null()) { return; } ctx.push_string(elem.bounds, text, parent.div.z_index, style.fg)!; @@ -46,7 +46,7 @@ fn ElemEvents? Ctx.text_box_id(&ctx, Id id, Rect size, char[] text, usz* text_le elem.text.str = (String)text; // layout the text box - elem.bounds = ctx.position_element(parent, size, style); + elem.bounds = ctx.layout_element(parent, size, style); // check input and update the text elem.events = ctx.get_elem_events(elem);