pub trait MovableNode: Clone + 'static {
// Required methods
fn id(&self) -> i32;
fn x(&self) -> f32;
fn y(&self) -> f32;
fn selected(&self) -> bool;
fn set_x(&mut self, x: f32);
fn set_y(&mut self, y: f32);
// Provided method
fn draggable(&self) -> bool { ... }
}Expand description
Trait for nodes that can be moved (dragged) in the editor. This allows generic logic to update node positions.
selected is part of the contract because a drag commits the co-selected
set, not just the dragged node — and it must read that from the same place
the rendering does. The row already carries the flag (the editor renders it
from there); asking a separate set instead is what lets a drag’s visuals and
its commit disagree.
Rows that belong to groups also implement
GroupMember, which adds the membership.
Required Methods§
fn id(&self) -> i32
fn x(&self) -> f32
fn y(&self) -> f32
fn selected(&self) -> bool
fn set_x(&mut self, x: f32)
fn set_y(&mut self, y: f32)
Provided Methods§
Sourcefn draggable(&self) -> bool
fn draggable(&self) -> bool
Whether a drag of another selected node carries this one. Read it from
the field BaseNode.draggable is bound to, for the reason selected
is read from the row: the node previews its move from that property
and the commit reads this, so two sources would let a node stand still
under the drag and jump on release. A group that moves still carries
its members whatever this answers.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".