int right = canvas.size().x;
int center = canvas.size().x / 2;
if (element.layoutHint.getPositionCenterHorizontal() != null) {
HorizontalInfo info = element.layoutHint.getPositionCenterHorizontal();
Rect2i targetRegion = getTargetRegion(info.getWidget(), canvas);
HorizontalAlign align = (info.getTarget() != null) ? info.getTarget() : HorizontalAlign.CENTER;
center = align.getStart(targetRegion) + info.getOffset();
}
if (element.layoutHint.getPositionLeft() != null) {
HorizontalInfo info = element.layoutHint.getPositionLeft();
Rect2i targetRegion = getTargetRegion(info.getWidget(), canvas);
HorizontalAlign align = (info.getTarget() != null) ? info.getTarget() : HorizontalAlign.LEFT;
left = align.getStart(targetRegion) + info.getOffset();
}
if (element.layoutHint.getPositionRight() != null) {
HorizontalInfo info = element.layoutHint.getPositionRight();
Rect2i targetRegion = getTargetRegion(info.getWidget(), canvas);
HorizontalAlign align = (info.getTarget() != null) ? info.getTarget() : HorizontalAlign.RIGHT;
right = align.getStart(targetRegion) - info.getOffset();
}
int top = 0;
int bottom = canvas.size().y;
int vcenter = canvas.size().y / 2;
if (element.layoutHint.getPositionCenterVertical() != null) {
VerticalInfo info = element.layoutHint.getPositionCenterVertical();
Rect2i targetRegion = getTargetRegion(info.getWidget(), canvas);
VerticalAlign align = (info.getTarget() != null) ? info.getTarget() : VerticalAlign.MIDDLE;
vcenter = align.getStart(targetRegion) + info.getOffset();
}
if (element.layoutHint.getPositionTop() != null) {
VerticalInfo info = element.layoutHint.getPositionTop();
Rect2i targetRegion = getTargetRegion(info.getWidget(), canvas);
VerticalAlign align = (info.getTarget() != null) ? info.getTarget() : VerticalAlign.TOP;
top = align.getStart(targetRegion) + info.getOffset();
}
if (element.layoutHint.getPositionBottom() != null) {
VerticalInfo info = element.layoutHint.getPositionBottom();
Rect2i targetRegion = getTargetRegion(info.getWidget(), canvas);
VerticalAlign align = (info.getTarget() != null) ? info.getTarget() : VerticalAlign.BOTTOM;
bottom = align.getStart(targetRegion) - info.getOffset();
}
int width = element.layoutHint.getWidth();
if (width == 0 && element.layoutHint.isUsingContentWidth()) {
width = canvas.calculateRestrictedSize(element.widget, new Vector2i(right - left, bottom - top)).x;