|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
State of a drag gesture on an entity: whether it is in progress, how far the pointer moved since the previous motion event, and the callbacks for its start, its moves and its end. More...
#include <headers/guillaume/components/drag_interaction.hpp>


Public Types | |
| using | DragStartHandler |
| Callback run when a drag starts. | |
| using | DragHandler |
| Called on each move. | |
| using | DragEndHandler |
| Callback run when a drag ends. | |
Public Member Functions | |
| DragInteraction (void)=default | |
| Construct a component with no drag in progress and no handler. | |
| ~DragInteraction (void)=default | |
| Default destructor. | |
| bool | isDragging (void) const |
| Check whether a drag is in progress. | |
| DragInteraction & | setDragging (bool dragging) |
| Record whether a drag is in progress. | |
| utility::math::Vector2F | getLastPosition (void) const |
| Get the pointer position at the last motion event of the drag. | |
| DragInteraction & | setLastPosition (const utility::math::Vector2F &position) |
| Record the pointer position the next delta is measured from. | |
| utility::math::Vector2F | getDelta (void) const |
| Get the movement of the pointer between the two last motion events of the drag. | |
| DragInteraction & | setDelta (const utility::math::Vector2F &delta) |
| Record the movement of the pointer since the previous motion event. | |
| DragInteraction & | setOnDragStartHandler (const DragStartHandler &handler) |
| Store the callback run when a drag starts. | |
| DragStartHandler | getOnDragStartHandler (void) const |
| Get the callback run when a drag starts. | |
| DragInteraction & | setOnDragHandler (const DragHandler &handler) |
| Store the callback run on each move of a drag. | |
| DragHandler | getOnDragHandler (void) const |
| Get the callback run on each move of a drag. | |
| DragInteraction & | setOnDragEndHandler (const DragEndHandler &handler) |
| Store the callback run when a drag ends. | |
| DragEndHandler | getOnDragEndHandler (void) const |
| Get the callback run when a drag ends. | |
| Public Member Functions inherited from guillaume::ecs::Component | |
| bool | hasChanged (void) const |
| Tell whether a value of the component changed since the flags were last reset (the end of the previous frame). | |
| void | setHasChanged (bool hasChanged) |
| Raise or lower the changed flag. | |
| Component (void)=default | |
| Create a component that is not marked as changed. | |
| virtual | ~Component (void)=default |
| Virtual destructor, so components can be destroyed through the base class. | |
State of a drag gesture on an entity: whether it is in progress, how far the pointer moved since the previous motion event, and the callbacks for its start, its moves and its end.
systems::Drag writes it in the Event phase, on the entities that have a DragInteraction, a Transform, a Bound, a MouseButtonInteraction and a HandButtonInteraction. A drag starts on the first mouse motion event received while the primary button (left mouse button or hand button A) is held on the entity, continues on every following motion event, and ends on the first motion event received after the button was released or the entity was disabled. systems::StyleState copies the dragging flag into StyleState::isDragged.
Positions and deltas are in the coordinates of the mouse motion event (view coordinates), not in dp. The delta is the movement between the two last motion events, not the distance since the start of the drag. Nothing happens in a frame without mouse motion event.
Definition at line 62 of file drag_interaction.hpp.
Callback run when a drag ends.
Definition at line 69 of file drag_interaction.hpp.
Called on each move.
Definition at line 67 of file drag_interaction.hpp.
Callback run when a drag starts.
Definition at line 65 of file drag_interaction.hpp.
| utility::math::Vector2F guillaume::components::DragInteraction::getDelta | ( | void | ) | const |
Get the movement of the pointer between the two last motion events of the drag.
Definition at line 54 of file drag_interaction.cpp.
| utility::math::Vector2F guillaume::components::DragInteraction::getLastPosition | ( | void | ) | const |
Get the pointer position at the last motion event of the drag.
Definition at line 42 of file drag_interaction.cpp.
| DragInteraction::DragEndHandler guillaume::components::DragInteraction::getOnDragEndHandler | ( | void | ) | const |
Get the callback run when a drag ends.
Definition at line 100 of file drag_interaction.cpp.
| DragInteraction::DragHandler guillaume::components::DragInteraction::getOnDragHandler | ( | void | ) | const |
Get the callback run on each move of a drag.
Definition at line 87 of file drag_interaction.cpp.
| DragInteraction::DragStartHandler guillaume::components::DragInteraction::getOnDragStartHandler | ( | void | ) | const |
Get the callback run when a drag starts.
Definition at line 75 of file drag_interaction.cpp.
| bool guillaume::components::DragInteraction::isDragging | ( | void | ) | const |
Check whether a drag is in progress.
Definition at line 27 of file drag_interaction.cpp.
| DragInteraction & guillaume::components::DragInteraction::setDelta | ( | const utility::math::Vector2F & | delta | ) |
Record the movement of the pointer since the previous motion event.
Called by systems::Drag, which then passes the same delta to the drag handler. Always marks the component changed.
| delta | The movement, in the coordinates of the mouse motion event. |
Definition at line 60 of file drag_interaction.cpp.

| DragInteraction & guillaume::components::DragInteraction::setDragging | ( | bool | dragging | ) |
Record whether a drag is in progress.
Called by systems::Drag; it calls no handler. Marks the component changed only when the flag differs.
| dragging | True when a drag is in progress. |
Definition at line 32 of file drag_interaction.cpp.

| DragInteraction & guillaume::components::DragInteraction::setLastPosition | ( | const utility::math::Vector2F & | position | ) |
Record the pointer position the next delta is measured from.
Called by systems::Drag. Does not mark the component changed.
| position | The pointer position, in the coordinates of the mouse motion event. |
Definition at line 47 of file drag_interaction.cpp.

| DragInteraction & guillaume::components::DragInteraction::setOnDragEndHandler | ( | const DragEndHandler & | handler | ) |
Store the callback run when a drag ends.
Does not mark the component changed.
| handler | The callback, or nullptr to remove the current one. |
Definition at line 93 of file drag_interaction.cpp.
| DragInteraction & guillaume::components::DragInteraction::setOnDragHandler | ( | const DragHandler & | handler | ) |
Store the callback run on each move of a drag.
It receives the movement since the previous motion event. It is not called for the motion event that starts the drag. Does not mark the component changed.
| handler | The callback, or nullptr to remove the current one. |
Definition at line 81 of file drag_interaction.cpp.
| DragInteraction & guillaume::components::DragInteraction::setOnDragStartHandler | ( | const DragStartHandler & | handler | ) |
Store the callback run when a drag starts.
Does not mark the component changed.
| handler | The callback, or nullptr to remove the current one. |
Definition at line 68 of file drag_interaction.cpp.