stuff, mostly renaming variables

This commit is contained in:
Alessandro Mauri 2024-12-19 15:24:39 +01:00
parent 601a396aa8
commit 1088083e1e
7 changed files with 127 additions and 129 deletions

View file

@ -14,39 +14,39 @@ fn ElemEvents! Ctx.button(&ctx, String label, Rect size, bool state = false)
Id id = ctx.gen_id(label)!;
Elem *parent = ctx.get_parent()!;
Elem *c_elem = ctx.get_elem(id)!;
Elem *elem = ctx.get_elem(id)!;
// add it to the tree
ctx.tree.add(id, ctx.active_div)!;
if (c_elem.flags.is_new) {
c_elem.type = ETYPE_BUTTON;
c_elem.button.color = uint_to_rgba(0x0000ffff);
} else if (c_elem.type != ETYPE_BUTTON) {
if (elem.flags.is_new) {
elem.type = ETYPE_BUTTON;
elem.button.color = uint_to_rgba(0x0000ffff);
} else if (elem.type != ETYPE_BUTTON) {
return UgError.WRONG_ELEMENT_TYPE?;
}
c_elem.bounds = ctx.position_element(parent, size, true);
elem.bounds = ctx.position_element(parent, size, true);
// if the bounds are null the element is outside the div view,
// no interaction should occur so just return
if (c_elem.bounds.is_null()) { return ElemEvents{}; }
if (elem.bounds.is_null()) { return ElemEvents{}; }
c_elem.events = ctx.get_elem_events(c_elem);
if (c_elem.events.mouse_hover) {
elem.events = ctx.get_elem_events(elem);
if (elem.events.mouse_hover) {
if (parent.flags.has_focus) {
c_elem.flags.has_focus = true;
c_elem.button.color = uint_to_rgba(0x00ff00ff);
elem.flags.has_focus = true;
elem.button.color = uint_to_rgba(0x00ff00ff);
}
} else {
c_elem.button.color = uint_to_rgba(0x0000ffff);
elem.button.color = uint_to_rgba(0x0000ffff);
}
if (state) {
c_elem.button.color = uint_to_rgba(0xff00ffff);
elem.button.color = uint_to_rgba(0xff00ffff);
}
// Draw the button
ctx.push_rect(c_elem.bounds, c_elem.button.color, do_border: true, do_radius: true)!;
ctx.push_rect(elem.bounds, elem.button.color, do_border: true, do_radius: true)!;
return c_elem.events;
return elem.events;
}