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, asValue::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 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>
impl<O: Operations, S: Scalar> StepEditor<O, S>
Sourcepub fn new(step: O, before: &Part<S>, new: bool) -> Self
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.
Sourcepub fn handle(
&mut self,
before: &Part<S>,
view: &PartView<S>,
event: &StepEditEvent<S>,
)
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.
Sourcepub fn presentation(&self, before: &Part<S>) -> Presentation<S>
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.