BsGUIDockSlider.h 2.5 KB

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