BsDropDownWindowManager.h 1.8 KB

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