fix dimensions being calculated wrong
This commit is contained in:
parent
636f162b10
commit
be951c616a
@ -55,8 +55,11 @@ macro Size Layout.total_height(&el)
|
|||||||
// Returns the width and height of a @FIT() element based on it's wanted size (min/max)
|
// Returns the width and height of a @FIT() element based on it's wanted size (min/max)
|
||||||
// and the content size, this function is used to both update the parent's children size and
|
// and the content size, this function is used to both update the parent's children size and
|
||||||
// give the dimensions of a fit element
|
// give the dimensions of a fit element
|
||||||
|
// TODO: test and cleanup this function
|
||||||
macro Point Layout.get_dimensions(&el)
|
macro Point Layout.get_dimensions(&el)
|
||||||
{
|
{
|
||||||
|
// if the direction is ROW then the text is placed horizontally with the children
|
||||||
|
if (el.dir == ROW) {
|
||||||
Size content_width = el.children.w + el.text.width;
|
Size content_width = el.children.w + el.text.width;
|
||||||
Size width = el.w.combine(content_width);
|
Size width = el.w.combine(content_width);
|
||||||
short final_width = width.greater();
|
short final_width = width.greater();
|
||||||
@ -67,6 +70,27 @@ macro Point Layout.get_dimensions(&el)
|
|||||||
text_height = @exact((short)(el.text.area / text_width)).combine(el.text.height).min;
|
text_height = @exact((short)(el.text.area / text_width)).combine(el.text.height).min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Size content_height = el.children.h.comb_max(@exact(text_height));
|
||||||
|
Size height = el.h.combine(content_height);
|
||||||
|
short final_height = height.greater();
|
||||||
|
|
||||||
|
Point dim = {
|
||||||
|
.x = final_width + el.content_offset.x + el.content_offset.w,
|
||||||
|
.y = final_height + el.content_offset.y + el.content_offset.h,
|
||||||
|
};
|
||||||
|
return dim;
|
||||||
|
} else {
|
||||||
|
// if the direction is COLUMN the text and children are one on top of the other
|
||||||
|
Size content_width = el.children.w.comb_max(el.text.width);
|
||||||
|
Size width = el.w.combine(content_width);
|
||||||
|
short final_width = width.greater();
|
||||||
|
|
||||||
|
short text_height;
|
||||||
|
if (el.text.area != 0) {
|
||||||
|
short text_width = @exact(final_width).combine(el.text.width).min;
|
||||||
|
text_height = @exact((short)(el.text.area / text_width)).combine(el.text.height).min;
|
||||||
|
}
|
||||||
|
|
||||||
Size content_height = el.children.h + @exact(text_height);
|
Size content_height = el.children.h + @exact(text_height);
|
||||||
Size height = el.h.combine(content_height);
|
Size height = el.h.combine(content_height);
|
||||||
short final_height = height.greater();
|
short final_height = height.greater();
|
||||||
@ -76,6 +100,7 @@ macro Point Layout.get_dimensions(&el)
|
|||||||
.y = final_height + el.content_offset.y + el.content_offset.h,
|
.y = final_height + el.content_offset.y + el.content_offset.h,
|
||||||
};
|
};
|
||||||
return dim;
|
return dim;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The content space of the element
|
// The content space of the element
|
||||||
|
Loading…
Reference in New Issue
Block a user