BsGUIMouseEvent.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #include "BsGUIMouseEvent.h"
  2. namespace BansheeEngine
  3. {
  4. GUIMouseEvent::GUIMouseEvent()
  5. :mType(GUIMouseEventType::MouseMove), mButton(GUIMouseButton::Left),
  6. mShift(false), mCtrl(false), mAlt(false), mWheelScrollAmount(0.0f)
  7. {
  8. }
  9. GUIMouseEvent::GUIMouseEvent(bool buttonStates[(int)GUIMouseButton::Count], bool shift, bool ctrl, bool alt)
  10. :mType(GUIMouseEventType::MouseMove), mButton(GUIMouseButton::Left),
  11. mShift(shift), mCtrl(ctrl), mAlt(alt)
  12. {
  13. memcpy(mButtonStates, buttonStates, sizeof(mButtonStates));
  14. }
  15. void GUIMouseEvent::setMouseOverData(const Vector2I& position)
  16. {
  17. mType = GUIMouseEventType::MouseOver;
  18. mPosition = position;
  19. mButton = GUIMouseButton::Left;
  20. mDragAmount = Vector2I();
  21. mWheelScrollAmount = 0.0f;
  22. }
  23. void GUIMouseEvent::setMouseOutData(const Vector2I& position)
  24. {
  25. mType = GUIMouseEventType::MouseOut;
  26. mPosition = position;
  27. mButton = GUIMouseButton::Left;
  28. mDragAmount = Vector2I();
  29. mWheelScrollAmount = 0.0f;
  30. }
  31. void GUIMouseEvent::setMouseMoveData(const Vector2I& position)
  32. {
  33. mType = GUIMouseEventType::MouseMove;
  34. mPosition = position;
  35. mButton = GUIMouseButton::Left;
  36. mDragAmount = Vector2I();
  37. mWheelScrollAmount = 0.0f;
  38. }
  39. void GUIMouseEvent::setMouseWheelScrollData(float scrollAmount)
  40. {
  41. mType = GUIMouseEventType::MouseWheelScroll;
  42. mPosition = Vector2I();
  43. mButton = GUIMouseButton::Left;
  44. mDragAmount = Vector2I();
  45. mWheelScrollAmount = scrollAmount;
  46. }
  47. void GUIMouseEvent::setMouseUpData(const Vector2I& position, GUIMouseButton button)
  48. {
  49. mType = GUIMouseEventType::MouseUp;
  50. mPosition = position;
  51. mButton = button;
  52. mDragAmount = Vector2I();
  53. mWheelScrollAmount = 0.0f;
  54. }
  55. void GUIMouseEvent::setMouseDownData(const Vector2I& position, GUIMouseButton button)
  56. {
  57. mType = GUIMouseEventType::MouseDown;
  58. mPosition = position;
  59. mButton = button;
  60. mDragAmount = Vector2I();
  61. mWheelScrollAmount = 0.0f;
  62. }
  63. void GUIMouseEvent::setMouseDoubleClickData(const Vector2I& position, GUIMouseButton button)
  64. {
  65. mType = GUIMouseEventType::MouseDoubleClick;
  66. mPosition = position;
  67. mButton = button;
  68. mDragAmount = Vector2I();
  69. mWheelScrollAmount = 0.0f;
  70. }
  71. void GUIMouseEvent::setMouseDragData(const Vector2I& position, const Vector2I& dragAmount)
  72. {
  73. mType = GUIMouseEventType::MouseDrag;
  74. mPosition = position;
  75. mButton = GUIMouseButton::Left;
  76. mDragAmount = dragAmount;
  77. mWheelScrollAmount = 0.0f;
  78. }
  79. void GUIMouseEvent::setMouseDragStartData(const Vector2I& position)
  80. {
  81. mType = GUIMouseEventType::MouseDragStart;
  82. mPosition = position;
  83. mButton = GUIMouseButton::Left;
  84. mDragAmount = Vector2I();
  85. mWheelScrollAmount = 0.0f;
  86. }
  87. void GUIMouseEvent::setMouseDragEndData(const Vector2I& position)
  88. {
  89. mType = GUIMouseEventType::MouseDragEnd;
  90. mPosition = position;
  91. mButton = GUIMouseButton::Left;
  92. mDragAmount = Vector2I();
  93. mWheelScrollAmount = 0.0f;
  94. }
  95. void GUIMouseEvent::setDragAndDropDroppedData(const Vector2I& position, UINT32 dragTypeId, void* dragData)
  96. {
  97. mType = GUIMouseEventType::MouseDragAndDropDropped;
  98. mPosition = position;
  99. mButton = GUIMouseButton::Left;
  100. mDragAmount = Vector2I();
  101. mWheelScrollAmount = 0.0f;
  102. mDragTypeId = dragTypeId;
  103. mDragData = dragData;
  104. }
  105. void GUIMouseEvent::setDragAndDropDraggedData(const Vector2I& position, UINT32 dragTypeId, void* dragData)
  106. {
  107. mType = GUIMouseEventType::MouseDragAndDropDragged;
  108. mPosition = position;
  109. mButton = GUIMouseButton::Left;
  110. mDragAmount = Vector2I();
  111. mWheelScrollAmount = 0.0f;
  112. mDragTypeId = dragTypeId;
  113. mDragData = dragData;
  114. }
  115. }