BsHandleSliderManager.h 2.2 KB

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