| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #include "GUI/BsGUIMouseEvent.h" |
| 4 | |
| 5 | namespace bs |
| 6 | { |
| 7 | GUIMouseEvent::GUIMouseEvent(bool buttonStates[(int)GUIMouseButton::Count], bool shift, bool ctrl, bool alt) |
| 8 | :mType(GUIMouseEventType::MouseMove), mButton(GUIMouseButton::Left), mShift(shift), mCtrl(ctrl), mAlt(alt) |
| 9 | { |
| 10 | memcpy(mButtonStates, buttonStates, sizeof(mButtonStates)); |
| 11 | } |
| 12 | |
| 13 | void GUIMouseEvent::setMouseOverData(const Vector2I& position) |
| 14 | { |
| 15 | mType = GUIMouseEventType::MouseOver; |
| 16 | mPosition = position; |
| 17 | mButton = GUIMouseButton::Left; |
| 18 | mDragAmount = Vector2I(); |
| 19 | mDragStartPosition = Vector2I(); |
| 20 | mWheelScrollAmount = 0.0f; |
| 21 | } |
| 22 | |
| 23 | void GUIMouseEvent::setMouseOutData(const Vector2I& position) |
| 24 | { |
| 25 | mType = GUIMouseEventType::MouseOut; |
| 26 | mPosition = position; |
| 27 | mButton = GUIMouseButton::Left; |
| 28 | mDragAmount = Vector2I(); |
| 29 | mDragStartPosition = Vector2I(); |
| 30 | mWheelScrollAmount = 0.0f; |
| 31 | } |
| 32 | |
| 33 | void GUIMouseEvent::setMouseMoveData(const Vector2I& position) |
| 34 | { |
| 35 | mType = GUIMouseEventType::MouseMove; |
| 36 | mPosition = position; |
| 37 | mButton = GUIMouseButton::Left; |
| 38 | mDragAmount = Vector2I(); |
| 39 | mDragStartPosition = Vector2I(); |
| 40 | mWheelScrollAmount = 0.0f; |
| 41 | } |
| 42 | |
| 43 | void GUIMouseEvent::setMouseWheelScrollData(float scrollAmount) |
| 44 | { |
| 45 | mType = GUIMouseEventType::MouseWheelScroll; |
| 46 | mPosition = Vector2I(); |
| 47 | mButton = GUIMouseButton::Left; |
| 48 | mDragAmount = Vector2I(); |
| 49 | mDragStartPosition = Vector2I(); |
| 50 | mWheelScrollAmount = scrollAmount; |
| 51 | } |
| 52 | |
| 53 | void GUIMouseEvent::setMouseUpData(const Vector2I& position, GUIMouseButton button) |
| 54 | { |
| 55 | mType = GUIMouseEventType::MouseUp; |
| 56 | mPosition = position; |
| 57 | mButton = button; |
| 58 | mDragAmount = Vector2I(); |
| 59 | mDragStartPosition = Vector2I(); |
| 60 | mWheelScrollAmount = 0.0f; |
| 61 | } |
| 62 | |
| 63 | void GUIMouseEvent::setMouseDownData(const Vector2I& position, GUIMouseButton button) |
| 64 | { |
| 65 | mType = GUIMouseEventType::MouseDown; |
| 66 | mPosition = position; |
| 67 | mButton = button; |
| 68 | mDragAmount = Vector2I(); |
| 69 | mDragStartPosition = Vector2I(); |
| 70 | mWheelScrollAmount = 0.0f; |
| 71 | } |
| 72 | |
| 73 | void GUIMouseEvent::setMouseDoubleClickData(const Vector2I& position, GUIMouseButton button) |
| 74 | { |
| 75 | mType = GUIMouseEventType::MouseDoubleClick; |
| 76 | mPosition = position; |
| 77 | mButton = button; |
| 78 | mDragAmount = Vector2I(); |
| 79 | mDragStartPosition = Vector2I(); |
| 80 | mWheelScrollAmount = 0.0f; |
| 81 | } |
| 82 | |
| 83 | void GUIMouseEvent::setMouseDragData(const Vector2I& position, const Vector2I& dragAmount) |
| 84 | { |
| 85 | mType = GUIMouseEventType::MouseDrag; |
| 86 | mPosition = position; |
| 87 | mButton = GUIMouseButton::Left; |
| 88 | mDragAmount = dragAmount; |
| 89 | mDragStartPosition = Vector2I(); |
| 90 | mWheelScrollAmount = 0.0f; |
| 91 | } |
| 92 | |
| 93 | void GUIMouseEvent::setMouseDragStartData(const Vector2I& position, const Vector2I& dragStartPosition) |
| 94 | { |
| 95 | mType = GUIMouseEventType::MouseDragStart; |
| 96 | mPosition = position; |
| 97 | mButton = GUIMouseButton::Left; |
| 98 | mDragAmount = Vector2I(); |
| 99 | mDragStartPosition = dragStartPosition; |
| 100 | mWheelScrollAmount = 0.0f; |
| 101 | } |
| 102 | |
| 103 | void GUIMouseEvent::setMouseDragEndData(const Vector2I& position) |
| 104 | { |
| 105 | mType = GUIMouseEventType::MouseDragEnd; |
| 106 | mPosition = position; |
| 107 | mButton = GUIMouseButton::Left; |
| 108 | mDragAmount = Vector2I(); |
| 109 | mDragStartPosition = Vector2I(); |
| 110 | mWheelScrollAmount = 0.0f; |
| 111 | } |
| 112 | |
| 113 | void GUIMouseEvent::setDragAndDropDroppedData(const Vector2I& position, UINT32 dragTypeId, void* dragData) |
| 114 | { |
| 115 | mType = GUIMouseEventType::MouseDragAndDropDropped; |
| 116 | mPosition = position; |
| 117 | mButton = GUIMouseButton::Left; |
| 118 | mDragAmount = Vector2I(); |
| 119 | mDragStartPosition = Vector2I(); |
| 120 | mWheelScrollAmount = 0.0f; |
| 121 | mDragTypeId = dragTypeId; |
| 122 | mDragData = dragData; |
| 123 | } |
| 124 | |
| 125 | void GUIMouseEvent::setDragAndDropDraggedData(const Vector2I& position, UINT32 dragTypeId, void* dragData) |
| 126 | { |
| 127 | mType = GUIMouseEventType::MouseDragAndDropDragged; |
| 128 | mPosition = position; |
| 129 | mButton = GUIMouseButton::Left; |
| 130 | mDragAmount = Vector2I(); |
| 131 | mDragStartPosition = Vector2I(); |
| 132 | mWheelScrollAmount = 0.0f; |
| 133 | mDragTypeId = dragTypeId; |
| 134 | mDragData = dragData; |
| 135 | } |
| 136 | |
| 137 | void GUIMouseEvent::setDragAndDropLeftData(const Vector2I& position, UINT32 dragTypeId, void* dragData) |
| 138 | { |
| 139 | mType = GUIMouseEventType::MouseDragAndDropLeft; |
| 140 | mPosition = position; |
| 141 | mButton = GUIMouseButton::Left; |
| 142 | mDragAmount = Vector2I(); |
| 143 | mDragStartPosition = Vector2I(); |
| 144 | mWheelScrollAmount = 0.0f; |
| 145 | mDragTypeId = dragTypeId; |
| 146 | mDragData = dragData; |
| 147 | } |
| 148 | } |