CmEditorWindow.cpp 2.2 KB

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