Skip to content

Spike: drag and drop (reorder, list to zone, OS files) before M5 #71

Closed

Description

@samitbasu

Decided (user, 2026-11-10): spike drag and drop before M5, so that scroll (M5) and overlays (M6) are shaped by what drag needs. The production DnD API is decided after the spike. Implementation of #33 and #23 is still unscheduled.

Scenarios the spike must run

  1. Reorder in todo (Drag to reorder (live reorder, ghost, Esc to cancel) #23): drag a row by its body. The list reorders live as the pointer crosses rows, and siblings slide with Animate position changes of keyed nodes (FLIP) #30 animate_layout. A drag image follows the pointer. Esc restores the original order. Releasing outside the list cancels.
  2. List to zone (Drag and drop: drag sources, drop targets, OS file drops routed to nodes #33, in-app): drag an item from one list onto a drop zone. The zone shows hover feedback while a compatible payload is over it, and receives the drop with its position inside the zone. An incompatible payload type shows no feedback.
  3. OS file drop (Drag and drop: drag sources, drop targets, OS file drops routed to nodes #33): drag files from the desktop onto one of two zones. The hovered zone shows a hint, and each zone accepts or refuses by file type. Native only; check whether the web build gets drops.

Questions the spike must answer (in a design note, docs/dnd.md)

  • Can egui's DnD payload API (Response::dnd_set_drag_payload, dnd_hover_payload, dnd_release_payload, egui::DragAndDrop) carry all three scenarios, or what's missing?
  • Build-time state: how does the view read "what is being dragged and over what" during build, to render gaps, placeholders and highlights? One frame of lag is acceptable or not; say which and why.
  • Identity across rebuilds: does egui keep the drag when the source node is rebuilt elsewhere (live reorder)? What does bullseye have to guarantee: stable ids, a sense on the node, never inert?
  • Hit-testing targets: layout rect versus painted rect under FLIP; nested targets; which one wins (encode once, per CLAUDE.md).
  • The drag image: paint the source's shapes under the pointer (the ghost mechanism of Exit transitions: animate a keyed node out before it leaves the tree #35), or a separate chip? What's the cheapest that works?
  • Scroll (M5): auto-scroll near the edges of a scroll container during a drag, and wheel during a drag. What M5 must expose.
  • Overlays (M6): drag over and onto popovers and sheets; the z-order of the drag image.
  • Keyboard: a non-pointer way to reorder (e.g. move with modifier+arrows), and whether accesskit has a DnD story.
  • Cancel: Esc, release outside, and the window losing focus.
  • The core changes needed, if any (an active-gesture model, a new paint variant drag_over, NodeHandle methods). List them with the reason for each.

Output

  • A branch with spike code (not merged as-is) and the design note, opened as a draft PR for review.
  • The note ends with a proposed API sketch and a list of the issues to file (production DnD, M5 and M6 requirements).

Activity

  1. samitbasu commented on Nov 10, 2026

    @samitbasu
    OwnerAuthor

    Scope addition (user, 2026-11-10): a gallery scenario, as an example plus tests.

    1. Gallery reorder: a wrapping grid of equal-width square panels.
      • Drag a panel to reorder it in two dimensions: as the pointer crosses panels, the order changes and panels reflow across rows, sliding with Animate position changes of keyed nodes (FLIP) #30 animate_layout.
      • Drag image: a ghost is preferred, meaning the panel's own painted shapes following the pointer (the Exit transitions: animate a keyed node out before it leaves the tree #35 mechanism). A placeholder div in the gap is the acceptable fallback. The spike reports which it reached and what the ghost needed.
      • Drop from outside (OS files) into the gallery inserts a new panel at the position under the pointer, with the same insertion indicator or gap as an in-app drag.
      • Required: drag and drop within the app, and drops into the app from outside. Not needed: dragging out of the app.

    Tests through the real harness path:

    • a 2D reorder across a row boundary gives the expected order;
    • panels' layout rects are final while their painting animates;
    • the insertion index from a drop position;
    • Esc cancels;
    • the outside-drop insertion index, simulated through RawInput::hovered_files / dropped_files if the harness allows it, otherwise said plainly.
  2. samitbasu commented on Nov 10, 2026

    @samitbasu
    OwnerAuthor

    Real use case (user, 2026-11-10): the gallery stands for telemetry windows in 1, 2 or 3 columns, inside a scroll area. That makes scenario 4:

    • Columns: a grid of equal-width panels whose column count is 1, 2 or 3, chosen by the app and/or by the available width. Changing the count reflows the panels, which should slide with animate_layout too. That is the same relative-to-parent rule.
    • Inside a scroll area taller than the viewport. bullseye has no scroll container yet (M5). The spike builds the minimum needed to learn the requirements: a vertical clip plus a scroll offset in egui memory plus the wheel, or egui's ScrollArea hosting the bullseye subtree if that's cleaner. It records what M5 must provide. It is not M5.
    • Questions this adds (answer in docs/dnd.md):
      • Auto-scroll while dragging near the top or bottom edge: speed, and whether it is the scroll container's job or the drag's.
      • The wheel during a drag.
      • The insertion index in content coordinates, i.e. pointer plus scroll offset.
      • FLIP measured against the scrolled content origin, so scrolling doesn't animate (Nested scrolling and scroll chaining #55's note).
      • The ghost painted above the scroll clip, so it can be dragged past the viewport edge.
      • A drop from outside onto a part of the list that is scrolled out of view, via auto-scroll.
  3. samitbasu commented on Nov 10, 2026

    @samitbasu
    OwnerAuthor

    The spike's four one-frame glitches led to #76 (frame-continuity checker, sweeps and fuzzing, design rules).

  4. samitbasu commented on Nov 10, 2026

    @samitbasu
    OwnerAuthor

    Native check (user, 2026-11-10), Fedora on Wayland: dragging a .png from the file manager onto dnd_gallery produced no reaction at all: no hover gap and no drop.

    Cause, verified in source: winit 0.30.13 (bullseye's version through eframe) delivers HoveredFile/DroppedFile only from its X11 backend (platform_impl/linux/x11/event_processor.rs). The Wayland backend has no file drag-and-drop, so nothing reaches egui. Not a bullseye bug.

    Pending: a re-run under XWayland (env -u WAYLAND_DISPLAY cargo run --release --example dnd_gallery) to see whether X11 delivers the drop, and whether a live position follows the cursor during an outside drag.

    Options for the requirement "drops into the app":

    • run under XWayland on Linux;
    • track winit's Wayland DnD upstream;
    • add a file-picker fallback (e.g. rfd via the desktop portal), which works everywhere.

    The production DnD design must state per-platform behaviour.

  5. samitbasu commented on Nov 10, 2026

    @samitbasu
    OwnerAuthor

    Correction and upstream status: winit 0.31 (beta) reworks file DnD into DragEntered/DragMoved/DragDropped/DragLeft, with the pointer position (v0.31.0-beta.1 release notes). winit #4571 (merged 2026-07-16) implements receiving and initiating drags on Windows, Wayland and macOS. bullseye is on 0.30.13 through eframe, so it doesn't have this. Per third-party reports (unverified): eframe's winit 0.31 migration is a draft (emilk/egui#7731), and a 0.30.x Wayland backport (#4729) is open.

    Consequence for the design: design outside drops against 0.31's event model, which supplies a live position on all platforms. Adopt it when eframe moves (CLAUDE.md: migrate first, don't build on the deprecated surface). In-app DnD doesn't depend on winit and can proceed now.

  6. samitbasu commented on Nov 10, 2026

    @samitbasu
    OwnerAuthor

    macOS check (user, 2026-11-10): dragging a .png from Finder onto dnd_gallery shows the drag cursor. On drop, a new panel is appended at the end of the list. winit 0.30 delivers the drop on macOS but no pointer position during the hover or at the drop, so the shared insertion resolver gets no point and falls back to the end. There is no hover gap.

    Summary on winit 0.30: macOS delivers the drop without a position; Linux/Wayland delivers nothing; X11 delivers the drop without a position (per source); the web delivers no position. Positioned outside drops therefore need winit 0.31's DragMoved/DragDropped (#78) on every platform.

    Spike follow-up: the demo failed silently: the panel appended off-screen, and app.dropped is never shown. A status line and scroll-into-view are proposed.

  7. samitbasu commented on Nov 10, 2026

    @samitbasu
    OwnerAuthor

    Correction to the macOS result (user retried, 2026-11-10): the drop does insert the new panel where the cursor is released. What's missing is the live preview while hovering: no gap follows the cursor, the panel just appears on release. The first tries appended at the end, most likely drops where no fresh pointer position had arrived yet.

    Corrected summary on winit 0.30:

    • macOS: drop delivered with a usable position at release; no position during the hover, so no live gap.
    • Linux/Wayland: nothing delivered.
    • X11: drop delivered (per source); hover position unverified.
    • Web: no position.

    #78 (winit 0.31 DragMoved) is what adds the live preview everywhere, and Wayland support.

  8. samitbasu commented on Nov 11, 2026

    @samitbasu
    OwnerAuthor

    Spike complete. Its findings are in docs/dnd.md on main; production landed in #87.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions