CmEditorWindow.cpp 4.3 KB

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