BsHandleSlider.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsVector2I.h"
  4. #include "BsMatrix4.h"
  5. #include "BsQuaternion.h"
  6. namespace BansheeEngine
  7. {
  8. class BS_ED_EXPORT HandleSlider
  9. {
  10. public:
  11. enum class State
  12. {
  13. Inactive,
  14. Active,
  15. Hover
  16. };
  17. HandleSlider(bool fixedScale, float snapValue);
  18. virtual ~HandleSlider() { }
  19. State getState() const { return mState; }
  20. bool getFixedScale() const { return mFixedScale; }
  21. float getSnapValue() const { return mSnapValue; }
  22. void setPosition(const Vector3& position);
  23. void setRotation(const Quaternion& rotation);
  24. void setScale(const Vector3& scale);
  25. const Vector3& getPosition() const { return mPosition; }
  26. const Quaternion& getRotation() const { return mRotation; }
  27. const Vector3& getScale() const { return mScale; }
  28. virtual const Matrix4& getTransform() const { return mTransform; }
  29. protected:
  30. friend class HandleManager;
  31. void setInactive() { mState = State::Inactive; }
  32. void setActive(const Vector2I& pointerPos) { mState = State::Active; mLastPointerPos = pointerPos; }
  33. void setHover() { mState = State::Hover; }
  34. void registerDrag(const Vector2I& pointerPos);
  35. float calcDelta(const HCamera& camera, const Vector3& position, const Vector3& direction,
  36. const Vector2I& pointerStart, const Vector2I& pointerEnd);
  37. bool mFixedScale;
  38. float mSnapValue;
  39. Vector3 mPosition;
  40. Quaternion mRotation;
  41. Vector3 mScale;
  42. Matrix4 mTransform;
  43. Vector2I mLastPointerPos;
  44. Vector2I mCurPointerPos;
  45. State mState;
  46. };
  47. }