drag-tree
Builds Icon Toggle ToggleGroup Tree


The code that drew it
A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.
fn drag_tree(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
dnd::stage(
StagedDrag::new(
DragItem::new("scene.drag.workspace", "kit", "gpui-kit").icon(Icon::Document),
)
.landing(
"scene.drag.workspace",
DropPosition::Into(SharedString::new_static("docs")),
None,
true,
),
cx,
);
stack(&theme)
.w(px(360.0))
.child(caption(&theme, "gpui-kit moving into docs"))
.child(
div()
.relative()
.child(
Tree::new("scene.drag.workspace")
.expanded_ids(&["workspace", "crates", "docs"])
.nodes([TreeNode::new("workspace", "workspace")
.icon(Icon::Folder)
.children([
TreeNode::new("crates", "crates")
.icon(Icon::Folder)
.children([
TreeNode::new("kit", "gpui-kit").icon(Icon::Document),
TreeNode::new("tokens", "gpui-kit-tokens")
.icon(Icon::Document),
]),
TreeNode::new("docs", "docs")
.icon(Icon::Folder)
.children([TreeNode::new("components", "components.md")
.icon(Icon::Document)]),
])])
.reorderable(true)
.on_toggle(|_, _, _, _| {})
.on_select(|_, _, _| {})
.on_move(|_, _, _| {}),
)
.children(
dnd::staged_ghost(cx)
.map(|ghost| div().absolute().left(px(212.0)).top(px(116.0)).child(ghost)),
),
)
.into_any_element()
}