Skip to main content

SelectionSet

Struct SelectionSet 

Source
pub struct SelectionSet { /* private fields */ }

Implementations§

Source§

impl SelectionSet

Source

pub fn new() -> Self

Source

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.

Source

pub fn items(&self) -> &[Selection]

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, index: usize) -> Option<&Selection>

Source

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.

Source

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.

Source

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.

Source

pub fn measures(&self) -> &[Measure]

Source

pub fn add_measure(&mut self, measure: Measure)

Source

pub fn delete_measure(&mut self, index: usize) -> bool

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn add(&mut self, selection: Selection)

Source

pub fn delete(&mut self, index: usize) -> bool

Source

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.

Source

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.

Source

pub fn set_label(&mut self, index: usize, label: String) -> bool

Returns whether the label actually changed — committing the editor without edits records nothing.

Source

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.

Source

pub fn undo(&mut self) -> bool

Undo the most recent operation. Returns false when there is nothing to undo.

Source

pub fn redo(&mut self) -> bool

Re-apply the most recently undone operation. Returns false when there is nothing to redo — any new edit empties the redo branch.

Trait Implementations§

Source§

impl Debug for SelectionSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SelectionSet

Source§

fn default() -> SelectionSet

Returns the “default value” for a type. Read more

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.