Skip to main content

Module ui

Module ui 

Source
Expand description

What an editor exchanges with the operations while a step is edited.

An editor never edits a step’s arguments itself. It sends what the user did — a StepEditEvent: a dialog field used, a click or a drag in the 3-D viewport as a ray from the eye, a key — to a StepEditor, which turns it into what the operation understands: a field set to a value, by the dialog, by a pick in the viewport or by dragging a handle; the selection changed; a visual dragged in the plane worked in — or, for an operation with a tool in hand, the click itself (CanvasEvent). What comes back is a Presentation: the operation’s Form — the Dialog to show and the Visuals to draw — with what is picked, selected and hovered lit. The editor reruns the program with the new arguments, draws both, and the cycle repeats.

Operations say what their fields and visuals mean — entities that can fill a crate::operation::Role, a length with a handle, a visual that can be selected or dragged — and the editor decides how they are edited, so a pick, a selection or a drag works the same in every operation.

So an editor only ever renders generic primitives and forwards raw input, and every decision — what a click means, what it snaps to, what a drag changes — is made here, in Rust, where it can be tested: hit tests a pointer against visuals, PartView against the part.

Re-exports§

pub use view::Extent;
pub use view::PartHit;
pub use view::PartView;

Modules§

hit
Hit tests: which Visual a Pointer is over, shared by every operation so a click means the same thing whatever is being edited.
view
PartView: a part as the viewport draws it, and picking entities of it with a Pointer.

Structs§

Action
Something to do or to choose, as an Control::Actions offers it.
Choice
One option of a Control::Select.
Dialog
The fields an operation shows for a step, in order: an ordered dictionary from key to control, serialized as a list, so a UI renders it with one map and keys each element by it. Keys are unique.
Edit
What a setter edits: the step’s arguments, its session, and the keys of the visuals selected.
Field
A control, and the key the events it sends carry.
Form
What an operation shows for a step: its fields and what setting each does, and what it draws. A is its arguments, T its session; a form an editor reads (see Form::erase) has neither.
ListItem
One entry of a Control::List, with its own key: pressing it sends super::Value::Press, removing it Remove, editing its value Number.
Number
A number field.
Picked
An entity a Reference holds, and what the editor found it to be.
Pointer
Where the pointer is: the ray from the eye through it, and how far from that ray it reaches.
Presentation
What an editor shows for a step being edited: the operation’s [Form], and what the editor adds to it — what is picked, selected and hovered, what a click would pick, and the handles of number fields.
Reference
Entities of the part a step builds on, picked in the viewport: any entity that can fill one of roles — and, with a scope, is part of it, like a line of one sketch. One entity, or — multiple — any number, a pick adding or taking out one.
StepEditor
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.
Track
Where a number is dragged in the viewport: a handle at at, sliding along direction — moving it by direction adds one to the number.
Visual
Something an operation draws in the viewport, under a key the hit tests report (see super::hit::hit_visuals) — and what the user can do with it, which the editor handles alike for every operation (see super::StepEditor).

Enums§

Button
Which mouse button.
CanvasEvent
A pointer or key event the editor passes on to an operation, having taken what is its own: picks, selecting, dragging handles (see super::StepEditor).
Control
A dialog primitive.
Reach
How far from its ray a Pointer reaches: what counts as under it, at any distance along the ray. Everything a viewer draws at a constant size on screen — a handle, a label, a frame datum — is laid out in reaches, so it is hit where it is drawn however far away or zoomed in the view is.
Shape
What a visual is.
StepEditEvent
One thing the user did while editing a step.
Style
What a visual means, which decides how it is drawn.
Tone
How a text reads: plain, a hint, a problem, or good news.
Unit
What a number measures, which decides how it reads and steps.
Value
What a field was set to — or that it was pressed: in the dialog, by a pick in the viewport, or by dragging a handle.

Constants§

DRAG_SNAP
Dragged values snap to this: a drag is for rough shaping, a dialog for exact values.