BsHandleSliderManager.h 2.2 KB

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