Module dnd

Module dnd 

Source
Expand description

Flexible API for drag-and-drop and reordering.

  • Any UI widget or layout can be made draggable
  • Any UI widget or layout can be given a handle for dragging
  • Any UI widget or layout can be made a target for dragging
  • Any UI widget or layout can be made a target for reordering
  • Multiple separate drag-and-drop environments can coexist and even overlap in the same UI

§Examples

use hcegui::*;

let mut elements = vec!["point", "line", "plane", "space"];
let mut dnd = reorder::Dnd::new(ui.ctx(), ui.next_auto_id());
for (i, &elem) in elements.iter().enumerate() {
    dnd.reorderable_with_handle(ui, i, |ui, _| ui.label(elem));
}
if let Some(r) = dnd.finish(ui).if_done_dragging() {
    r.reorder_vec(&mut elements);
}

For more advanced examples, see bin/demo/reorder.rs.

Structs§

Dnd
Drag-and-drop environment.
DndMove
Drag-and-drop move.
DndStyle
Styling for Dnd.
ReorderHandle
Visual handle for dragging widgets.

Enums§

BeforeOrAfter
Whether the payload should be placed before or after the target.
DndResponse
Response from a drag-and-drop.

Type Aliases§

ReorderDnd
Drag-and-drop for reordering a sequence.
ReorderDndMove
Drag-and-drop move for reordering a sequence.