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 aValue::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 (seeVisual::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 aCanvasEvent::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 aCanvasEvent::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 aGIZMO_ORIENTATIONfield 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::cyclenames, 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::ConfirmandCanvasEvent::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
impl StepEditor
Sourcepub fn new<'a>(
editors: &Editors,
runner: &Runner,
part: impl Into<Against<'a>>,
program: &Program,
step: &str,
new: bool,
) -> GeopResult<Self>
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.
Sourcepub fn restart<'a>(
&mut self,
editors: &Editors,
runner: &Runner,
part: impl Into<Against<'a>>,
program: &Program,
) -> GeopResult<()>
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.
Sourcepub fn form<'a>(
&self,
editors: &Editors,
runner: &Runner,
part: impl Into<Against<'a>>,
program: &Program,
) -> GeopResult<Form>
pub fn form<'a>( &self, editors: &Editors, runner: &Runner, part: impl Into<Against<'a>>, program: &Program, ) -> GeopResult<Form>
The step’s form.
Sourcepub fn at_rest(&self, form: &Form) -> bool
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).
Sourcepub fn handle<Sc: Scene>(
&mut self,
e: Editing<'_, Sc>,
event: &StepEditEvent,
) -> GeopResult<()>
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.
Sourcepub fn presentation<'a>(
&self,
editors: &Editors,
runner: &Runner,
part: impl Into<Against<'a>>,
program: &Program,
scene: &impl Scene,
) -> GeopResult<Presentation>
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.