pub struct SortableList<'a> { /* private fields */ }Expand description
A vertical list of rows that can be reordered by dragging their grips.
§Interaction
- Press on a row’s grip to start dragging. The source row collapses out of layout and a ghost copy of the row floats under the cursor.
- Move the cursor — a sky-tinted slot opens at the predicted drop position, and the surrounding rows shift to reveal it.
- Release to commit the move. If the slot lands at the source’s own position the order is left untouched.
- Escape cancels the drag without reordering.
§State
Items are stored in a caller-owned Vec<SortableItem> passed by mutable
reference; the widget reorders the vec in place on a successful drop.
Transient drag state (origin, target, grab offset) lives in egui memory
keyed by the widget’s id_salt.
§Example
let mut items = vec![
SortableItem::new("api", "api-east-01")
.subtitle("10.0.1.5 · us-east-1")
.status("live", BadgeTone::Ok),
SortableItem::new("worker", "worker-pool-a")
.subtitle("24 instances · autoscale")
.status("idle", BadgeTone::Neutral),
];
SortableList::new("deployment-targets", &mut items).show(ui);Implementations§
Source§impl<'a> SortableList<'a>
impl<'a> SortableList<'a>
Sourcepub fn new(id_salt: impl Hash, items: &'a mut Vec<SortableItem>) -> Self
pub fn new(id_salt: impl Hash, items: &'a mut Vec<SortableItem>) -> Self
Create a sortable list.
id_salt— stable salt for this widget’s transient drag state. DifferentSortableListwidgets in the same window must use distinct salts.items— caller-owned list of rows. Reordered in place on drop.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for SortableList<'a>
impl<'a> RefUnwindSafe for SortableList<'a>
impl<'a> Send for SortableList<'a>
impl<'a> Sync for SortableList<'a>
impl<'a> Unpin for SortableList<'a>
impl<'a> UnsafeUnpin for SortableList<'a>
impl<'a> !UnwindSafe for SortableList<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more