BsDropDownWindowManager.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 "Utility/BsModule.h"
  6. namespace bs
  7. {
  8. /** @addtogroup EditorWindow-Internal
  9. * @{
  10. */
  11. /** Handles opening and closing of a drop down window. Only a single drop down window can be open at a time. */
  12. class BS_ED_EXPORT DropDownWindowManager : public Module <DropDownWindowManager>
  13. {
  14. public:
  15. DropDownWindowManager();
  16. ~DropDownWindowManager();
  17. /**
  18. * Opens a new drop down window with the specified type and arguments.
  19. *
  20. * @param[in] parent Render window parent in which to open the drop down window.
  21. * @param[in] camera Camera in which to open the drop down window.
  22. * @param[in] position Position relative to the viewport at which to open the drop down window.
  23. * @param[in] ...args A set of arguments to be passed along to the drop down window constructor.
  24. * @return An instance of the newly created drop down window.
  25. *
  26. * @note This method will automatically close any existing drop down windows before opening a new one.
  27. */
  28. template<class T, class... Args>
  29. T* open(const SPtr<RenderWindow>& parent, const SPtr<Camera>& camera,
  30. const Vector2I& position, Args &&...args)
  31. {
  32. close();
  33. mOpenWindow = bs_new<T>(parent, camera, position, std::forward<Args>(args)...);
  34. return static_cast<T*>(mOpenWindow);
  35. }
  36. /** Closes a drop down window if one is open. */
  37. void close();
  38. /** To be called once per frame. Internal method. */
  39. void update();
  40. protected:
  41. DropDownWindow* mOpenWindow;
  42. };
  43. /** @} */
  44. }