BsEditorWidget.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #include "BsEditorWidgetManager.h"
  11. using namespace CamelotFramework;
  12. using namespace BansheeEngine;
  13. namespace BansheeEditor
  14. {
  15. EditorWidgetBase::EditorWidgetBase(const HString& displayName, const CM::String& name)
  16. :mDisplayName(displayName), mName(name), mParent(nullptr), mContent(nullptr)
  17. {
  18. }
  19. EditorWidgetBase::~EditorWidgetBase()
  20. {
  21. }
  22. void EditorWidgetBase::close()
  23. {
  24. EditorWidgetManager::instance().close(this);
  25. }
  26. void EditorWidgetBase::destroy(EditorWidgetBase* widget)
  27. {
  28. widget->~EditorWidgetBase();
  29. cm_free(widget);
  30. }
  31. void EditorWidgetBase::_setPosition(INT32 x, INT32 y)
  32. {
  33. if(mContent == nullptr)
  34. return;
  35. mContent->setPosition(x, y);
  36. }
  37. void EditorWidgetBase::_setSize(UINT32 width, UINT32 height)
  38. {
  39. if(mContent == nullptr)
  40. return;
  41. mContent->setSize(width, height);
  42. }
  43. void EditorWidgetBase::_changeParent(EditorWidgetContainer* parent)
  44. {
  45. if(mParent != parent)
  46. {
  47. if(parent != nullptr)
  48. {
  49. if(mContent == nullptr)
  50. mContent = GUIArea::create(parent->getParentWidget(), 0, 0, 0, 0, 10000);
  51. else
  52. mContent->changeParentWidget(&parent->getParentWidget());
  53. }
  54. else
  55. {
  56. if(mContent != nullptr)
  57. mContent->changeParentWidget(nullptr);
  58. }
  59. mParent = parent;
  60. }
  61. }
  62. void EditorWidgetBase::_disable()
  63. {
  64. mContent->disable();
  65. }
  66. void EditorWidgetBase::_enable()
  67. {
  68. mContent->enable();
  69. }
  70. GUIWidget& EditorWidgetBase::getParentWidget() const
  71. {
  72. return mParent->getParentWidget();
  73. }
  74. }