pub struct SelectionSet { /* private fields */ }Implementations§
Source§impl SelectionSet
impl SelectionSet
pub fn new() -> Self
Sourcepub fn seed(items: Vec<Selection>, measures: Vec<Measure>) -> Self
pub fn seed(items: Vec<Selection>, measures: Vec<Measure>) -> Self
A set pre-populated with existing selections — restoring a saved session. Seeding is not an edit: no undo history is created, so undo in a resumed session stops at the resume point instead of dismantling the session it reopened.
pub fn items(&self) -> &[Selection]
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get(&self, index: usize) -> Option<&Selection>
Sourcepub fn hit_topmost(&self, monitor: usize, p: Point) -> Option<usize>
pub fn hit_topmost(&self, monitor: usize, p: Point) -> Option<usize>
Topmost selection on monitor containing p (most recent wins),
respecting each selection’s rotation.
Sourcepub fn grab_topmost(
&self,
monitor: usize,
p: Point,
tolerance: i32,
) -> Option<(usize, GrabKind)>
pub fn grab_topmost( &self, monitor: usize, p: Point, tolerance: i32, ) -> Option<(usize, GrabKind)>
What a press at p grabs, topmost selection first: a border within
tolerance resizes, an interior moves. A shape’s border outranks
its own interior; a topmost shape outranks anything beneath it.
Sourcepub fn rotate(&mut self, index: usize, delta: i32) -> Option<i32>
pub fn rotate(&mut self, index: usize, delta: i32) -> Option<i32>
Rotate a selection by delta degrees about its bbox center; circles
are inherently rotation-free and are left untouched. Returns the new
rotation, or None if nothing changed.
pub fn measures(&self) -> &[Measure]
pub fn add_measure(&mut self, measure: Measure)
pub fn delete_measure(&mut self, index: usize) -> bool
Sourcepub fn grab_measure(
&self,
monitor: usize,
p: Point,
tolerance: i32,
) -> Option<(usize, MeasureGrab)>
pub fn grab_measure( &self, monitor: usize, p: Point, tolerance: i32, ) -> Option<(usize, MeasureGrab)>
Topmost measure on monitor that a press at p grabs — an
endpoint first, then the line itself. Most recent wins, as with
selections.
Sourcepub fn set_measure_line_live(&mut self, index: usize, line: Line)
pub fn set_measure_line_live(&mut self, index: usize, line: Line)
Update a measure mid-drag without recording history; pair with
commit_measure when the drag ends.
Sourcepub fn commit_measure(&mut self, index: usize, original: Line) -> bool
pub fn commit_measure(&mut self, index: usize, original: Line) -> bool
Record a finished measure edit. original is the line as it stood
when the drag began; a drag that ended where it started records
nothing and does not dirty the session.
Sourcepub fn label_measure(&mut self, index: usize, label: String) -> bool
pub fn label_measure(&mut self, index: usize, label: String) -> bool
Set a measure’s label. An unchanged label records nothing, the same rule the selection labels follow.
pub fn add(&mut self, selection: Selection)
pub fn delete(&mut self, index: usize) -> bool
Sourcepub fn set_shape_live(&mut self, index: usize, shape: Shape)
pub fn set_shape_live(&mut self, index: usize, shape: Shape)
Update a shape mid-drag without recording undo history; pair with
commit_move when the drag ends.
Sourcepub fn commit_move(&mut self, index: usize, original: Shape) -> bool
pub fn commit_move(&mut self, index: usize, original: Shape) -> bool
Record a completed move: original is the shape as it was when the
drag started. No-op if the shape ended up back where it began.
Returns whether the shape actually changed — a no-op move records
nothing and shouldn’t dirty the session.
Sourcepub fn set_label(&mut self, index: usize, label: String) -> bool
pub fn set_label(&mut self, index: usize, label: String) -> bool
Returns whether the label actually changed — committing the editor without edits records nothing.
Sourcepub fn cycle_at(&mut self, monitor: usize, p: Point) -> bool
pub fn cycle_at(&mut self, monitor: usize, p: Point) -> bool
Send the topmost shape under p to the bottom of the stack, so
the next grab reaches what was beneath it. Returns false when
fewer than two shapes are under the point. Stacking order is also
save order, so this is an undoable edit like any other.