Skip to main content

GroupLogic

Struct GroupLogic 

Source
pub struct GroupLogic;
Expand description

Operations on group rows and node membership.

Implementations§

Source§

impl GroupLogic

Source

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.

Source

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.

Source

pub fn moving_groups<G: GroupModel>( groups: &impl Model<Data = G>, dragged: Dragged, ) -> Vec<i32>

The ids of the groups a drag moves.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn set_collapsed<T, G>( groups: &VecModel<G>, nodes: &VecModel<T>, group_id: i32, collapsed: bool, selected: impl Fn(&mut T) -> &mut bool, ) -> bool
where 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.

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn dissolve_group<T, G>( nodes: &VecModel<T>, groups: &VecModel<G>, group_id: i32, ) -> bool
where 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.

Source

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.

Source

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.

Source

pub fn find_group<G: GroupModel>( groups: &impl Model<Data = G>, group_id: i32, ) -> Option<(usize, G)>

Find a group row by id.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.