CmEditorWindow.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 "BsGUISkin.h"
  12. #include "BsGUILayout.h"
  13. #include "BsOverlayManager.h"
  14. #include "BsCamera.h"
  15. #include "BsUpdateCallback.h"
  16. #include "BsEngineGUI.h"
  17. #include "BsGUIArea.h"
  18. using namespace CamelotFramework;
  19. using namespace BansheeEngine;
  20. namespace BansheeEditor
  21. {
  22. EditorWindow::EditorWindow(const String& name)
  23. {
  24. RENDER_WINDOW_DESC renderWindowDesc;
  25. renderWindowDesc.width = 200;
  26. renderWindowDesc.height = 200;
  27. renderWindowDesc.title = "EditorWindow";
  28. renderWindowDesc.fullscreen = false;
  29. renderWindowDesc.border = WindowBorder::None;
  30. renderWindowDesc.toolWindow = true;
  31. mRenderWindow = RenderWindow::create(renderWindowDesc, gApplication().getPrimaryWindow());
  32. HSceneObject so = SceneObject::create("EditorWindow-" + name);
  33. GameObjectHandle<UpdateCallback> updateCallback = so->addComponent<UpdateCallback>();
  34. updateCallback->onUpdate.connect(boost::bind(&EditorWindow::update, this));
  35. HCamera camera = so->addComponent<Camera>();
  36. camera->initialize(mRenderWindow, 0.0f, 0.0f, 1.0f, 1.0f, 0);
  37. camera->setNearClipDistance(5);
  38. camera->setAspectRatio(1.0f);
  39. camera->setIgnoreSceneRenderables(true);
  40. mGUI = so->addComponent<GUIWidget>();
  41. mGUI->initialize(camera->getViewport().get(), mRenderWindow.get());
  42. //// DEBUG
  43. mGUI->setSkin(&EngineGUI::instance().getSkin());
  44. //GUIArea* backgroundArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 0);
  45. //GUILayout& layout = backgroundArea->getLayout();
  46. mDbgLabel = GUILabel::create(*mGUI, "Testing test");
  47. /*layout.addElement(mDbgLabel);*/
  48. GUIArea* mainArea = GUIArea::create(*mGUI, 0, 0, 0, 0, 1);
  49. GUILayout& otherLayout = mainArea->getLayout();
  50. GUIFlexibleSpace& space4 = otherLayout.addFlexibleSpace();
  51. otherLayout.addElement(mDbgLabel);
  52. //GUIFixedSpace& space = otherLayout.addSpace(10); // Due to bug in MSVC compiler I need to store return value
  53. GUIFlexibleSpace& space3 = otherLayout.addFlexibleSpace();
  54. otherLayout.addElement(GUIWindowFrame::create(*mGUI, GUILayoutOptions::expandableX(20, 20)));
  55. //GUIFixedSpace& space2 = otherLayout.addSpace(10);
  56. otherLayout.addElement(GUIButton::create(*mGUI));
  57. //otherLayout.addElement(GUIWindowFrame::create(*mGUI));
  58. }
  59. EditorWindow::~EditorWindow()
  60. {
  61. mRenderWindow->destroy();
  62. }
  63. void EditorWindow::update()
  64. {
  65. Int2 cursorPos = Cursor::getWindowPosition(*mRenderWindow);
  66. mDbgLabel->setText("Position: " + toString(cursorPos.x) + ", " + toString(cursorPos.y));
  67. }
  68. }