BsEditorWindow.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. }
  14. EditorWindow::~EditorWindow()
  15. {
  16. cm_delete(mWidgets);
  17. }
  18. void EditorWindow::movedOrResized()
  19. {
  20. EditorWindowBase::movedOrResized();
  21. updateSize();
  22. }
  23. void EditorWindow::updateSize()
  24. {
  25. mWidgets->setPosition(1, 1);
  26. UINT32 widgetWidth = (UINT32)std::max(0, (INT32)getWidth() - 2);
  27. UINT32 widgetHeight = (UINT32)std::max(0, (INT32)getHeight() - 2);
  28. mWidgets->setSize(widgetWidth, widgetHeight);
  29. }
  30. void EditorWindow::widgetRemoved()
  31. {
  32. if(mWidgets->getNumWidgets() == 0)
  33. close();
  34. }
  35. EditorWindow* EditorWindow::create()
  36. {
  37. return EditorWindowManager::instance().create();
  38. }
  39. }