Expand description
A drag across windows, on the bus (ADR 0029).
egui keeps each window’s input apart. While the button is held, the system gives every pointer event to the window the drag began in (Wayland’s and X11’s implicit grab, the capture on Windows), whose pointer keeps following the drag past its edges; no other window sees the drag, nor the release. egui’s own drag payload lives in one window’s passes: it is gone before another window could take it.
A drag session carries any typed payload from the window it began in to the window it is let go over:
- the source starts it (
start), naming its kind;pop.drag.startis asked (DragStart), thendrag.startedsaid; - each pass, the drop targets say where they are, by window and by
id (
target): over one, the target shows where the payload would go (per-frame painting, the ADR’s exception: no event per pass); - while the drag lasts, every target that takes its payload is highlighted, wherever the pointer is, so the user sees where it may go; a target that refuses it is not, until hovered (then its outline says it refuses, with its reason);
- targets nest: a panel’s background and the rows or cells inside
it. Under the pointer, the most specific one wins, the smallest
that contains it (the last registered among equals), whatever the
order they were registered in: only that one sees the drag over it
(
Seen::Over) and takes the drop, as VS Code’s tree views resolve a drop by the element under the pointer, the view as the fallback (https://code.visualstudio.com/api/references/vscode-api#TreeDragAndDropController); - let go, the payload is delivered once, to the target under the
pointer: in the window it began in, or in another window, found from
the screen’s coordinates where the system tells where windows are;
where it hides them (Wayland), the first window that sees the pointer
over one of its targets once the drag lets it go takes it, within a
few passes. A delivery is
pop.drag.drop(DragDrop), thendrag.dropped; a target that refuses it says why, indrag.refusedwith its reason, as does a drag let go over no target and taken by nobody, or cancelled (Escape). A source handling a drop in its own window by itself (the workbench’s tabs into its areas) claims it (claim):drag.droppednames what took it.
The ghost. A source says what goes under the pointer (Ghost:
the first item’s thumbnail with the stack’s edges and a count, or an
object’s icon and name; start_with, set_ghost); a target the
drag hovers says what a drop would do (verdict: an Action
and its title) or refuses it (target’s refusal). The session
paints both at the end of each window’s pass, from the kit (the
drag-ghost, drag-ghost-count, drag-verdict and drop-target
components): the ghost beside the pointer, the verdict as a symbol on
its corner, the target’s outline, and in a tooltip the refusal’s
reason at once, the action’s title only after a short pause (symbols
first). The look follows established desktops: the stacked, counted
ghost of macOS’s Finder (Apple’s Human Interface Guidelines, “Drag
and drop”, https://developer.apple.com/design/human-interface-guidelines/drag-and-drop),
the symbol and verb under Windows Explorer’s ghost
(DROPDESCRIPTION, https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/ns-shlobj_core-dropdescription),
VS Code’s named list drags (https://code.visualstudio.com/api/references/vscode-api#TreeDragAndDropController)
and darktable’s dragged thumbnail (src/dtgtk/thumbtable.c,
https://github.com/darktable-org/darktable).
The workbench’s tabs and tab groups are carried by the session too, so their drags are said on the bus; their drop is the workbench’s dock space’s (egui_stack’s one drag across its windows), which ends the session where it lands it, or refuses it, at a dock of another window: a release the space took is never delivered to a target of the session, nor said twice.
Structs§
- Drag
Begin - A drag begins: its kind and the window it began in.
- Drag
Delivery - A drag let go over a target that takes it.
- Drag
Drop - A drag is delivered to a target (
pop.drag.drop): egui-pop’s listenerTARGETsays which, first. - Drag
Start - A drag begins (
pop.drag.start): its listeners are told, each saying what it did in the value. - Ghost
Shown - What a window last painted of a drag (
shown): its ghost, the verdict of the target it hovered (its id) and its hint, for tests and agents.
Enums§
- Action
- What a drop on a target would do, its symbol on the ghost.
- End
- How a drag ended, for its source (
ended). - Ghost
- What a drag carries under the pointer: its source says it when the
drag starts (
start_with,set_ghost); the session paints it. - Seen
- What a drop target sees of a drag of its payload type in a pass.
- Verdict
- What a target the drag hovers says of it, shown on the ghost.
Constants§
- DRAG_
POINTS - The drag points, in the order
super::order_dumpprints them. - TARGET
- egui-pop’s listener of
pop.drag.drop, first: the target that took it.
Functions§
- active
- Whether a drag is in progress (held, or let go and waiting for a window to take it).
- claim
- The source handled a drag let go over no target (
End::Left):whattook it (the workbench’s areas), said as the target ofdrag.dropped. - ended
- How the last drag of a
Tended, and its payload, while no other drag began: for its source, to handle a drop over no target itself. - paint_
ghost - Paints a drag’s ghost beside the pointer at
at, from the kit (itsdrag-ghost,drag-ghost-countanddrag-verdictcomponents), withverdict’s symbol on its corner; the rectangle it took. The session calls it each pass of the window the pointer is in; a page showing ghosts (a gallery) may call it too. - payload
- The payload of the drag in progress, when it is a
T. - set_
ghost - Gives the drag in progress its ghost (a source that knows it only once the drag started: its thumbnail loaded, its count known).
- shown
- The ghost the window being drawn (
ctx’s viewport) showed at the end of its last pass, while a drag is in progress;Noneonce it ended. - start
- Starts a drag of
payloadin the window being drawn (ctx’s viewport), askind: a source calls it when its drag starts (Response::drag_started). A drag still in progress is replaced. - start_
with - Starts a drag of
payloadasstartdoes,ghostunder the pointer while it lasts. - take_
ended - Takes how the last drag of a
Tended:ended, once. - target
- A drop target for a payload of type
T, in the window being drawn (ctx’s viewport), by itsid(unique in its window) and itsrect: what it sees of a drag this pass.refusalsays why it does not take a payload, asked each pass while one is dragged: a target that takes it is highlighted, wherever the pointer is. - verdict
- What a drop on the target
id(registered this pass bytarget, which returnedSeen::Over) would do, and its title: its symbol on the ghost at once, its title beside it after a short pause. A target that refuses the drag says why throughtarget’srefusal.