CmEditorWindow.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 "BsGUIWindowFrameWidget.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->setSkin(&EngineGUI::instance().getSkin());
  48. titleBar->initialize(camera->getViewport().get(), mRenderWindow.get());
  49. titleBar->setDepth(127);
  50. GameObjectHandle<WindowFrameWidget> frame = so->addComponent<WindowFrameWidget>();
  51. frame->setSkin(&EngineGUI::instance().getSkin());
  52. frame->initialize(camera->getViewport().get(), mRenderWindow.get());
  53. frame->setDepth(129);
  54. //// DEBUG
  55. //GUIArea* dbgArea = GUIArea::create(*mGUI, 0, 13, 0, 0, 1998);
  56. //GUILayout& layout = dbgArea->getLayout();
  57. //
  58. //mDbgLabel = GUILabel::create(*mGUI, "Testing test");
  59. //layout.addElement(mDbgLabel);
  60. //GUIFlexibleSpace& space4 = otherLayout.addFlexibleSpace();
  61. //otherLayout.addElement(mDbgLabel);
  62. //GUIFixedSpace& space = otherLayout.addSpace(10); // Due to bug in MSVC compiler I need to store return value
  63. //GUIFlexibleSpace& space3 = otherLayout.addFlexibleSpace();
  64. //otherLayout.addElement(GUIWindowFrame::create(*mGUI, GUILayoutOptions::fixed(100, 100)));
  65. //GUIFixedSpace& space2 = otherLayout.addSpace(10);
  66. //otherLayout.addElement(GUIButton::create(*mGUI, "Test"));
  67. //otherLayout.addElement(GUIWindowFrame::create(*mGUI));
  68. //GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 2000);
  69. //backgroundArea->getLayout().addElement(GUITexture::create(*mGUI, GUILayoutOptions::expandableXY(), GUIImageScaleMode::RepeatToFit, mGUI->getSkin()->getStyle("WindowBackground")));
  70. //GUIArea* windowFrameArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 1999);
  71. //windowFrameArea->getLayout().addElement(GUIWindowFrame::create(*mGUI));
  72. //GUIArea* titleBarBackgroundArea = GUIArea::create(*mGUI, 0, 1, 0, 11, 1999);
  73. //titleBarBackgroundArea->getLayout().addSpace(1);
  74. //titleBarBackgroundArea->getLayout().addElement(GUITexture::create(*mGUI, GUIImageScaleMode::RepeatToFit, GUILayoutOptions::expandableXY(), mGUI->getGUISkin()->getStyle("TitleBarBg")));
  75. //titleBarBackgroundArea->getLayout().addSpace(1);
  76. mRenderWindow->resize(300, 250);
  77. }
  78. EditorWindow::~EditorWindow()
  79. {
  80. mRenderWindow->destroy();
  81. }
  82. void EditorWindow::update()
  83. {
  84. Int2 cursorPos = Cursor::getWindowPosition(*mRenderWindow);
  85. //mDbgLabel->setText("Position: " + toString(cursorPos.x) + ", " + toString(cursorPos.y));
  86. }
  87. }