cleaner get_parent()
This commit is contained in:
parent
8d79f13fd6
commit
78fc1c1e87
@ -65,7 +65,7 @@ alias ElemCache = cache::Cache{Id, Elem, MAX_ELEMENTS};
|
|||||||
|
|
||||||
alias CmdQueue = fifo::Fifo{Cmd};
|
alias CmdQueue = fifo::Fifo{Cmd};
|
||||||
|
|
||||||
faultdef INVALID_SIZE, EVENT_UNSUPPORTED, UNEXPECTED_ELEMENT, WRONG_ELEMENT_TYPE, WRONG_ID;
|
faultdef INVALID_SIZE, EVENT_UNSUPPORTED, WRONG_ELEMENT_TYPE, WRONG_ID;
|
||||||
|
|
||||||
const Rect DIV_FILL = { .x = 0, .y = 0, .w = 0, .h = 0 };
|
const Rect DIV_FILL = { .x = 0, .y = 0, .w = 0, .h = 0 };
|
||||||
|
|
||||||
@ -117,7 +117,10 @@ struct Ctx {
|
|||||||
fn Elem*? Ctx.get_parent(&ctx)
|
fn Elem*? Ctx.get_parent(&ctx)
|
||||||
{
|
{
|
||||||
Id parent_id = ctx.tree.get(ctx.active_div)!;
|
Id parent_id = ctx.tree.get(ctx.active_div)!;
|
||||||
return ctx.cache.search(parent_id);
|
Elem*? parent = ctx.cache.search(parent_id);
|
||||||
|
if (catch parent) return parent;
|
||||||
|
if (parent.type != ETYPE_DIV) return WRONG_ELEMENT_TYPE?;
|
||||||
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
macro @bits(#a) => $typeof(#a).sizeof*8;
|
macro @bits(#a) => $typeof(#a).sizeof*8;
|
||||||
|
@ -9,51 +9,25 @@ enum Layout {
|
|||||||
|
|
||||||
fn void? Ctx.layout_set_row(&ctx)
|
fn void? Ctx.layout_set_row(&ctx)
|
||||||
{
|
{
|
||||||
Id parent_id = ctx.tree.get(ctx.active_div)!;
|
Elem *parent = ctx.get_parent()!;
|
||||||
Elem *parent = ctx.cache.search(parent_id)!;
|
|
||||||
|
|
||||||
if (parent.type != ETYPE_DIV) {
|
|
||||||
// what?
|
|
||||||
return UNEXPECTED_ELEMENT?;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent.div.layout = LAYOUT_ROW;
|
parent.div.layout = LAYOUT_ROW;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn void? Ctx.layout_set_column(&ctx)
|
fn void? Ctx.layout_set_column(&ctx)
|
||||||
{
|
{
|
||||||
Id parent_id = ctx.tree.get(ctx.active_div)!;
|
Elem *parent = ctx.get_parent()!;
|
||||||
Elem *parent = ctx.cache.search(parent_id)!;
|
|
||||||
|
|
||||||
if (parent.type != ETYPE_DIV) {
|
|
||||||
// what?
|
|
||||||
return UNEXPECTED_ELEMENT?;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent.div.layout = LAYOUT_COLUMN;
|
parent.div.layout = LAYOUT_COLUMN;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn void? Ctx.layout_set_floating(&ctx)
|
fn void? Ctx.layout_set_floating(&ctx)
|
||||||
{
|
{
|
||||||
Id parent_id = ctx.tree.get(ctx.active_div)!;
|
Elem *parent = ctx.get_parent()!;
|
||||||
Elem *parent = ctx.cache.search(parent_id)!;
|
|
||||||
|
|
||||||
if (parent.type != ETYPE_DIV) {
|
|
||||||
// what?
|
|
||||||
return UNEXPECTED_ELEMENT?;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent.div.layout = LAYOUT_FLOATING;
|
parent.div.layout = LAYOUT_FLOATING;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn void? Ctx.layout_next_row(&ctx)
|
fn void? Ctx.layout_next_row(&ctx)
|
||||||
{
|
{
|
||||||
Id parent_id = ctx.tree.get(ctx.active_div)!;
|
Elem *parent = ctx.get_parent()!;
|
||||||
Elem *parent = ctx.cache.search(parent_id)!;
|
|
||||||
|
|
||||||
if (parent.type != ETYPE_DIV) {
|
|
||||||
return UNEXPECTED_ELEMENT?;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent.div.origin_r = {
|
parent.div.origin_r = {
|
||||||
.x = parent.bounds.x,
|
.x = parent.bounds.x,
|
||||||
@ -64,12 +38,7 @@ fn void? Ctx.layout_next_row(&ctx)
|
|||||||
|
|
||||||
fn void? Ctx.layout_next_column(&ctx)
|
fn void? Ctx.layout_next_column(&ctx)
|
||||||
{
|
{
|
||||||
Id parent_id = ctx.tree.get(ctx.active_div)!;
|
Elem *parent = ctx.get_parent()!;
|
||||||
Elem *parent = ctx.cache.search(parent_id)!;
|
|
||||||
|
|
||||||
if (parent.type != ETYPE_DIV) {
|
|
||||||
return UNEXPECTED_ELEMENT?;
|
|
||||||
}
|
|
||||||
|
|
||||||
parent.div.origin_c = {
|
parent.div.origin_c = {
|
||||||
.x = parent.div.children_bounds.bottom_right().x,
|
.x = parent.div.children_bounds.bottom_right().x,
|
||||||
|
Loading…
Reference in New Issue
Block a user