BsDropDownWindow.h 2.3 KB

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