pub struct GroupLogic;Expand description
Operations on group rows and node membership.
Implementations§
Source§impl GroupLogic
impl GroupLogic
Sourcepub fn moves<G: GroupModel>(group: &G, dragged: Dragged) -> bool
pub fn moves<G: GroupModel>(group: &G, dragged: Dragged) -> bool
Does this group row move with a drag that started on dragged?
Yes when its own sheet is being dragged, or when it is selected while a
node or another sheet is. This is the one movement rule: the commit
uses it for every group, and Self::group_moves answers the editor’s
live-preview question with it.
Sourcepub fn group_moves<G: GroupModel>(
groups: &impl Model<Data = G>,
group_id: i32,
dragged: Dragged,
) -> bool
pub fn group_moves<G: GroupModel>( groups: &impl Model<Data = G>, group_id: i32, dragged: Dragged, ) -> bool
Self::moves for a group looked up by id; unknown groups (and 0) do
not move. This is the predicate behind
NodeEditorComputations.group-in-drag; wire_groups! installs it.
Sourcepub fn moving_groups<G: GroupModel>(
groups: &impl Model<Data = G>,
dragged: Dragged,
) -> Vec<i32>
pub fn moving_groups<G: GroupModel>( groups: &impl Model<Data = G>, dragged: Dragged, ) -> Vec<i32>
The ids of the groups a drag moves.
Sourcepub fn commit_node_drag<T, G>(
nodes: &VecModel<T>,
groups: &impl Model<Data = G>,
dragged: Dragged,
delta_x: f32,
delta_y: f32,
)where
T: GroupMember,
G: GroupModel,
pub fn commit_node_drag<T, G>(
nodes: &VecModel<T>,
groups: &impl Model<Data = G>,
dragged: Dragged,
delta_x: f32,
delta_y: f32,
)where
T: GroupMember,
G: GroupModel,
Commit a finished drag into one node model.
A row moves if it is the dragged node, if it is selected and
draggable, or if it is a member of a group
that moves. A member keeps its place in a moving group whether or not
it is draggable: left behind, it would sit outside the sheet it still
belongs to. Call once per node model when nodes are split across
several; the dragged node lives in exactly one of them.
Sourcepub fn commit_group_drag<G: GroupModel>(
groups: &VecModel<G>,
dragged: Dragged,
delta_x: f32,
delta_y: f32,
)
pub fn commit_group_drag<G: GroupModel>( groups: &VecModel<G>, dragged: Dragged, delta_x: f32, delta_y: f32, )
Commit a finished drag into the group rows: every group that
Self::moves shifts by the delta. Call once per drag.
Sourcepub fn commit_drag<T, G>(
nodes: &VecModel<T>,
groups: &VecModel<G>,
dragged: Dragged,
delta_x: f32,
delta_y: f32,
)where
T: GroupMember,
G: GroupModel,
pub fn commit_drag<T, G>(
nodes: &VecModel<T>,
groups: &VecModel<G>,
dragged: Dragged,
delta_x: f32,
delta_y: f32,
)where
T: GroupMember,
G: GroupModel,
Commit a finished drag into one node model and the group rows.
The single-model convenience over Self::commit_node_drag and
Self::commit_group_drag: install it with
NodeEditorSetup::with_drag_commit
and both gestures share one rule.
Sourcepub fn is_collapsed<G: GroupModel>(
groups: &impl Model<Data = G>,
group_id: i32,
) -> bool
pub fn is_collapsed<G: GroupModel>( groups: &impl Model<Data = G>, group_id: i32, ) -> bool
Whether group_id is collapsed. Unknown groups are expanded. This is
the predicate behind NodeEditorComputations.group-collapsed.
Sourcepub fn set_collapsed<T, G>(
groups: &VecModel<G>,
nodes: &VecModel<T>,
group_id: i32,
collapsed: bool,
selected: impl Fn(&mut T) -> &mut bool,
) -> boolwhere
T: GroupMember,
G: GroupModel,
pub fn set_collapsed<T, G>(
groups: &VecModel<G>,
nodes: &VecModel<T>,
group_id: i32,
collapsed: bool,
selected: impl Fn(&mut T) -> &mut bool,
) -> boolwhere
T: GroupMember,
G: GroupModel,
Set a group’s collapsed state. Returns whether the row changed.
Collapsing deselects the members it hides, through the same row
projection every other selection write uses (selected is the row’s
flag, handed back by selected), so no later gesture acts on invisible
nodes. Expanding does not restore that selection. The sheet reacts to
the row change: members re-evaluate their visibility, and an active
drag is cancelled.
Sourcepub fn members<T: GroupMember>(
nodes: &impl Model<Data = T>,
group_id: i32,
) -> Vec<i32>
pub fn members<T: GroupMember>( nodes: &impl Model<Data = T>, group_id: i32, ) -> Vec<i32>
The ids of the nodes that belong to group_id, in row order.
Sourcepub fn selected_ungrouped<T: GroupMember>(
nodes: &impl Model<Data = T>,
) -> Vec<i32>
pub fn selected_ungrouped<T: GroupMember>( nodes: &impl Model<Data = T>, ) -> Vec<i32>
The selected nodes that belong to no group yet: the candidates for a new group. A node belongs to at most one group, so selected members of another group are left out rather than reassigned.
Sourcepub fn assign_members<T: GroupMember>(
nodes: &VecModel<T>,
node_ids: &[i32],
group_id: i32,
)
pub fn assign_members<T: GroupMember>( nodes: &VecModel<T>, node_ids: &[i32], group_id: i32, )
Make node_ids members of group_id, replacing any previous
membership. Unknown ids are ignored.
Sourcepub fn remove_member<T: GroupMember>(
nodes: &VecModel<T>,
node_id: i32,
) -> Option<i32>
pub fn remove_member<T: GroupMember>( nodes: &VecModel<T>, node_id: i32, ) -> Option<i32>
Take node_id out of its group. Returns the group it left, or None
if the node was unknown or ungrouped. The node stays where it is and no
longer moves with the group. When the group is now empty the caller
decides whether to keep or dissolve it (Self::members).
Sourcepub fn dissolve_group<T, G>(
nodes: &VecModel<T>,
groups: &VecModel<G>,
group_id: i32,
) -> boolwhere
T: GroupMember,
G: GroupModel,
pub fn dissolve_group<T, G>(
nodes: &VecModel<T>,
groups: &VecModel<G>,
group_id: i32,
) -> boolwhere
T: GroupMember,
G: GroupModel,
Dissolve a group: its members become ungrouped and stay where they are, and the row is removed. Returns whether a row was removed.
The sheet’s projected geometry is the editor’s: call
NodeEditorInternalCallbacks.remove-group(id) on the Slint side as
well, as for a removed node.
Sourcepub fn fit_bounds<N: NodeGeometry + Copy>(
cache: &GeometryCache<N>,
node_ids: &[i32],
padding: f32,
) -> Option<Bounds>
pub fn fit_bounds<N: NodeGeometry + Copy>( cache: &GeometryCache<N>, node_ids: &[i32], padding: f32, ) -> Option<Bounds>
The rectangle enclosing the cached rectangles of node_ids, grown by
padding on every side. None when none of them has geometry yet.
Sourcepub fn set_bounds<G: GroupModel>(
groups: &VecModel<G>,
group_id: i32,
bounds: Bounds,
) -> bool
pub fn set_bounds<G: GroupModel>( groups: &VecModel<G>, group_id: i32, bounds: Bounds, ) -> bool
Write bounds into a group row. Returns whether the row changed.
Sourcepub fn find_group<G: GroupModel>(
groups: &impl Model<Data = G>,
group_id: i32,
) -> Option<(usize, G)>
pub fn find_group<G: GroupModel>( groups: &impl Model<Data = G>, group_id: i32, ) -> Option<(usize, G)>
Find a group row by id.