|
|
@@ -7,24 +7,12 @@ using namespace CamelotFramework;
|
|
|
|
|
|
namespace BansheeEngine
|
|
|
{
|
|
|
- GUIArea::GUIArea(GUIWidget& widget, UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT16 depth)
|
|
|
- :mWidget(widget), mX(x), mY(y), mWidth(width), mHeight(height), mDepth(depth), mIsDirty(true),
|
|
|
- mResizeHeightWithWindow(false), mResizeWidthWithWindow(false)
|
|
|
+ GUIArea::GUIArea(GUIWidget& widget, UINT32 x, UINT32 y, UINT16 depth)
|
|
|
+ :mWidget(widget), mLeft(x), mTop(y), mDepth(depth), mIsDirty(true),
|
|
|
+ mResizeXWithWidget(false), mResizeYWithWidget(false), mWidth(0), mHeight(0), mRight(0), mBottom(0)
|
|
|
{
|
|
|
mLayout = cm_new<GUILayoutX, PoolAlloc>();
|
|
|
|
|
|
- if(width <= 0)
|
|
|
- {
|
|
|
- mWidth = mWidget.getTarget()->getWidth() - mX;
|
|
|
- mResizeWidthWithWindow = true;
|
|
|
- }
|
|
|
-
|
|
|
- if(height <= 0)
|
|
|
- {
|
|
|
- mHeight = mWidget.getTarget()->getHeight() - mY;
|
|
|
- mResizeHeightWithWindow = true;
|
|
|
- }
|
|
|
-
|
|
|
mWidget.registerArea(this);
|
|
|
}
|
|
|
|
|
|
@@ -35,7 +23,54 @@ namespace BansheeEngine
|
|
|
|
|
|
GUIArea* GUIArea::create(GUIWidget& widget, UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT16 depth)
|
|
|
{
|
|
|
- return new (cm_alloc<GUIArea, PoolAlloc>()) GUIArea(widget, x, y, width, height, depth);
|
|
|
+ GUIArea* area = new (cm_alloc<GUIArea, PoolAlloc>()) GUIArea(widget, x, y, depth);
|
|
|
+ area->mWidth = width;
|
|
|
+ area->mHeight = height;
|
|
|
+
|
|
|
+ return area;
|
|
|
+ }
|
|
|
+
|
|
|
+ GUIArea* GUIArea::createStretchedXY(GUIWidget& widget, UINT32 offsetLeft,
|
|
|
+ UINT32 offsetRight, UINT32 offsetTop, UINT32 offsetBottom, UINT16 depth)
|
|
|
+ {
|
|
|
+ GUIArea* area = new (cm_alloc<GUIArea, PoolAlloc>()) GUIArea(widget, offsetLeft, offsetTop, depth);
|
|
|
+
|
|
|
+ area->mWidth = std::max(0, (INT32)widget.getTarget()->getWidth() - (INT32)offsetLeft - (INT32)offsetRight);
|
|
|
+ area->mHeight = std::max(0, (INT32)widget.getTarget()->getHeight() - (INT32)offsetTop - (INT32)offsetBottom);
|
|
|
+ area->mRight = offsetRight;
|
|
|
+ area->mBottom = offsetBottom;
|
|
|
+ area->mResizeXWithWidget = true;
|
|
|
+ area->mResizeYWithWidget = true;
|
|
|
+
|
|
|
+ return area;
|
|
|
+ }
|
|
|
+
|
|
|
+ GUIArea* GUIArea::createStretchedX(GUIWidget& widget, CM::UINT32 offsetLeft,
|
|
|
+ CM::UINT32 offsetRight, CM::UINT32 offsetTop, CM::UINT32 height, CM::UINT16 depth)
|
|
|
+ {
|
|
|
+ GUIArea* area = new (cm_alloc<GUIArea, PoolAlloc>()) GUIArea(widget, offsetLeft, offsetTop, depth);
|
|
|
+
|
|
|
+ area->mWidth = std::max(0, (INT32)widget.getTarget()->getWidth() - (INT32)offsetLeft - (INT32)offsetRight);
|
|
|
+ area->mHeight = height;
|
|
|
+ area->mRight = offsetRight;
|
|
|
+ area->mResizeXWithWidget = true;
|
|
|
+ area->mResizeYWithWidget = false;
|
|
|
+
|
|
|
+ return area;
|
|
|
+ }
|
|
|
+
|
|
|
+ GUIArea* GUIArea::createStretchedY(GUIWidget& widget, CM::UINT32 offsetTop,
|
|
|
+ CM::UINT32 offsetBottom, CM::UINT32 offsetLeft, CM::UINT32 width, CM::UINT16 depth)
|
|
|
+ {
|
|
|
+ GUIArea* area = new (cm_alloc<GUIArea, PoolAlloc>()) GUIArea(widget, offsetLeft, offsetTop, depth);
|
|
|
+
|
|
|
+ area->mWidth = width;
|
|
|
+ area->mHeight = std::max(0, (INT32)widget.getTarget()->getHeight() - (INT32)offsetTop - (INT32)offsetBottom);
|
|
|
+ area->mBottom = offsetBottom;
|
|
|
+ area->mResizeXWithWidget = false;
|
|
|
+ area->mResizeYWithWidget = true;
|
|
|
+
|
|
|
+ return area;
|
|
|
}
|
|
|
|
|
|
void GUIArea::destroy(GUIArea* area)
|
|
|
@@ -54,7 +89,7 @@ namespace BansheeEngine
|
|
|
{
|
|
|
if(isDirty())
|
|
|
{
|
|
|
- mLayout->_updateLayout(mX, mY, mWidth, mHeight, mWidget.getDepth(), mDepth);
|
|
|
+ mLayout->_updateLayout(mLeft, mTop, mWidth, mHeight, mWidget.getDepth(), mDepth);
|
|
|
mIsDirty = false;
|
|
|
}
|
|
|
}
|
|
|
@@ -69,15 +104,13 @@ namespace BansheeEngine
|
|
|
|
|
|
void GUIArea::notifyWindowResized(UINT32 newWidth, UINT32 newHeight)
|
|
|
{
|
|
|
- if(mResizeWidthWithWindow)
|
|
|
- mWidth = newWidth - mX;
|
|
|
+ if(mResizeXWithWidget)
|
|
|
+ mWidth = (UINT32)std::max(0, (INT32)newWidth - (INT32)mLeft - (INT32)mRight);
|
|
|
|
|
|
- if(mResizeHeightWithWindow)
|
|
|
- mHeight = newHeight - mY;
|
|
|
+ if(mResizeYWithWidget)
|
|
|
+ mHeight = (UINT32)std::max(0, (INT32)newHeight - (INT32)mTop - (INT32)mBottom);
|
|
|
|
|
|
- if(mResizeWidthWithWindow || mResizeHeightWithWindow)
|
|
|
- {
|
|
|
+ if(mResizeXWithWidget || mResizeYWithWidget)
|
|
|
mIsDirty = true;
|
|
|
- }
|
|
|
}
|
|
|
}
|