Exemplo n.º 1
0
	RectF WidgetLayout::GetRect() const
	{
		RectF parentRect = GetParentRectangle();

		RectF rectangle(mData->offsetMin + mData->anchorMin*parentRect.Size(),
						mData->offsetMax + mData->anchorMax*parentRect.Size());

		return rectangle;
	}
Exemplo n.º 2
0
	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();
	}
Exemplo n.º 3
0
	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();
	}
Exemplo n.º 4
0
	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();
	}
Exemplo n.º 5
0
	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();
	}
Exemplo n.º 6
0
	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();
	}
Exemplo n.º 7
0
	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();
		}
	}
Exemplo n.º 8
0
	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());
	}