CmEditorWindow.cpp 2.0 KB

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