BsHandleSliderManager.h 2.3 KB

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