CmEditorWindow.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 "BsGUIScrollArea.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::createStretchedXY(*mGUI, 1, 1, 14, 2, 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. GUIScrollArea* scrollArea = GUIScrollArea::create(*mGUI);
  65. layout.addElement(scrollArea);
  66. GUILayout& scrollLayout = scrollArea->getLayout().addLayoutX();
  67. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test A"));
  68. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test B"));
  69. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test C"));
  70. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test D"));
  71. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test E"));
  72. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test F"));
  73. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test G"));
  74. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test H"));
  75. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test I"));
  76. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test J"));
  77. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test K"));
  78. scrollLayout.addElement(GUIButton::create(*mGUI, L"Test L"));
  79. //GUIFlexibleSpace& space4 = otherLayout.addFlexibleSpace();
  80. //otherLayout.addElement(mDbgLabel);
  81. //GUIFixedSpace& space = otherLayout.addSpace(10); // Due to bug in MSVC compiler I need to store return value
  82. //GUIFlexibleSpace& space3 = otherLayout.addFlexibleSpace();
  83. //otherLayout.addElement(GUIWindowFrame::create(*mGUI, GUILayoutOptions::fixed(100, 100)));
  84. //GUIFixedSpace& space2 = otherLayout.addSpace(10);
  85. //otherLayout.addElement(GUIButton::create(*mGUI, "Test"));
  86. //otherLayout.addElement(GUIWindowFrame::create(*mGUI));
  87. //GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 2000);
  88. //backgroundArea->getLayout().addElement(GUITexture::create(*mGUI, GUILayoutOptions::expandableXY(), GUIImageScaleMode::RepeatToFit, mGUI->getSkin()->getStyle("WindowBackground")));
  89. //GUIArea* windowFrameArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 1999);
  90. //windowFrameArea->getLayout().addElement(GUIWindowFrame::create(*mGUI));
  91. //GUIArea* titleBarBackgroundArea = GUIArea::create(*mGUI, 0, 1, 0, 11, 1999);
  92. //titleBarBackgroundArea->getLayout().addSpace(1);
  93. //titleBarBackgroundArea->getLayout().addElement(GUITexture::create(*mGUI, GUIImageScaleMode::RepeatToFit, GUILayoutOptions::expandableXY(), mGUI->getGUISkin()->getStyle("TitleBarBg")));
  94. //titleBarBackgroundArea->getLayout().addSpace(1);
  95. //mRenderWindow->resize(300, 250);
  96. //mRenderWindow->setVisible(false);
  97. }
  98. EditorWindow::~EditorWindow()
  99. {
  100. mRenderWindow->destroy();
  101. }
  102. void EditorWindow::update()
  103. {
  104. //Int2 cursorPos = Cursor::getWindowPosition(*mRenderWindow);
  105. //mDbgLabel->setText("Position: " + toString(cursorPos.x) + ", " + toString(cursorPos.y));
  106. }
  107. }