pub struct Move<K: 'static> { /* private fields */ }Expand description
A native hierarchical tree (docs/tree.md): rows nest, disclose, and drag to a new parent.
The platform widget owns scrolling, disclosure and cell reuse; Day builds each visible row
once and rebinds it as cells recycle (list()’s contract, token-addressed). Gate its UI
on Cap::Tree: a backend without tree support renders nothing.
Drag-to-move for a tree (docs/tree.md): the handler that applies a committed
re-parent, an optional guard consulted while the drag is live, and whether the gesture is
offered right now. A tree is movable exactly when it carries one of these
(tree(..).movable(Move::new(f))). The list() counterpart is Reorder.
Implementations§
Source§impl<K: 'static> Move<K>
impl<K: 'static> Move<K>
Sourcepub fn new(moved: impl Fn(K, Option<K>, Option<usize>) + 'static) -> Move<K>
pub fn new(moved: impl Fn(K, Option<K>, Option<usize>) + 'static) -> Move<K>
moved(key, parent, index) runs after a committed move: key now sits under parent
(None = the root) at index (None = dropped onto the parent: append). Apply the
same re-parent to the backing data; its refresh reloads the tree. Runs at the next event
drain, never inside the native drop callback.
Sourcepub fn guard(
self,
g: impl Fn(&K, Option<&K>, Option<usize>) -> MoveVerdict + 'static,
) -> Move<K>
pub fn guard( self, g: impl Fn(&K, Option<&K>, Option<usize>) -> MoveVerdict + 'static, ) -> Move<K>
Veto drops while the drag is live. The structural refusals (a row into itself, into its own descendant, into a leaf) are built in; this guard adds the app’s own. Keep it pure: it runs inside the platform’s drag callback.
Sourcepub fn enabled<M>(self, on: impl IntoReactive<bool, M>) -> Move<K>
pub fn enabled<M>(self, on: impl IntoReactive<bool, M>) -> Move<K>
Whether the gesture is offered right now (default true): a constant or a reactive
bool, read when the platform asks whether a drag may begin.
Auto Trait Implementations§
impl<K> !RefUnwindSafe for Move<K>
impl<K> !Send for Move<K>
impl<K> !Sync for Move<K>
impl<K> !UnwindSafe for Move<K>
impl<K> Freeze for Move<K>
impl<K> Unpin for Move<K>
impl<K> UnsafeUnpin for Move<K>
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more