27#include <utility/math/vector.hpp>
29#include "guillaume/ecs/component.hpp"
66 std::function<void(
void)>;
68 const utility::math::Vector2F &)>;
70 std::function<void(
void)>;
73 bool _dragging {
false };
74 utility::math::Vector2F _lastPosition {
77 utility::math::Vector2F _delta {
140 utility::math::Vector2F
getDelta(
void)
const;
DragEndHandler getOnDragEndHandler(void) const
Get the callback run when a drag ends.
DragHandler getOnDragHandler(void) const
Get the callback run on each move of a drag.
std::function< void( const utility::math::Vector2F &)> DragHandler
Called on each move.
DragInteraction & setOnDragStartHandler(const DragStartHandler &handler)
Store the callback run when a drag starts.
DragInteraction & setOnDragEndHandler(const DragEndHandler &handler)
Store the callback run when a drag ends.
DragInteraction(void)=default
Construct a component with no drag in progress and no handler.
DragInteraction & setLastPosition(const utility::math::Vector2F &position)
Record the pointer position the next delta is measured from.
DragStartHandler getOnDragStartHandler(void) const
Get the callback run when a drag starts.
bool isDragging(void) const
Check whether a drag is in progress.
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.
std::function< void(void)> DragStartHandler
Callback run when a drag starts.
utility::math::Vector2F getLastPosition(void) const
Get the pointer position at the last motion event of the drag.
DragInteraction & setOnDragHandler(const DragHandler &handler)
Store the callback run on each move of a drag.
~DragInteraction(void)=default
Default destructor.
DragInteraction & setDragging(bool dragging)
Record whether a drag is in progress.
std::function< void(void)> DragEndHandler
Callback run when a drag ends.
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
State. Every class here is plain data attached to an entity.