ugui.c3l/src/ugui_text.c3

27 lines
633 B
Plaintext
Raw Normal View History

2024-12-11 01:14:14 +01:00
module ugui;
import std::io;
2024-12-11 22:25:53 +01:00
2024-12-11 01:14:14 +01:00
fn void! Ctx.text_unbounded(&ctx, String label, String text)
{
Id id = label.hash();
Elem *parent = ctx.get_parent()!;
Elem *c_elem = ctx.get_elem(id)!;
// add it to the tree
ctx.tree.add(id, ctx.active_div)!;
// 1. Fill the element fields
// this resets the flags
c_elem.type = ETYPE_TEXT;
2024-12-11 01:14:14 +01:00
// if the element is new or the parent was updated then redo layout
2024-12-18 14:58:40 +01:00
Rect text_size = ctx.get_text_bounds(text)!;
// 2. Layout
c_elem.bounds = ctx.position_element(parent, text_size, true);
// 3. Fill the button specific fields
c_elem.text.str = text;
2024-12-11 01:14:14 +01:00
ctx.push_string(c_elem.bounds, text)!;
2024-12-11 01:14:14 +01:00
}