Skip to main content

StepEditor

Struct StepEditor 

Source
pub struct StepEditor { /* private fields */ }
Expand description

A step being edited: the operation’s editing state, and the editor’s own: which reference field waits for a click and what a click would pick for it, where the pointer is, what is being dragged. The step’s arguments are the program’s: every edit writes them back to it.

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 operation keeps the selection: it is sent the new one (Event::Select), and says what it is in its form (Form::selection).
  • A draggable visual is dragged in the plane worked in — or, where there is none, in the plane through where it was grabbed, facing the eye — as a CanvasEvent::Move; one dragged from where it was grabbed (see Visual::from_grab) is sent to the step as it was then, as the gizmo is. With a tool in hand that strokes, a drag from anywhere else is the tool’s, as a CanvasEvent::Stroke.
  • The form’s gizmo, if it has one, is drawn over everything and grabbed first: a drag of one of its parts is followed and snapped (see crate::editing::gizmo) and sent as a CanvasEvent::Gizmo, to the step as it was when it was pressed, so each event applies the whole drag once. A click on it does nothing, unless a field waits for a pick: then it picks what is under it. Where it has an orientation of its own, the dialog gets a GIZMO_ORIENTATION field to choose the world’s axes or its own.
  • Of what lies under the pointer, a hover lights and a click takes the one its Pointer::cycle names, front to back: what a reference field would hold of each counted once (see [candidates]), or each visual.
  • Escape, Enter and Delete mean the same in every tool, and reach it as CanvasEvent::Cancel, CanvasEvent::Confirm and CanvasEvent::Delete; any other key, lowercased, is a tool’s shortcut.

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.

An edit is made against the part as the last run left it: the editor runs the program again after each, for the step to be shown as it is now.

Implementations§

Source§

impl StepEditor

Source

pub fn new<'a>( editors: &Editors, runner: &Runner, part: impl Into<Against<'a>>, program: &Program, step: &str, new: bool, ) -> GeopResult<Self>

Editing the step step of program. 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) -> &str

The step edited, by id.

Source

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

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

Source

pub fn restart<'a>( &mut self, editors: &Editors, runner: &Runner, part: impl Into<Against<'a>>, program: &Program, ) -> GeopResult<()>

Starts the operation’s editing afresh, as for a step just opened — nothing picked for or dragged — after the step’s arguments were put back as an edit found them: undoing one. What the old editing state held may not be in the step any more. What is the user’s, not the operation’s, stays: the field waiting for a pick still waits, if the step still has it, and the gizmo stays turned as it was.

Source

pub fn form<'a>( &self, editors: &Editors, runner: &Runner, part: impl Into<Against<'a>>, program: &Program, ) -> GeopResult<Form>

The step’s form.

Source

pub fn at_rest(&self, form: &Form) -> bool

Whether nothing is in progress in form, the step’s form: no field waits for a pick, nothing is selected or dragged, no value is asked for in place, and the operation has no tool in hand — so Escape has nothing to end, and Enter nothing to finish, but the step itself (see crate::editor::Editor::handle).

Source

pub fn handle<Sc: Scene>( &mut self, e: Editing<'_, Sc>, event: &StepEditEvent, ) -> GeopResult<()>

Applies event, picking in e.scene: the part before the step as drawn, or, for an operation whose picks are made in what it builds, that.

Source

pub fn presentation<'a>( &self, editors: &Editors, runner: &Runner, part: impl Into<Against<'a>>, program: &Program, scene: &impl Scene, ) -> GeopResult<Presentation>

What to show: the step’s form, with its reference fields saying what they hold in scene — what they are picked from — 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 — and of the visuals, only the handles can be grabbed.

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.