BsRenderWindowManager.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsModule.h"
  4. #include "BsRenderWindow.h"
  5. #include "BsEvent.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief Handles creation and internal updates relating to render windows.
  10. *
  11. * @note Sim thread.
  12. */
  13. class BS_CORE_EXPORT RenderWindowManager : public Module<RenderWindowManager>
  14. {
  15. public:
  16. RenderWindowManager();
  17. /**
  18. * @brief Creates a new render window using the specified options. Optionally
  19. * makes the created window a child of another window.
  20. */
  21. RenderWindowPtr create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow);
  22. /**
  23. * @brief Called once per frame. Dispatches events.
  24. *
  25. * @note Internal method.
  26. */
  27. void _update();
  28. /**
  29. * @brief Returns a list of all open render windows.
  30. */
  31. Vector<RenderWindow*> getRenderWindows() const;
  32. /**
  33. * @brief Event that is triggered when a window gains focus.
  34. */
  35. Event<void(RenderWindow&)> onFocusGained;
  36. /**
  37. * @brief Event that is triggered when a window loses focus.
  38. */
  39. Event<void(RenderWindow&)> onFocusLost;
  40. protected:
  41. friend class RenderWindow;
  42. /**
  43. * @copydoc create
  44. */
  45. virtual RenderWindowPtr createImpl(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow) = 0;
  46. /**
  47. * @brief Called by the core thread when window is destroyed.
  48. */
  49. void windowDestroyed(RenderWindow* window);
  50. /**
  51. * @brief Called by the core thread when window receives focus.
  52. */
  53. void windowFocusReceived(RenderWindow* window);
  54. /**
  55. * @brief Called by the core thread when window loses focus.
  56. */
  57. void windowFocusLost(RenderWindow* window);
  58. /**
  59. * @brief Called by the core thread when window is moved or resized.
  60. */
  61. void windowMovedOrResized(RenderWindow* window);
  62. protected:
  63. BS_MUTEX(mWindowMutex);
  64. Vector<RenderWindow*> mCreatedWindows;
  65. RenderWindow* mWindowInFocus;
  66. RenderWindow* mNewWindowInFocus;
  67. Vector<RenderWindow*> mMovedOrResizedWindows;
  68. };
  69. }