renamed position_element() to layout_element()

This commit is contained in:
Alessandro Mauri 2025-07-14 13:15:21 +02:00
parent 278e4988e9
commit e8bb35811a
7 changed files with 11 additions and 11 deletions

2
TODO
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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,

View File

@ -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);