BsDropDownWindowManager.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsModule.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Handles opening and closing of a drop down window. Only a single drop down window
  8. * can be open at a time.
  9. */
  10. class BS_ED_EXPORT DropDownWindowManager : public Module <DropDownWindowManager>
  11. {
  12. public:
  13. DropDownWindowManager();
  14. ~DropDownWindowManager();
  15. /**
  16. * @brief Opens a new drop down window with the specified type and arguments.
  17. *
  18. * @param parent Render window parent in which to open the drop down window.
  19. * @param target Viewport parent in which to open the drop down window.
  20. * @param position Position relative to the viewport at which to open the drop down window.
  21. * @param ...args A set of arguments to be passed along to the drop down window constructor.
  22. *
  23. * @returns An instance of the newly created drop down window.
  24. *
  25. * @note This method will automatically close any existing drop down windows before opening
  26. * a new one.
  27. */
  28. template<class T, class... Args>
  29. T* open(const RenderWindowPtr& parent, Viewport* target,
  30. const Vector2I& position, Args &&...args)
  31. {
  32. close();
  33. mOpenWindow = bs_new<T>(parent, target, position, std::forward<Args>(args)...);
  34. return static_cast<T*>(mOpenWindow);
  35. }
  36. /**
  37. * @brief Closes a drop down window if one is open.
  38. */
  39. void close();
  40. /**
  41. * @brief To be called once per frame.
  42. *
  43. * @note Internal method.
  44. */
  45. void update();
  46. protected:
  47. DropDownWindow* mOpenWindow;
  48. };
  49. }