#pragma once #include "BsCorePrerequisites.h" #include "BsModule.h" #include "BsRenderWindow.h" #include "BsEvent.h" namespace BansheeEngine { /** * @brief Handles creation and internal updates relating to render windows. * * @note Internal class. */ class BS_CORE_EXPORT RenderWindowManager : public Module { /** * @brief Holds a buffer that contains dirty data used for updating sim * thread render windows after changes on the core thread. */ struct DirtyPropertyData { UINT8* data; UINT32 size; }; public: RenderWindowManager(); ~RenderWindowManager(); /** * @brief Creates a new render window using the specified options. Optionally * makes the created window a child of another window. */ RenderWindowPtr create(RENDER_WINDOW_DESC& desc, RenderWindowPtr parentWindow); /** * @brief Called once per frame. Dispatches events. * * @note Internal method. */ void _update(); /** * @brief Called by the core thread when window is destroyed. */ void notifyWindowDestroyed(RenderWindow* window); /** * @brief Called by the core thread when window receives focus. */ void notifyFocusReceived(RenderWindowCore* window); /** * @brief Called by the core thread when window loses focus. */ void notifyFocusLost(RenderWindowCore* window); /** * @brief Called by the core thread when window is moved or resized. */ void notifyMovedOrResized(RenderWindowCore* window); /** * @brief Called by the core thread when window properties change. */ void notifyPropertiesDirty(RenderWindowCore* window); /** * @brief Returns a list of all open render windows. */ Vector getRenderWindows() const; /** * @brief Event that is triggered when a window gains focus. */ Event onFocusGained; /** * @brief Event that is triggered when a window loses focus. */ Event onFocusLost; /** * @brief Event that is triggered when mouse leaves a window. */ Event onMouseLeftWindow; protected: friend class RenderWindow; /** * @brief Called by the core thread when mouse leaves a window. */ void windowMouseLeft(RenderWindowCore* window); /** * @brief Finds a sim thread equivalent of the provided core thread window implementation. */ RenderWindow* getNonCore(const RenderWindowCore* window) const; /** * @brief Adds a new dirty property entry. */ void setDirtyProperties(RenderWindowCore* coreWindow); /** * @copydoc create */ virtual RenderWindowPtr createImpl(RENDER_WINDOW_DESC& desc, const RenderWindowPtr& parentWindow) = 0; protected: BS_MUTEX(mWindowMutex); Vector mCreatedWindows; Map mCoreToNonCoreMap; RenderWindow* mWindowInFocus; RenderWindow* mNewWindowInFocus; Vector mMovedOrResizedWindows; Vector mMouseLeftWindows; Map mDirtyProperties; }; /** * @brief Handles creation and internal updates relating to render windows. * * @note Core thread only. */ class BS_CORE_EXPORT RenderWindowCoreManager : public Module { public: /** * @copydoc RenderWindowCoreManager::create */ SPtr create(RENDER_WINDOW_DESC& desc); /** * @brief Returns a list of all open render windows. */ Vector getRenderWindows() const; protected: friend class RenderWindowCore; friend class RenderWindow; /** * @copydoc create */ virtual SPtr createInternal(RENDER_WINDOW_DESC& desc) = 0; /** * @brief Called whenever a window is created. */ void windowCreated(RenderWindowCore* window); /** * @brief Called by the core thread when window is destroyed. */ void windowDestroyed(RenderWindowCore* window); BS_MUTEX(mWindowMutex); Vector mCreatedWindows; }; }