CmEditorWindow.cpp 4.2 KB

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