pub struct LinkManager<L, N = SimpleNodeGeometry> { /* private fields */ }Expand description
Manages links and their visual paths for the node editor.
LinkManager maintains a collection of links and automatically computes
their bezier path representations for rendering.
§Auto-Sync Mode
Use bind_model to enable automatic synchronization
to a Slint VecModel. After binding, every call to update_paths
automatically updates the Slint model.
This fragment assumes the generated LinkRow and window types from the
host’s Slint UI; the complete binding is application-specific.
let mut links = LinkManager::new(cache);
links.add(SimpleLink::new(1, start_pin, end_pin, color));
// Bind once - auto-syncs on every update_paths call
let model = Rc::new(VecModel::<LinkRow>::default());
links.bind_model(model.clone(), |id, path, color, line_width, status| LinkRow { id, path_commands: path, color, line_width, status });
window.set_link_paths(ModelRc::from(model));
// Now just call update_paths - model syncs automatically
links.update_paths(zoom);§Type Parameters
L: The link data type, must implementLinkModelN: The node geometry type used by the cache (default:SimpleNodeGeometry)
Implementations§
Source§impl<L, N> LinkManager<L, N>
impl<L, N> LinkManager<L, N>
Sourcepub fn new(cache: Rc<RefCell<GeometryCache<N>>>) -> Self
pub fn new(cache: Rc<RefCell<GeometryCache<N>>>) -> Self
Create a new LinkManager with the given geometry cache.
§Arguments
cache- Reference to the geometry cache for pin position lookups
Sourcepub fn bind_model<P, F>(&mut self, model: Rc<VecModel<P>>, constructor: F)
pub fn bind_model<P, F>(&mut self, model: Rc<VecModel<P>>, constructor: F)
Bind to a Slint model for automatic synchronization.
After binding, every call to Self::update_paths automatically
updates the Slint model.
§Arguments
model- The VecModel to sync toconstructor- Function to create path items from (id, path_commands, color, line_width, status)
Sourcepub fn add(&mut self, link: L)
pub fn add(&mut self, link: L)
Add a link to the manager.
The link’s visual path will be computed on the next call to Self::update_paths.
Sourcepub fn remove(&mut self, id: i32) -> bool
pub fn remove(&mut self, id: i32) -> bool
Remove a link by ID.
Returns true if a link was removed.
Sourcepub fn set_bezier_offset(&mut self, offset: f32)
pub fn set_bezier_offset(&mut self, offset: f32)
Set the bezier curve offset (default: 50.0).
This controls how curved the link paths are.
Sourcepub fn update_paths(&mut self, zoom: f32)
pub fn update_paths(&mut self, zoom: f32)
Update all link paths based on current pin positions.
Call this whenever:
- Pin positions change (node moved)
- Zoom level changes
- Links are added/removed
§Arguments
zoom- Current viewport zoom level