BsEditorWindow.cpp 961 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. :mWidgets(cm_new<EditorWidgetContainer>(mGUI.get()))
  10. {
  11. mWidgets->onWidgetClosed.connect(boost::bind(&EditorWindow::widgetRemoved, this));
  12. }
  13. EditorWindow::~EditorWindow()
  14. {
  15. cm_delete(mWidgets);
  16. }
  17. void EditorWindow::movedOrResized()
  18. {
  19. EditorWindowBase::movedOrResized();
  20. mWidgets->setPosition(1, 1);
  21. UINT32 widgetWidth = (UINT32)std::max(0, (INT32)getWidth() - 2);
  22. UINT32 widgetHeight = (UINT32)std::max(0, (INT32)getHeight() - 2);
  23. mWidgets->setSize(widgetWidth, widgetHeight);
  24. }
  25. void EditorWindow::widgetRemoved()
  26. {
  27. if(mWidgets->getNumWidgets() == 0)
  28. close();
  29. }
  30. EditorWindow* EditorWindow::create()
  31. {
  32. return EditorWindowManager::instance().create();
  33. }
  34. }