Module re_viewer_context::drag_and_drop

source ·
Expand description

Support for viewer-wide drag-and-drop of crate::Items.

§Theory of operation

§Setup

A DragAndDropManager should be created at the start of the frame and made available to the entire UI code.

§Initiating a drag

Any UI representation of an crate::Item may initiate a drag. crate::ViewerContext::handle_select_hover_drag_interactions will handle that automatically when passed true for its draggable argument.

§Reacting to a drag and accepting a drop

This part of the process is more involved and typically includes the following steps:

  1. When hovered, the receiving UI element should check for a compatible payload using [egui::DragAndDrop::payload] and matching one or more variants of the returned DragAndDropPayload, if any.

  2. If an acceptable payload type is being dragged, the UI element should provide appropriate visual feedback. This includes:

  3. If the mouse is released (using [egui::PointerState::any_released]), the payload must be actually transferred to the container and [egui::DragAndDrop::clear_payload] must be called.

Structs§

  • Helper to handle drag-and-drop operations.
  • Helper class to count item types and display them in a human-readable way.

Enums§

Functions§