CmEditorWindow.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #include "CmEditorWindow.h"
  2. #include "CmRenderWindow.h"
  3. #include "CmApplication.h"
  4. #include "CmSceneObject.h"
  5. #include "CmCursor.h"
  6. #include "BsGUIManager.h"
  7. #include "BsGUIWidget.h"
  8. #include "BsGUILabel.h"
  9. #include "BsGUIWindowFrame.h"
  10. #include "BsGUIButton.h"
  11. #include "BsGUITexture.h"
  12. #include "BsGUISkin.h"
  13. #include "BsGUILayout.h"
  14. #include "BsOverlayManager.h"
  15. #include "BsCamera.h"
  16. #include "BsUpdateCallback.h"
  17. #include "BsEngineGUI.h"
  18. #include "BsGUIArea.h"
  19. #include "BsGUITabbedTitleBar.h"
  20. using namespace CamelotFramework;
  21. using namespace BansheeEngine;
  22. namespace BansheeEditor
  23. {
  24. EditorWindow::EditorWindow(const String& name)
  25. {
  26. RENDER_WINDOW_DESC renderWindowDesc;
  27. renderWindowDesc.width = 200;
  28. renderWindowDesc.height = 200;
  29. renderWindowDesc.title = "EditorWindow";
  30. renderWindowDesc.fullscreen = false;
  31. renderWindowDesc.border = WindowBorder::None;
  32. renderWindowDesc.toolWindow = true;
  33. mRenderWindow = RenderWindow::create(renderWindowDesc, gApplication().getPrimaryWindow());
  34. HSceneObject so = SceneObject::create("EditorWindow-" + name);
  35. GameObjectHandle<UpdateCallback> updateCallback = so->addComponent<UpdateCallback>();
  36. updateCallback->onUpdate.connect(boost::bind(&EditorWindow::update, this));
  37. HCamera camera = so->addComponent<Camera>();
  38. camera->initialize(mRenderWindow, 0.0f, 0.0f, 1.0f, 1.0f, 0);
  39. camera->setNearClipDistance(5);
  40. camera->setAspectRatio(1.0f);
  41. camera->setIgnoreSceneRenderables(true);
  42. mGUI = so->addComponent<GUIWidget>();
  43. mGUI->initialize(camera->getViewport().get(), mRenderWindow.get());
  44. mGUI->setDepth(128);
  45. mGUI->setSkin(&EngineGUI::instance().getSkin());
  46. GameObjectHandle<TabbedTitleBar> titleBar = so->addComponent<TabbedTitleBar>();
  47. titleBar->initialize(camera->getViewport().get(), mRenderWindow.get());
  48. titleBar->setDepth(127);
  49. //// DEBUG
  50. GUIArea* dbgArea = GUIArea::create(*mGUI, 0, 13, 0, 0, 1998);
  51. GUILayout& layout = dbgArea->getLayout();
  52. mDbgLabel = GUILabel::create(*mGUI, "Testing test");
  53. layout.addElement(mDbgLabel);
  54. //GUIFlexibleSpace& space4 = otherLayout.addFlexibleSpace();
  55. //otherLayout.addElement(mDbgLabel);
  56. //GUIFixedSpace& space = otherLayout.addSpace(10); // Due to bug in MSVC compiler I need to store return value
  57. //GUIFlexibleSpace& space3 = otherLayout.addFlexibleSpace();
  58. //otherLayout.addElement(GUIWindowFrame::create(*mGUI, GUILayoutOptions::fixed(100, 100)));
  59. //GUIFixedSpace& space2 = otherLayout.addSpace(10);
  60. //otherLayout.addElement(GUIButton::create(*mGUI, "Test"));
  61. //otherLayout.addElement(GUIWindowFrame::create(*mGUI));
  62. GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 2000);
  63. backgroundArea->getLayout().addElement(GUITexture::create(*mGUI, GUILayoutOptions::expandableXY(), GUIImageScaleMode::RepeatToFit, mGUI->getSkin()->getStyle("WindowBackground")));
  64. GUIArea* windowFrameArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 1999);
  65. windowFrameArea->getLayout().addElement(GUIWindowFrame::create(*mGUI));
  66. //GUIArea* titleBarBackgroundArea = GUIArea::create(*mGUI, 0, 1, 0, 11, 1999);
  67. //titleBarBackgroundArea->getLayout().addSpace(1);
  68. //titleBarBackgroundArea->getLayout().addElement(GUITexture::create(*mGUI, GUIImageScaleMode::RepeatToFit, GUILayoutOptions::expandableXY(), mGUI->getGUISkin()->getStyle("TitleBarBg")));
  69. //titleBarBackgroundArea->getLayout().addSpace(1);
  70. }
  71. EditorWindow::~EditorWindow()
  72. {
  73. mRenderWindow->destroy();
  74. }
  75. void EditorWindow::update()
  76. {
  77. Int2 cursorPos = Cursor::getWindowPosition(*mRenderWindow);
  78. mDbgLabel->setText("Position: " + toString(cursorPos.x) + ", " + toString(cursorPos.y));
  79. }
  80. }