BsDropDownWindow.h 2.1 KB

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