Refactor layout and size policies - dirty

This commit is contained in:
IlyaShurupov 2024-10-11 16:48:44 +03:00 committed by Ilya Shurupov
parent 5de5dbba23
commit 0ebbe75b6e
8 changed files with 284 additions and 96 deletions

View file

@ -42,7 +42,7 @@ RectF Widget::getAreaT() const {
return mArea.getTargetRect();
}
RectF Widget::getAreaCache() const {
const RectF& Widget::getAreaCache() const {
return mAreaCache;
}
@ -134,7 +134,7 @@ void Widget::removeChild(Widget* child) {
child->triggerWidgetUpdate("parent changed");
}
void Widget::setSizePolicy(tp::Widget::SizePolicy x, tp::Widget::SizePolicy y) {
void Widget::setSizePolicy(SizePolicy x, SizePolicy y) {
mSizePolicy = { x, y };
triggerWidgetUpdate("chane size policy");
}
@ -162,7 +162,7 @@ void Widget::pickRect() {
auto newArea = RectF(rangeX, rangeY);
for (auto child : mChildren) {
child->setAreaCache(child->getAreaCache().move(current.pos - newArea.pos));
child->setAreaCache(RectF(child->getAreaCache()).move(current.pos - newArea.pos));
}
setAreaCache(newArea);
@ -184,8 +184,8 @@ void Widget::adjustChildrenRect() {
switch (mLayoutPolicy) {
case LayoutPolicy::Passive: break;
case LayoutPolicy::Vertically: adjustLayout(true); break;
case LayoutPolicy::Horizontally: adjustLayout(false); break;
case LayoutPolicy::Vertical: adjustLayout(true); break;
case LayoutPolicy::Horizontal: adjustLayout(false); break;
}
}
@ -305,7 +305,7 @@ RangeF Widget::clampRange(const RangeF& current, const RangeF& children, const R
return out;
}
RectF Widget::getChildrenEnclosure() {
RectF Widget::getChildrenEnclosure() const {
RectF out;
if (mChildren.empty()) {