BsMainEditorWindow.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "BsMainEditorWindow.h"
  2. #include "BsEditorWindowManager.h"
  3. #include "BsDockManager.h"
  4. #include "BsGUIMenuBar.h"
  5. #include "BsCamera.h"
  6. #include "BsSceneObject.h"
  7. #include "BsRenderTexture.h"
  8. #include "BsApplication.h"
  9. #include "BsProfilingManager.h"
  10. #include "BsGUIPanel.h"
  11. #include "BsGUILayout.h"
  12. #include "BsEditorTestSuite.h"
  13. #include "BsTestOutput.h"
  14. #include "BsVirtualInput.h"
  15. // DEBUG ONLY
  16. #include "BsTestTextSprite.h"
  17. #include "BsShapeMeshes2D.h"
  18. #include "BsShapeMeshes3D.h"
  19. #include "BsRect2.h"
  20. #include "BsProfilerOverlay.h"
  21. #include "BsPlatform.h"
  22. namespace BansheeEngine
  23. {
  24. MainEditorWindow* MainEditorWindow::create(const RenderWindowPtr& renderWindow)
  25. {
  26. return EditorWindowManager::instance().createMain(renderWindow);
  27. }
  28. MainEditorWindow::MainEditorWindow(const RenderWindowPtr& renderWindow)
  29. :EditorWindowBase(renderWindow), mDockManager(nullptr),
  30. mMenuBar(bs_new<GUIMenuBar>(mGUI.get(), mRenderWindow.get()))
  31. {
  32. mDockManager = DockManager::create(this);
  33. mGUI->getPanel()->addElement(mDockManager);
  34. updateAreas();
  35. mMenuBar->addMenuItem(L"File/New project", nullptr, 100);
  36. mMenuBar->addMenuItem(L"File/Open project", nullptr, 100);
  37. mMenuBar->addSeparator(L"File", 99);
  38. mMenuBar->addMenuItem(L"File/Exit", nullptr, 98);
  39. TestSuitePtr testSuite = TestSuite::create<EditorTestSuite>();
  40. testSuite->run(ExceptionTestOutput());
  41. }
  42. MainEditorWindow::~MainEditorWindow()
  43. {
  44. mDockManager->closeAll();
  45. GUIElement::destroy(mDockManager);
  46. bs_delete(mMenuBar);
  47. }
  48. void MainEditorWindow::resized()
  49. {
  50. EditorWindowBase::resized();
  51. updateAreas();
  52. }
  53. void MainEditorWindow::updateAreas()
  54. {
  55. UINT32 widgetWidth = (UINT32)std::max(0, (INT32)getWidth() - 2);
  56. UINT32 widgetHeight = (UINT32)std::max(0, (INT32)getHeight() - 2);
  57. UINT32 menuBarHeight = 15;
  58. mMenuBar->setArea(1, 1, widgetWidth, menuBarHeight);
  59. UINT32 dockHeight = (UINT32)std::max(0, (INT32)widgetHeight - (INT32)menuBarHeight);
  60. mDockManager->setArea(1, menuBarHeight + 1, widgetWidth, dockHeight);
  61. }
  62. void MainEditorWindow::update()
  63. {
  64. mDockManager->update();
  65. }
  66. }