BsDropDownWindowManager.h 1.8 KB

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