BsRenderWindowManager.h 2.3 KB

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