pub struct NodeEditorSetup<F>{ /* private fields */ }Expand description
Setup helper that bundles NodeEditorController and automatic model updates.
This helper eliminates boilerplate by:
- Managing the controller lifecycle
- Calling your drag-commit closure automatically when a drag ends
The setup knows nothing about selection. A finished drag hands your closure
the node that was dragged, and committing it — including moving whatever
else is selected — is GraphLogic::commit_drag, which reads selected
off the model rows.
Implementations§
Source§impl NodeEditorSetup<Box<dyn Fn(i32, f32, f32)>>
impl NodeEditorSetup<Box<dyn Fn(i32, f32, f32)>>
Sourcepub fn with_drag_commit(
on_committed: impl Fn(Dragged, f32, f32) + 'static,
) -> Self
pub fn with_drag_commit( on_committed: impl Fn(Dragged, f32, f32) + 'static, ) -> Self
Create a setup helper with one drag commit for both gestures.
The closure receives what was dragged (Dragged::Node or
Dragged::Group) and the delta, once per finished drag. With
GroupLogic::commit_drag it
is the whole movement policy for a host with groups:
let setup = NodeEditorSetup::with_drag_commit(move |dragged, dx, dy| {
GroupLogic::commit_drag(&nodes, &groups, dragged, dx, dy)
});Source§impl<F> NodeEditorSetup<F>
impl<F> NodeEditorSetup<F>
Sourcepub fn new(on_drag_committed: F) -> Self
pub fn new(on_drag_committed: F) -> Self
Create a new setup helper with a drag-commit callback.
The callback receives (dragged_node_id, delta_x, delta_y) once, when a
node drag ends. This is the ONLY callback you need to provide - everything
else is handled internally.
Sourcepub fn on_group_drag_committed(
&self,
on_committed: impl Fn(i32, f32, f32) + 'static,
)
pub fn on_group_drag_committed( &self, on_committed: impl Fn(i32, f32, f32) + 'static, )
Install the commit for a finished group sheet drag, when the node and
group commits are separate closures. Self::with_drag_commit is the
usual way to get both from one rule.
Sourcepub fn controller(&self) -> &Rc<NodeEditorController>
pub fn controller(&self) -> &Rc<NodeEditorController>
Get the underlying controller for advanced operations.
Sourcepub fn report_node_rect(&self) -> impl Fn(i32, f32, f32, f32, f32) + 'static
pub fn report_node_rect(&self) -> impl Fn(i32, f32, f32, f32, f32) + 'static
Callback for NodeEditorInternalCallbacks.on_report_node_rect.
Sourcepub fn report_pin_position(
&self,
) -> impl Fn(i32, i32, i32, f32, f32, bool) + 'static
pub fn report_pin_position( &self, ) -> impl Fn(i32, i32, i32, f32, f32, bool) + 'static
Callback for NodeEditorInternalCallbacks.on_report_pin_position.
Sourcepub fn remove_node(&self) -> impl Fn(i32) + 'static
pub fn remove_node(&self) -> impl Fn(i32) + 'static
Callback for retiring a node and all of its projected pins.
Sourcepub fn remove_pin(&self) -> impl Fn(i32) + 'static
pub fn remove_pin(&self) -> impl Fn(i32) + 'static
Callback for retiring one projected pin.
Sourcepub fn reset_graph(&self) -> impl Fn() + 'static
pub fn reset_graph(&self) -> impl Fn() + 'static
Callback for clearing all projected graph state.
Sourcepub fn start_node_drag(&self) -> impl Fn(i32, bool, f32, f32) + 'static
pub fn start_node_drag(&self) -> impl Fn(i32, bool, f32, f32) + 'static
Callback for NodeEditorInternalCallbacks.on_start_node_drag.
Sourcepub fn cancel_node_drag(&self) -> impl Fn() + 'static
pub fn cancel_node_drag(&self) -> impl Fn() + 'static
Callback for a node drag cancelled before its normal end.
Sourcepub fn end_node_drag(&self) -> impl Fn(i32, f32, f32) + 'static
pub fn end_node_drag(&self) -> impl Fn(i32, f32, f32) + 'static
Callback for NodeEditorInternalCallbacks.on_end_node_drag.
Calls your drag-commit closure once, with the node the user dragged.
Sourcepub fn report_group_rect(&self) -> impl Fn(i32, f32, f32, f32, f32) + 'static
pub fn report_group_rect(&self) -> impl Fn(i32, f32, f32, f32, f32) + 'static
Callback for NodeEditorInternalCallbacks.on_report_group_rect.
Sourcepub fn remove_group(&self) -> impl Fn(i32) + 'static
pub fn remove_group(&self) -> impl Fn(i32) + 'static
Callback for retiring a group sheet’s projected rectangle.
Callback for NodeEditorInternalCallbacks.on_set_node_hidden.
Sourcepub fn start_group_drag(&self) -> impl Fn(i32, f32, f32) + 'static
pub fn start_group_drag(&self) -> impl Fn(i32, f32, f32) + 'static
Callback for NodeEditorInternalCallbacks.on_start_group_drag.
Sourcepub fn end_group_drag(&self) -> impl Fn(i32, f32, f32) + 'static
pub fn end_group_drag(&self) -> impl Fn(i32, f32, f32) + 'static
Callback for NodeEditorInternalCallbacks.on_end_group_drag.
Calls the group drag commit from Self::with_drag_commit or
Self::on_group_drag_committed, if any, once per finished sheet drag.