BsGUIArea.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "BsGUIArea.h"
  2. #include "BsGUIWidget.h"
  3. #include "BsGUILayoutX.h"
  4. using namespace CamelotFramework;
  5. namespace BansheeEngine
  6. {
  7. GUIArea::GUIArea(GUIWidget& widget, UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT32 depth)
  8. :mWidget(widget), mX(x), mY(y), mWidth(width), mHeight(height), mDepth(depth)
  9. {
  10. mLayout = CM_NEW(GUILayoutX, PoolAlloc) GUILayoutX();
  11. resizeWidthWithWindow = width == 0;
  12. resizeHeightWithWindow = height == 0;
  13. mWidget.registerArea(this);
  14. }
  15. GUIArea::~GUIArea()
  16. {
  17. CM_DELETE(mLayout, GUILayout, PoolAlloc);
  18. }
  19. GUIArea* GUIArea::create(GUIWidget& widget, UINT32 x, UINT32 y, UINT32 width, UINT32 height, UINT32 depth)
  20. {
  21. return CM_NEW(GUIArea, PoolAlloc) GUIArea(widget, x, y, width, height, depth);
  22. }
  23. void GUIArea::destroy(GUIArea* area)
  24. {
  25. area->mWidget.unregisterArea(area);
  26. CM_DELETE(area, GUIArea, PoolAlloc);
  27. }
  28. void GUIArea::destroyInternal(GUIArea* area)
  29. {
  30. CM_DELETE(area, GUIArea, PoolAlloc);
  31. }
  32. void GUIArea::notifyWindowResized(UINT32 newWidth, UINT32 newHeight)
  33. {
  34. if(resizeWidthWithWindow)
  35. mWidth = newWidth;
  36. if(resizeHeightWithWindow)
  37. mHeight = newHeight;
  38. if(resizeWidthWithWindow || resizeHeightWithWindow)
  39. mLayout->_update(mX, mY, mWidth, mHeight, mDepth);
  40. }
  41. }