|
@@ -7,13 +7,13 @@ using namespace CamelotFramework;
|
|
|
|
|
|
|
|
namespace BansheeEngine
|
|
namespace BansheeEngine
|
|
|
{
|
|
{
|
|
|
- GUIArea::GUIArea(GUIWidget& widget, UINT32 x, UINT32 y, UINT16 depth)
|
|
|
|
|
|
|
+ GUIArea::GUIArea(GUIWidget* widget, UINT32 x, UINT32 y, UINT16 depth)
|
|
|
:mWidget(widget), mLeft(x), mTop(y), mDepth(depth), mIsDirty(true), mIsDisabled(false),
|
|
:mWidget(widget), mLeft(x), mTop(y), mDepth(depth), mIsDirty(true), mIsDisabled(false),
|
|
|
mResizeXWithWidget(false), mResizeYWithWidget(false), mWidth(0), mHeight(0), mRight(0), mBottom(0)
|
|
mResizeXWithWidget(false), mResizeYWithWidget(false), mWidth(0), mHeight(0), mRight(0), mBottom(0)
|
|
|
{
|
|
{
|
|
|
mLayout = cm_new<GUILayoutX, PoolAlloc>();
|
|
mLayout = cm_new<GUILayoutX, PoolAlloc>();
|
|
|
|
|
|
|
|
- mWidget.registerArea(this);
|
|
|
|
|
|
|
+ mWidget->registerArea(this);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
GUIArea::~GUIArea()
|
|
GUIArea::~GUIArea()
|
|
@@ -23,7 +23,7 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
GUIArea* GUIArea::create(GUIWidget& widget, UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT16 depth)
|
|
GUIArea* GUIArea::create(GUIWidget& widget, UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT16 depth)
|
|
|
{
|
|
{
|
|
|
- GUIArea* area = new (cm_alloc<GUIArea, PoolAlloc>()) GUIArea(widget, x, y, depth);
|
|
|
|
|
|
|
+ GUIArea* area = new (cm_alloc<GUIArea, PoolAlloc>()) GUIArea(&widget, x, y, depth);
|
|
|
area->mWidth = width;
|
|
area->mWidth = width;
|
|
|
area->mHeight = height;
|
|
area->mHeight = height;
|
|
|
|
|
|
|
@@ -33,7 +33,7 @@ namespace BansheeEngine
|
|
|
GUIArea* GUIArea::createStretchedXY(GUIWidget& widget, UINT32 offsetLeft,
|
|
GUIArea* GUIArea::createStretchedXY(GUIWidget& widget, UINT32 offsetLeft,
|
|
|
UINT32 offsetRight, UINT32 offsetTop, UINT32 offsetBottom, UINT16 depth)
|
|
UINT32 offsetRight, UINT32 offsetTop, UINT32 offsetBottom, UINT16 depth)
|
|
|
{
|
|
{
|
|
|
- GUIArea* area = new (cm_alloc<GUIArea, PoolAlloc>()) GUIArea(widget, offsetLeft, offsetTop, 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->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->mHeight = std::max(0, (INT32)widget.getTarget()->getHeight() - (INT32)offsetTop - (INT32)offsetBottom);
|
|
@@ -48,7 +48,7 @@ namespace BansheeEngine
|
|
|
GUIArea* GUIArea::createStretchedX(GUIWidget& widget, CM::UINT32 offsetLeft,
|
|
GUIArea* GUIArea::createStretchedX(GUIWidget& widget, CM::UINT32 offsetLeft,
|
|
|
CM::UINT32 offsetRight, CM::UINT32 offsetTop, CM::UINT32 height, CM::UINT16 depth)
|
|
CM::UINT32 offsetRight, CM::UINT32 offsetTop, CM::UINT32 height, CM::UINT16 depth)
|
|
|
{
|
|
{
|
|
|
- GUIArea* area = new (cm_alloc<GUIArea, PoolAlloc>()) GUIArea(widget, offsetLeft, offsetTop, 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->mWidth = std::max(0, (INT32)widget.getTarget()->getWidth() - (INT32)offsetLeft - (INT32)offsetRight);
|
|
|
area->mHeight = height;
|
|
area->mHeight = height;
|
|
@@ -62,7 +62,7 @@ namespace BansheeEngine
|
|
|
GUIArea* GUIArea::createStretchedY(GUIWidget& widget, CM::UINT32 offsetTop,
|
|
GUIArea* GUIArea::createStretchedY(GUIWidget& widget, CM::UINT32 offsetTop,
|
|
|
CM::UINT32 offsetBottom, CM::UINT32 offsetLeft, CM::UINT32 width, CM::UINT16 depth)
|
|
CM::UINT32 offsetBottom, CM::UINT32 offsetLeft, CM::UINT32 width, CM::UINT16 depth)
|
|
|
{
|
|
{
|
|
|
- GUIArea* area = new (cm_alloc<GUIArea, PoolAlloc>()) GUIArea(widget, offsetLeft, offsetTop, depth);
|
|
|
|
|
|
|
+ GUIArea* area = new (cm_alloc<GUIArea, PoolAlloc>()) GUIArea(&widget, offsetLeft, offsetTop, depth);
|
|
|
|
|
|
|
|
area->mWidth = width;
|
|
area->mWidth = width;
|
|
|
area->mHeight = std::max(0, (INT32)widget.getTarget()->getHeight() - (INT32)offsetTop - (INT32)offsetBottom);
|
|
area->mHeight = std::max(0, (INT32)widget.getTarget()->getHeight() - (INT32)offsetTop - (INT32)offsetBottom);
|
|
@@ -75,7 +75,8 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
void GUIArea::destroy(GUIArea* area)
|
|
void GUIArea::destroy(GUIArea* area)
|
|
|
{
|
|
{
|
|
|
- area->mWidget.unregisterArea(area);
|
|
|
|
|
|
|
+ if(area->mWidget != nullptr)
|
|
|
|
|
+ area->mWidget->unregisterArea(area);
|
|
|
|
|
|
|
|
cm_delete<PoolAlloc>(area);
|
|
cm_delete<PoolAlloc>(area);
|
|
|
}
|
|
}
|
|
@@ -99,13 +100,16 @@ namespace BansheeEngine
|
|
|
mLayout->enableRecursively();
|
|
mLayout->enableRecursively();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void GUIArea::changeParentWidget(GUIWidget& widget)
|
|
|
|
|
|
|
+ void GUIArea::changeParentWidget(GUIWidget* widget)
|
|
|
{
|
|
{
|
|
|
- if(&mWidget == &widget)
|
|
|
|
|
|
|
+ if(mWidget == widget)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
- mWidget.unregisterArea(this);
|
|
|
|
|
- widget.registerArea(this);
|
|
|
|
|
|
|
+ if(mWidget != nullptr)
|
|
|
|
|
+ mWidget->unregisterArea(this);
|
|
|
|
|
+
|
|
|
|
|
+ if(widget != nullptr)
|
|
|
|
|
+ widget->registerArea(this);
|
|
|
|
|
|
|
|
mWidget = widget;
|
|
mWidget = widget;
|
|
|
|
|
|
|
@@ -114,10 +118,10 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
void GUIArea::_update()
|
|
void GUIArea::_update()
|
|
|
{
|
|
{
|
|
|
- if(!mIsDisabled && isDirty())
|
|
|
|
|
|
|
+ if(!mIsDisabled && isDirty() && (mWidget != nullptr))
|
|
|
{
|
|
{
|
|
|
Rect clipRect(mLeft, mTop, mWidth, mHeight);
|
|
Rect clipRect(mLeft, mTop, mWidth, mHeight);
|
|
|
- mLayout->_updateLayout(mLeft, mTop, mWidth, mHeight, clipRect, mWidget.getDepth(), mDepth);
|
|
|
|
|
|
|
+ mLayout->_updateLayout(mLeft, mTop, mWidth, mHeight, clipRect, mWidget->getDepth(), mDepth);
|
|
|
mIsDirty = false;
|
|
mIsDirty = false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|