BsGUIDockSlider.h 2.6 KB

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