Expand description
Drag primitive: threshold + state machine.
State per entity tracked via the DragState component:
Pending { start }- pointer pressed on entity, hasn’t moved past threshold yet.Active { start, last }- threshold crossed, drag is in progress.
Transitions:
(no state)
--(PointerPressed on Hovered)--> Pending
Pending
--(PointerMoved, dist > threshold)--> Active + DragStartEvent
--(PointerReleased)--> (no state)
Active
--(PointerMoved)--> Active + DragMoveEvent
--(PointerReleased)--> (no state) + DragEndEventThreshold is configured via DragConfig (default 4 px).
Reads PointerPressed from lumen-input::dispatch_clicks indirectly:
we look at entities that gain Pressed (so the existing dispatch
pipeline already filters to the hovered entity).
Structs§
- Drag
Config - Tunables for the drag recognizer.
- Drag
Plugin - Plugin: installs
DragConfigand registers the three drag systems. - Draggable
- Opt-in: entities with this marker have their
Transform::absolutetranslated by eachDragMoveEventdelta. Without this, drag events still fire but the entity stays put - apps that want different drag semantics (scrollbars, marquee selection) read DragMove themselves.
Enums§
- Drag
State - Per-entity drag state. Attached on Pressed insert, removed on release.
Constants§
- DEFAULT_
DRAG_ THRESHOLD_ PX - Default pixel threshold before a press graduates to a drag.
Functions§
- attach_
drag_ pending - On Pressed-without-DragState: attach
DragState::Pendingwith the current pointer position as the press anchor. - release_
drag_ on_ unpress - On Pressed -> not-Pressed: remove
DragState; if it wasActive, emitDragEndEventwith the final pointer position. - translate_
draggable - Generic system: every
DragMoveEventfor an entity carrying theDraggablemarker adds the delta to itsTransform::absolute. - update_
drag_ on_ move - Walk
PointerMovedevents: promote Pending -> Active when distance exceeds threshold; emitDragMoveEventwhile Active.