BsDropDownWindow.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsVector2I.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief This is a generic GUI drop down window class that
  8. * can be used for displaying custom drop down content.
  9. */
  10. class BS_ED_EXPORT DropDownWindow
  11. {
  12. public:
  13. virtual ~DropDownWindow();
  14. /**
  15. * @brief Returns width of the window in pixels.
  16. */
  17. UINT32 getWidth() const { return mWidth; }
  18. /**
  19. * @brief Returns height of the window in pixels.
  20. */
  21. UINT32 getHeight() const { return mHeight; }
  22. /**
  23. * @brief Converts screen pointer coordinates into coordinates relative to the window contents GUI panel.
  24. */
  25. Vector2I screenToWindowPos(const Vector2I& screenPos) const;
  26. /**
  27. * @brief Converts pointer coordinates relative to the window contents GUI panel into screen coordinates.
  28. */
  29. Vector2I windowToScreenPos(const Vector2I& windowPos) const;
  30. /**
  31. * @brief Returns the GUI widget used for displaying all GUI contents in the window.
  32. */
  33. HGUIWidget getGUIWidget() const { return mGUI; }
  34. /**
  35. * @brief Changes the size of the drop down window area.
  36. *
  37. * @note This might reposition the window if the new size doesn't fit at the current position.
  38. */
  39. void setSize(UINT32 width, UINT32 height);
  40. /**
  41. * @brief Closes the drop down window.
  42. */
  43. void close();
  44. /**
  45. * @brief Called once every frame. Internal method.
  46. */
  47. virtual void update() { }
  48. protected:
  49. DropDownWindow(const RenderWindowPtr& parent, Viewport* target,
  50. const Vector2I& position, UINT32 width = 200, UINT32 height = 200);
  51. GUIPanel* mContents;
  52. private:
  53. friend class DropDropWindowManager;
  54. /**
  55. * @brief Triggered when the user clicks outside of the drop down area.
  56. */
  57. void dropDownFocusLost();
  58. RenderWindowPtr mRenderWindow;
  59. HSceneObject mSceneObject;
  60. HGUIWidget mGUI;
  61. GUIDropDownHitBox* mFrontHitBox;
  62. GUIDropDownHitBox* mBackHitBox;
  63. GUIPanel* mRootPanel;
  64. Vector2I mPosition;
  65. UINT32 mWidth;
  66. UINT32 mHeight;
  67. };
  68. }