void WidgetLayout::Update() { RectF parentWorldRect; Vec2F parentWorldPosition; if (mData->owner->mParentWidget) { parentWorldRect = mData->owner->mParentWidget->mChildrenWorldRect; RectF notWidgetWorldRect = mData->owner->mParentWidget->transform->mData->worldRectangle; parentWorldPosition = notWidgetWorldRect.LeftBottom() + mData->owner->mParentWidget->transform->mData->pivot*notWidgetWorldRect.Size(); } else if (mData->owner->mParent) { parentWorldRect = mData->owner->mParent->transform->mData->worldRectangle; parentWorldPosition = parentWorldRect.LeftBottom() + mData->owner->mParent->transform->mData->pivot*parentWorldRect.Size(); } RectF worldRectangle(parentWorldRect.LeftBottom() + mData->offsetMin + mData->anchorMin*parentWorldRect.Size(), parentWorldRect.LeftBottom() + mData->offsetMax + mData->anchorMax*parentWorldRect.Size()); mData->size = worldRectangle.Size(); mData->position = worldRectangle.LeftBottom() - parentWorldPosition + mData->size*mData->pivot; (this->*mCheckMinMaxFunc)(); FloorRectangle(); UpdateRectangle(); UpdateTransform(); UpdateWorldRectangleAndTransform(); mData->updateFrame = mData->dirtyFrame; if (mData->owner) { mData->owner->mChildrenWorldRect = mData->worldRectangle; mData->owner->OnTransformUpdated(); } }
void WidgetLayout::SetRect(const RectF& rect) { RectF parentRect = GetParentRectangle(); RectF parentAnchoredRect(parentRect.Size()*mData->anchorMin, parentRect.Size()*mData->anchorMax); mData->offsetMin = rect.LeftBottom() - parentAnchoredRect.LeftBottom(); mData->offsetMax = rect.RightTop() - parentAnchoredRect.RightTop(); SetDirty(); }