BsHandleSliderManager.h 2.0 KB

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