BsEditorWindow.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "BsEditorWindow.h"
  2. #include "BsEditorWidgetContainer.h"
  3. #include "BsEditorWindowManager.h"
  4. using namespace CamelotFramework;
  5. using namespace BansheeEngine;
  6. namespace BansheeEditor
  7. {
  8. EditorWindow::EditorWindow()
  9. :EditorWindowBase(), mWidgets(cm_new<EditorWidgetContainer>(mGUI.get()))
  10. {
  11. updateSize();
  12. mWidgets->onWidgetClosed.connect(boost::bind(&EditorWindow::widgetRemoved, this));
  13. mWidgets->onWidgetHidden.connect(boost::bind(&EditorWindow::widgetHidden, this));
  14. }
  15. EditorWindow::~EditorWindow()
  16. {
  17. cm_delete(mWidgets);
  18. }
  19. void EditorWindow::movedOrResized()
  20. {
  21. EditorWindowBase::movedOrResized();
  22. updateSize();
  23. }
  24. void EditorWindow::updateSize()
  25. {
  26. mWidgets->setPosition(1, 1);
  27. UINT32 widgetWidth = (UINT32)std::max(0, (INT32)getWidth() - 2);
  28. UINT32 widgetHeight = (UINT32)std::max(0, (INT32)getHeight() - 2);
  29. mWidgets->setSize(widgetWidth, widgetHeight);
  30. }
  31. void EditorWindow::widgetRemoved()
  32. {
  33. if(mWidgets->getNumWidgets() == 0)
  34. close();
  35. }
  36. void EditorWindow::widgetHidden()
  37. {
  38. if(mWidgets->getNumWidgets() == 1)
  39. hide();
  40. }
  41. EditorWindow* EditorWindow::create()
  42. {
  43. return EditorWindowManager::instance().create();
  44. }
  45. }