Skip to main content

Form

Struct Form 

Source
pub struct Form<'a, S: Scalar, A = (), T = ()> {
    pub dialog: Dialog<S>,
    pub visuals: Vec<Visual<S>>,
    pub focus: Option<CoordinateSystem<S>>,
    pub tool: bool,
    /* private fields */
}
Expand description

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.

Fields§

§dialog: Dialog<S>§visuals: Vec<Visual<S>>§focus: Option<CoordinateSystem<S>>

A plane to work in, its u/v plane: the viewer faces it head on, stops orbiting, and draws a grid on it. Draggable visuals are dragged in it.

§tool: bool

Whether the operation has a tool in hand — drawing a line, say — so that clicks go to it rather than select.

Implementations§

Source§

impl<'a, S: Scalar, A, T> Form<'a, S, A, T>

Source

pub fn new() -> Self

Source

pub fn set(&self, key: &str, edit: Edit<'_, A, T>, value: Value)

What the field key does with value: its setter’s. Nothing for a key no field has — a field shown only to be read.

Source

pub fn erase(self) -> Form<'a, S>

The form as an editor reads it: what it shows, without what setting its fields does.

Source

pub fn on( &mut self, key: impl Into<String>, setter: impl Fn(Edit<'_, A, T>, Value) + 'a, )

setter for the key key: for a control already in the dialog, or one of its items — a list’s entries each have their own key.

Source

pub fn heading(&mut self, key: &str, text: impl Into<String>) -> &mut Self

Source

pub fn text( &mut self, key: &str, text: impl Into<String>, tone: Tone, ) -> &mut Self

Source

pub fn list( &mut self, key: &str, items: Vec<ListItem>, empty: impl Into<String>, ) -> &mut Self

A list of entries, each with a key of its own for Form::on.

Source

pub fn actions( &mut self, key: &str, actions: Vec<Action>, run: impl Fn(Edit<'_, A, T>, &str) + 'a, ) -> &mut Self

Things to do or choose; pressing one runs run with its value.

Source

pub fn checkbox( &mut self, key: &str, label: impl Into<String>, value: bool, set: impl Fn(&mut A, bool) + 'a, ) -> &mut Self

Source

pub fn number( &mut self, key: &str, number: Number<S>, set: impl Fn(&mut A, f64) + 'a, ) -> &mut Self

Source

pub fn select( &mut self, key: &str, label: impl Into<String>, value: impl Into<String>, options: Vec<Choice>, set: impl Fn(&mut A, &str) + 'a, ) -> &mut Self

One of options, by value.

Source

pub fn reference( &mut self, key: &str, label: impl Into<String>, value: Vec<EntityRef>, roles: &[Role], scope: Option<EntityRef>, multiple: bool, set: impl Fn(Edit<'_, A, T>, Vec<EntityRef>) + 'a, ) -> &mut Self

Entities that can fill one of roles — and, with a scope, are part of it (see Reference); set gets what the field holds now.

Trait Implementations§

Source§

impl<S: Scalar, A, T> Default for Form<'_, S, A, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a, S, A = (), T = ()> !RefUnwindSafe for Form<'a, S, A, T>

§

impl<'a, S, A = (), T = ()> !Send for Form<'a, S, A, T>

§

impl<'a, S, A = (), T = ()> !Sync for Form<'a, S, A, T>

§

impl<'a, S, A = (), T = ()> !UnwindSafe for Form<'a, S, A, T>

§

impl<'a, S, A, T> Freeze for Form<'a, S, A, T>
where S: Freeze,

§

impl<'a, S, A, T> Unpin for Form<'a, S, A, T>
where S: Unpin,

§

impl<'a, S, A, T> UnsafeUnpin for Form<'a, S, A, T>
where 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.