BsEditorWidget.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include "BsEditorWidget.h"
  2. #include "BsGUIManager.h"
  3. #include "BsGUIWidget.h"
  4. #include "BsGUITexture.h"
  5. #include "BsGUISkin.h"
  6. #include "BsGUILayout.h"
  7. #include "BsEngineGUI.h"
  8. #include "BsGUIArea.h"
  9. #include "BsEditorWidgetContainer.h"
  10. using namespace CamelotFramework;
  11. using namespace BansheeEngine;
  12. namespace BansheeEditor
  13. {
  14. EditorWidgetBase::EditorWidgetBase(const HString& name)
  15. :mName(name), mParent(nullptr), mContent(nullptr)
  16. {
  17. }
  18. EditorWidgetBase::~EditorWidgetBase()
  19. {
  20. }
  21. void EditorWidgetBase::destroy(EditorWidgetBase* widget)
  22. {
  23. cm_delete(widget);
  24. }
  25. void EditorWidgetBase::_setPosition(INT32 x, INT32 y)
  26. {
  27. if(mContent == nullptr)
  28. return;
  29. mContent->setPosition(x, y);
  30. }
  31. void EditorWidgetBase::_setSize(UINT32 width, UINT32 height)
  32. {
  33. if(mContent == nullptr)
  34. return;
  35. mContent->setSize(width, height);
  36. }
  37. void EditorWidgetBase::_changeParent(EditorWidgetContainer* parent)
  38. {
  39. if(mParent != parent)
  40. {
  41. if(parent != nullptr)
  42. {
  43. if(mContent == nullptr)
  44. mContent = GUIArea::create(parent->getParentWidget(), 0, 0, 0, 0, 10000);
  45. else
  46. mContent->changeParentWidget(&parent->getParentWidget());
  47. }
  48. else
  49. {
  50. if(mContent != nullptr)
  51. mContent->changeParentWidget(nullptr);
  52. }
  53. mParent = parent;
  54. }
  55. }
  56. void EditorWidgetBase::_disable()
  57. {
  58. mContent->disable();
  59. }
  60. void EditorWidgetBase::_enable()
  61. {
  62. mContent->enable();
  63. }
  64. GUIWidget& EditorWidgetBase::getParentWidget() const
  65. {
  66. return mParent->getParentWidget();
  67. }
  68. }