BsEditorWindowBase.h 3.2 KB

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