RectF WidgetLayout::GetRect() const { RectF parentRect = GetParentRectangle(); RectF rectangle(mData->offsetMin + mData->anchorMin*parentRect.Size(), mData->offsetMax + mData->anchorMax*parentRect.Size()); return rectangle; }
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(); }
void WidgetLayout::SetWidth(float value) { RectF parentRect = GetParentRectangle(); RectF rectangle(mData->offsetMin + mData->anchorMin*parentRect.Size(), mData->offsetMax + mData->anchorMax*parentRect.Size()); float szDelta = value - rectangle.Width(); mData->offsetMax.x += szDelta*(1.0f - mData->pivot.x); mData->offsetMin.x -= szDelta*mData->pivot.x; SetDirty(); }
void WidgetLayout::SetSize(const Vec2F& size) { RectF parentRect = GetParentRectangle(); RectF rectangle(mData->offsetMin + mData->anchorMin*parentRect.Size(), mData->offsetMax + mData->anchorMax*parentRect.Size()); Vec2F szDelta = size - rectangle.Size(); mData->offsetMax += szDelta*(Vec2F::One() - mData->pivot); mData->offsetMin -= szDelta*mData->pivot; SetDirty(); }
void WidgetLayout::SetPosition(const Vec2F& position) { RectF parentRect = GetParentRectangle(); RectF rectangle(mData->offsetMin + mData->anchorMin*parentRect.Size(), mData->offsetMax + mData->anchorMax*parentRect.Size()); Vec2F delta = position - rectangle.LeftBottom() + rectangle.Size()*mData->pivot; mData->offsetMin += delta; mData->offsetMax += delta; SetDirty(); }
void WidgetLayout::SetHeight(float value) { RectF parentRect = GetParentRectangle(); RectF rectangle(mData->offsetMin + mData->anchorMin*parentRect.Size(), mData->offsetMax + mData->anchorMax*parentRect.Size()); float szDelta = value - rectangle.Height(); mData->offsetMax.y += szDelta*(1.0f - mData->pivot.y); mData->offsetMin.y -= szDelta*mData->pivot.y; SetDirty(); }
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 FrameScrollView::UpdateCameraLimits(float dt) { if (o2Input.IsCursorDown()) return; RectF camRect = mViewCamera.GetRect(); Vec2F camSize = camRect.Size(); mHorScrollbar->SetValueRange(Math::Min(mAvailableArea.left + camSize.x*0.5f, camRect.Center().x), Math::Max(mAvailableArea.right - camSize.x*0.5f, camRect.Center().x)); mHorScrollbar->SetScrollHandleSize(camRect.Width()); mVerScrollbar->SetValueRange(Math::Min(mAvailableArea.bottom + camSize.y*0.5f, camRect.Center().y), Math::Max(mAvailableArea.top - camSize.y*0.5f, camRect.Center().y)); mVerScrollbar->SetScrollHandleSize(camRect.Height()); }