BsGUIDockSlider.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUIButtonBase.h"
  4. #include "BsDockManager.h"
  5. #include "BsEvent.h"
  6. namespace BansheeEngine
  7. {
  8. /**
  9. * @brief GUI element used by the dock manager to display a slider between
  10. * two different dock containers. The slider can be vertical or horizontal
  11. * and will process and report mouse drag events.
  12. *
  13. * @note It's up to the caller to actually handle the drag events.
  14. */
  15. class GUIDockSlider : public GUIButtonBase
  16. {
  17. public:
  18. /**
  19. * Returns type name of the GUI element used for finding GUI element styles.
  20. */
  21. static const String& getGUITypeName();
  22. /**
  23. * @brief Creates a new GUI dock slider element.
  24. *
  25. * @param horizontal Should the slider be rendered horizontal or vertical.
  26. * @param styleName Optional style to use for the element. Style will be retrieved
  27. * from GUISkin of the GUIWidget the element is used on. If not specified
  28. * default style is used.
  29. */
  30. static GUIDockSlider* create(bool horizontal, const String& styleName = StringUtil::BLANK);
  31. /**
  32. * @brief Creates a new GUI dock slider element.
  33. *
  34. * @param horizontal Should the slider be rendered horizontal or vertical.
  35. * @param options Options that allow you to control how is the element positioned and sized.
  36. * This will override any similar options set by style.
  37. * @param styleName Optional style to use for the element. Style will be retrieved
  38. * from GUISkin of the GUIWidget the element is used on. If not specified
  39. * default style is used.
  40. */
  41. static GUIDockSlider* create(bool horizontal, const GUIOptions& options, const String& styleName = StringUtil::BLANK);
  42. Event<void(const Vector2I&)> onDragged; /**< Triggered while the user is dragging the slider (pointer down and being moved) */
  43. protected:
  44. /**
  45. * @copydoc GUIButtonBase::_mouseEvent
  46. */
  47. virtual bool _mouseEvent(const GUIMouseEvent& ev) override;
  48. /**
  49. * @copydoc GUIButtonBase::_hasCustomCursor
  50. */
  51. bool _hasCustomCursor(const Vector2I position, CursorType& type) const override;
  52. private:
  53. Vector2I mLastDragPosition;
  54. bool mHorizontal;
  55. bool mIsCursorSet;
  56. bool mDragInProgress;
  57. GUIDockSlider(bool horizontal, const String& styleName, const GUIDimensions& dimensions);
  58. };
  59. }