Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lists/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ pub(crate) use select::row_action;
pub(crate) use select::{Pick, picked};
pub use sortable::SortableList;
pub use swipe::{SwipeAction, SwipeableListItem};
pub use tree::{DropAt, Tree, TreeNode, TreeSelect};
pub use tree::{DropAt, Tree, TreeDrag, TreeNode, TreeSelect};
16 changes: 14 additions & 2 deletions src/lists/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,25 @@ struct Nav {
renaming: Option<SharedString>,
}

/// A drag of one tree's node, named by its owner.
pub(crate) struct TreeDrag {
/// A drag of one tree's node, named by its owner. A drop past the tree's rows takes it wherever the app listens for it.
pub struct TreeDrag {
owner: EntityId,
key: SharedString,
label: SharedString,
}

impl TreeDrag {
/// The dragged node's key.
pub fn key(&self) -> &SharedString {
&self.key
}

/// The dragged node's label.
pub fn label(&self) -> &SharedString {
&self.label
}
}

/// Nodes that open and close, drawn a row at a time so large trees stay quick. Right and Left open, close and climb; Up and Down walk; Enter opens a node or activates a leaf; F2 renames. With `multiple`, Cmd and Shift widen the pick. With `checked`, boxes check whole branches. Nodes drag before, after or into others. Give it a height.
#[derive(IntoElement)]
pub struct Tree {
Expand Down