Skip to main content

StepEditor

Struct StepEditor 

Source
pub struct StepEditor<O, S: Scalar> { /* private fields */ }
Expand description

A step being edited: the step with its arguments as they now are, and the state of the edit — the operation’s session, and the editor’s own: what is selected, which reference field waits for a click and what a click would pick for it, where the pointer is, what is being dragged.

It turns every event into what the operation understands, the same for every operation:

  • A reference field (see Reference) is armed by pressing it, and then a click in the viewport picks for it — one entity, or, for a field of several, one more or one less. Removing one of its entities or clearing it is done here too. The operation is only ever sent what the field holds now, as Value::Entities.
  • A number field with a handle is dragged by it, snapped to DRAG_SNAP, and set as a Value::Number.
  • A click on a selectable visual selects it, or takes it out of the selection again; a click on nothing clears the selection, unless shift is held, and Escape clears it. The selection is the operation’s to read, and to change as its fields are used.
  • A draggable visual is dragged in the plane worked in, as a CanvasEvent::Move.

Whatever else the pointer and the keys do goes to the operation as a CanvasEvent: clicks while it has a tool in hand, and those on nothing, hovers, keys.

Implementations§

Source§

impl<O: Operations, S: Scalar> StepEditor<O, S>

Source

pub fn new(step: O, before: &Part<S>, new: bool) -> Self

Editing step against before. A new step whose first reference field is still empty starts by picking for it: what it is built on is what it needs first. One that already holds something — the newest sketch, say — needs no click, and leaves the pointer to the rest of the step: its handles, its drawing.

Source

pub fn step(&self) -> &O

The step, with its arguments as they now are.

Source

pub fn session(&self) -> &dyn Any

The operation’s session: its own, to look into.

Source

pub fn selection(&self) -> &[String]

The keys of the visuals selected.

Source

pub fn handle( &mut self, before: &Part<S>, view: &PartView<S>, event: &StepEditEvent<S>, )

Applies event — view is before as drawn, what picks test against.

Source

pub fn presentation(&self, before: &Part<S>) -> Presentation<S>

What to show: the step’s form, with its reference fields saying what they hold, the handles of its number fields, what is selected and what the pointer is over drawn so, what the reference fields hold and what a click would pick lit, and what a click picks now. While a field waits for a pick, there is no plane to work in: what can be picked is shown in the part as it stands.

Auto Trait Implementations§

§

impl<O, S> !RefUnwindSafe for StepEditor<O, S>

§

impl<O, S> !Send for StepEditor<O, S>

§

impl<O, S> !Sync for StepEditor<O, S>

§

impl<O, S> !UnwindSafe for StepEditor<O, S>

§

impl<O, S> Freeze for StepEditor<O, S>
where O: Freeze, S: Freeze,

§

impl<O, S> Unpin for StepEditor<O, S>
where O: Unpin, S: Unpin,

§

impl<O, S> UnsafeUnpin for StepEditor<O, S>
where O: UnsafeUnpin, S: UnsafeUnpin,

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.