Skip to main content

Crate lumen_os_dnd

Crate lumen_os_dnd 

Source
Expand description

Drag-and-drop abstractions for Lumen.

Reuses the MimePayload type from [lumen-os-mime] so a single payload travels across both the clipboard and the DnD pipeline - mirrors QMimeData / GdkContentProvider.

In-app drag from a DragSource entity to a lumen-core::DropTarget is now wired end to end: begin_in_app_drag opens an ActiveDrag session on the drag-gesture threshold (fed by lumen-primitives::drag), track_drop_hover follows the pointer marking the hovered target with DropHovered, and finish_in_app_drag hit-tests the release point and emits DropAccepted. The inbound file-drop path continues to work unchanged via lumen-core::FileDropped / PendingFileDrops (translate_file_drops_to_payload). Cross-window drag-source via the platform (NSDraggingSession, DoDragDrop, wl_data_source/Xdnd) is deferred - winit exposes no source API today.

Mirrors: the source-publishes-mime -> target-negotiates-effect -> drop-carries-source+data shape of QDrag/QMimeData/dropEvent, and the HTML5 dragstart/dragenter/drop + dataTransfer event model (so the markup draggable / drop-target / on-drop surface maps 1:1 onto real DOM DnD when transpiled).

Re-exports§

pub use lumen_os_mime as mime;

Structs§

ActiveDrag
In-flight in-app drag session: the source entity, the payload it published at drag-start, and the effects it advertises. None when no drag gesture is active.
ActiveDragData
Payload of an in-flight ActiveDrag.
DndPlugin
Plugin: registers DnD messages + both the platform file-drop -> payload translator and the in-app drag-gesture -> drop pipeline.
DragSource
Marker / data component for an entity that can be the source of a drag-and-drop. Authored by the markup layer (<draggable mime=...> follow-up) or imperatively by the app.
DragStarted
Emitted when a drag starts on a DragSource entity (in-app gesture). Cross-window drag-source via the platform is deferred - see crate docs.
DropAccept
MIME-type filter declared on a [lumen_core::DropTarget] (extended by this crate). Drops are rejected when none of the configured kinds match the source payload.
DropAccepted
Emitted when the user releases the drag on a hovered drop target (in-app gesture).
DropEffectSet
Bitset of drop effects a source advertises or a target accepts.

Enums§

DropEffect
Single resolved drop effect (one bit of DropEffectSet).

Functions§

begin_in_app_drag
Open an ActiveDrag session and announce DragStarted when a drag gesture crosses the threshold on a DragSource entity. Mirrors QDrag::exec beginning a drag with the source’s QMimeData / HTML5 dragstart populating dataTransfer.
finish_in_app_drag
On the release edge of an active drag, hit-test the drop point and emit DropAccepted at the topmost accepting target - the in-app twin of translate_file_drops_to_payload. Mirrors Qt dropEvent carrying the source + QMimeData / HTML5 drop carrying dataTransfer.
track_drop_hover
While a drag is active, keep DropHovered on the topmost accepting DropTarget under the pointer (and off every other target). Mirrors HTML5 dragenter / dragleave so :drag-over styling follows the cursor.
translate_file_drops_to_payload
Translate inbound platform FileDropped events into DropAccepted when the target carries a DropAccept filter. Targets without a DropAccept keep the old “accept anything” behaviour, so apps/drop-target keeps working.