BsHandleSliderManager.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. namespace BansheeEngine
  4. {
  5. /**
  6. * @brief Controls all instantiated HandleSlider%s.
  7. */
  8. class BS_ED_EXPORT HandleSliderManager
  9. {
  10. public:
  11. HandleSliderManager();
  12. ~HandleSliderManager();
  13. /**
  14. * @brief Updates all underlying sliders, changing their state and dragging them depending
  15. * on their state and pointer movement.
  16. *
  17. * @param camera Camera through which we're interacting with sliders.
  18. * @param inputPos Position of the pointer.
  19. * @param inputDelta Movement of the pointer since last frame.
  20. */
  21. void update(const CameraPtr& camera, const Vector2I& inputPos, const Vector2I& inputDelta);
  22. /**
  23. * @brief Attempts to select (activate) a slider at the specified position (if there is any).
  24. *
  25. * @param camera Camera through which we're interacting with sliders.
  26. * @param inputPos Position of the pointer.
  27. */
  28. void trySelect(const CameraPtr& camera, const Vector2I& inputPos);
  29. /**
  30. * @brief Clears the 0active slider (deactivates it).
  31. */
  32. void clearSelection();
  33. /**
  34. * @brief Checks is any slider active.
  35. */
  36. bool isSliderActive() const { return mActiveSlider != nullptr; }
  37. /**
  38. * @brief Registers a new instantiated slider.
  39. */
  40. void _registerSlider(HandleSlider* slider);
  41. /**
  42. * @brief Unregisters a previously instantiated slider.
  43. */
  44. void _unregisterSlider(HandleSlider* slider);
  45. private:
  46. /**
  47. * @brief Attempts to find slider at the specified position.
  48. *
  49. * @param camera Camera through which we're interacting with sliders.
  50. * @param inputPos Position of the pointer.
  51. *
  52. * @return Slider if we're intersecting with one, or null otherwise.
  53. */
  54. HandleSlider* findUnderCursor(const CameraPtr& camera, const Vector2I& inputPos) const;
  55. HandleSlider* mActiveSlider;
  56. HandleSlider* mHoverSlider;
  57. UnorderedSet<HandleSlider*> mSliders;
  58. };
  59. }