BsEditorWindowBase.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsEvent.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief A base class for all editor window. Each editor window is backed by a render window
  8. * (e.g. the OS "window"), and also provides a GUI widget for child elements to use.
  9. * On top of that it also provides basic GUI like window background and frame, as well
  10. * as setting up the OS-specific areas for resize/move operations.
  11. */
  12. class BS_ED_EXPORT EditorWindowBase
  13. {
  14. public:
  15. virtual ~EditorWindowBase();
  16. /**
  17. * @brief Moves the window on the desktop. Coordinates are in screen space.
  18. */
  19. virtual void setPosition(INT32 x, INT32 y);
  20. /**
  21. * @brief Resizes the window.
  22. */
  23. virtual void setSize(UINT32 width, UINT32 height);
  24. /**
  25. * @brief Returns the X position of the window in screen coordinates.
  26. */
  27. INT32 getLeft() const;
  28. /**
  29. * @brief Returns the X position of the window in screen coordinates.
  30. */
  31. INT32 getTop() const;
  32. /**
  33. * @brief Returns the width of the window in pixels.
  34. */
  35. UINT32 getWidth() const;
  36. /**
  37. * @brief Returns the height of the window in pixels.
  38. */
  39. UINT32 getHeight() const;
  40. /**
  41. * @brief Closes and destroys the window.
  42. */
  43. virtual void close();
  44. /**
  45. * @brief Hides the window without closing it.
  46. */
  47. void hide();
  48. /**
  49. * @brief Return true if this is the main editor window.
  50. */
  51. virtual bool isMain() const { return false; }
  52. /**
  53. * @brief Called once every frame. Internal method.
  54. */
  55. virtual void update() { }
  56. /**
  57. * @brief Returns the render window that this editor window is being rendered to.
  58. */
  59. RenderWindowPtr getRenderWindow() const { return mRenderWindow; }
  60. /**
  61. * @brief Returns the GUI widget used for displaying all GUI contents in the window.
  62. */
  63. HGUIWidget getGUIWidget() const { return mGUI; }
  64. /**
  65. * @brief Returns the camera used for rendering the window GUI contents.
  66. */
  67. HCamera getGUICamera() const { return mCamera; }
  68. protected:
  69. EditorWindowBase(bool isModal = false);
  70. EditorWindowBase(const RenderWindowPtr& renderWindow);
  71. RenderWindowPtr mRenderWindow;
  72. HSceneObject mSceneObject;
  73. HGUIWidget mGUI;
  74. HCamera mCamera;
  75. GameObjectHandle<WindowFrameWidget> mWindowFrame;
  76. bool mOwnsRenderWindow;
  77. bool mIsModal;
  78. /**
  79. * @brief Common code for constructing the object to be called from all constructors.
  80. */
  81. void construct(const RenderWindowPtr& renderWindow);
  82. /**
  83. * @brief Initializes elements that cannot be initialized in the constructor. Must be called right after construction.
  84. */
  85. virtual void initialize();
  86. /**
  87. * @brief Callback that triggers whenever the underlying render window changes size.
  88. */
  89. virtual void resized() { }
  90. private:
  91. HEvent mResizedConn;
  92. };
  93. }