Skip to main content

Widget

Enum Widget 

Source
pub enum Widget {
Show 54 variants Heading { text: String, }, Text { text: String, mono: bool, }, Note { kind: NoteKind, title: Option<String>, text: String, }, Number { id: String, label: String, value: f64, dim: Dim, bind: Option<Bind>, min: Option<f64>, max: Option<f64>, decimals: usize, error: Option<String>, }, Choice { id: String, label: String, options: Vec<String>, selected: usize, }, Toggle { id: String, label: String, on: bool, }, TextField { id: String, label: String, value: String, }, Button { id: String, label: String, style: ButtonStyle, enabled: bool, }, Pick { id: String, label: String, value: Option<String>, armed: bool, }, List { id: String, items: Vec<ListItem>, selected: Option<usize>, }, Table { id: String, columns: Vec<String>, rows: Vec<Vec<String>>, selected: Option<usize>, editable: Vec<bool>, }, Group { title: String, open: bool, children: Vec<Widget>, }, Progress { label: String, fraction: Option<f32>, job: Option<u64>, }, Separator, Diagram { id: String, width: f32, height: f32, shapes: Vec<DiagramShape>, dimensions: Vec<Dimension>, callouts: Vec<Callout>, }, Header { icon: String, title: String, }, Value { label: String, value: String, mono: bool, }, Row { children: Vec<Widget>, }, Hinted { hint: String, widget: Box<Widget>, }, HintedFigure { hint: String, figure: Box<Widget>, widget: Box<Widget>, }, Slider { id: String, label: String, value: f64, min: f64, max: f64, step: Option<f64>, decimals: usize, show_value: bool, }, Sheet { id: String, columns: Vec<String>, rows: Vec<Vec<Cell>>, }, Section(PanelSection), Item(Item), Items(ItemList), Filter(FilterField), Status(StatusLine), Stack(Stack), Flow(Flow), Fill(Fill), Fields(Fields), Inline(Inline), PickChip(PickChip), Entry(Entry), TaskHeader(TaskHeader), Quantity(Quantity), Check(Check), Select(Select), Grid(FieldGrid), Alert(Alert), Card(Card), Caption(Caption), Gap(Gap), Plot(Plot), Swatches(Swatches), Color(ColorField), Range(Range), RowButton(RowButton), Selectable(Selectable), Gallery(Gallery), Settings(SettingsGroup), Cells(Cells), Action(PanelAction), Toggles(Toggles),
}
Expand description

One element of a declared panel. The host draws it with the app’s widgets and sends back a PanelEvent when the user changes it.

A package builds these, so a variant keeps its fields for as long as the contract’s minor version holds: a new option comes as a new variant, or as a new struct that derives Default.

Variants§

§

Heading

Fields

§text: String
§

Text

Fields

§text: String
§mono: bool
§

Note

Fields

§text: String
§

Number

A number. Bound to a parameter of a feature (bind), it takes formulas: the host keeps the formula, and the bench is told the value.

Fields

§label: String
§value: f64
§dim: Dim
§bind: Option<Bind>
§decimals: usize
§

Choice

Fields

§label: String
§options: Vec<String>
§selected: usize
§

Toggle

Fields

§label: String
§on: bool
§

TextField

Fields

§label: String
§value: String
§

Button

Fields

§label: String
§enabled: bool
§

Pick

A row asking for something to be clicked in the viewport. A click on it arms it (PanelEvent::Pick); the bench then reads the picks from the events that follow.

Fields

§label: String
§value: Option<String>

What has been picked, in words.

§armed: bool
§

List

Selectable rows.

Fields

§items: Vec<ListItem>
§selected: Option<usize>
§

Table

Columns of text, one row selectable. A column marked in editable takes typing in its cells (PanelEvent::Cell): a tool table, a list of settings by row.

Fields

§columns: Vec<String>
§rows: Vec<Vec<String>>
§selected: Option<usize>
§editable: Vec<bool>

One per column; a column left out is read-only.

§

Group

Fields

§title: String
§open: bool
§children: Vec<Widget>
§

Progress

Fields

§label: String
§fraction: Option<f32>

None while the amount is unknown.

§job: Option<u64>

A job of the bench’s: the host shows how far it is.

§

Separator

§

Diagram

A drawing: a schematic of what the panel edits, with its measures marked beside the parts they size. It is drawn in a space of its own, [0, width] × [0, height] with y up, which the host fits to the panel’s width; strokes and text keep their pixel size. A press on it, and every move of a drag begun on it, comes back as PanelEvent::DiagramPress in those coordinates: a timeline seeks where it is pressed.

Fields

§width: f32
§height: f32
§dimensions: Vec<Dimension>
§callouts: Vec<Callout>
§

Header

A task panel’s title with an icon, on a raised band.

Fields

§icon: String
§title: String
§

Value

A label and a value beside it, read only.

Fields

§label: String
§value: String
§mono: bool
§

Row

Widgets side by side, going on to the next line when the panel is narrow. A field with an empty label takes no label column here.

Fields

§children: Vec<Widget>
§

Hinted

A widget with words shown while the pointer rests on it.

Fields

§hint: String
§widget: Box<Widget>
§

HintedFigure

A widget with words and a figure under them (a Widget::Diagram) shown while the pointer rests on it.

Fields

§hint: String
§figure: Box<Widget>
§widget: Box<Widget>
§

Slider

A number dragged along a range, for a spread or a place in time rather than a measure; it comes back as PanelEvent::Number.

Fields

§label: String
§value: f64
§min: f64
§max: f64
§step: Option<f64>

The values it stops at, every step from min.

§decimals: usize
§show_value: bool

The value written beside it.

§

Sheet

Rows of cells under column titles, some cells editable; it scrolls sideways when wider than the panel.

Fields

§columns: Vec<String>
§rows: Vec<Vec<Cell>>
§

Section(PanelSection)

A folding section with a count and a summary while closed.

§

Item(Item)

One item: an icon, a name, a value at the end, tags and badges.

§

Items(ItemList)

Items, selectable, narrowed by a Widget::Filter.

§

Filter(FilterField)

A filter field for item lists, with a kind selector.

§

Status(StatusLine)

A state in a few words, as a toned pill.

§

Stack(Stack)

Widgets one under another.

§

Flow(Flow)

Widgets side by side.

§

Fill(Fill)

A widget taking the rest of a Widget::Flow’s width.

§

Fields(Fields)

Fields sharing one label column of their own.

§

Inline(Inline)

A field with its label beside it at its own width, no column.

§

PickChip(PickChip)

What is picked in the view, as a chip that clears.

§

Entry(Entry)

A line of text the user types, with a placeholder while empty.

§

TaskHeader(TaskHeader)

What the task panel’s header shows under and beside the title.

§

Quantity(Quantity)

A number field with its drag speed, width and state, and as a stepper.

§

Check(Check)

A labelled check box.

§

Select(Select)

A choice of a few, with its width and state.

§

Grid(FieldGrid)

Fields in a two-column grid, labels as wide as the longest.

§

Alert(Alert)

A note the user can click.

§

Card(Card)

A raised card holding widgets, under an icon and a title.

§

Caption(Caption)

A line of words in a size and a tone.

§

Gap(Gap)

Room between widgets.

§

Plot(Plot)

Lines plotted along a strip.

§

Swatches(Swatches)

Colours to click, the chosen ones ringed.

§

Color(ColorField)

A colour, edited in the system’s picker.

§

Range(Range)

A number dragged along a range, written with a suffix of its own.

§

RowButton(RowButton)

A frameless button as wide as the panel: one of a list of places.

§

Selectable(Selectable)

Words that light up while chosen, as one of a few side by side.

§

Gallery(Gallery)

Pictures to choose among, each over its name.

§

Settings(SettingsGroup)

A titled, bordered group of rows, as the Preferences pages draw theirs.

§

Cells(Cells)

Widgets in rows of a few columns, each column as wide as its widest: a table of readings.

§

Action(PanelAction)

A small icon button on its own, its words on hover.

§

Toggles(Toggles)

A row of icon buttons under one label, each lit while on: an editor’s alignment buttons.

Implementations§

Source§

impl Widget

Source

pub fn children(&self) -> Vec<&Widget>

The widgets this one holds, in the order they are drawn: a container’s children, a hinted widget (and its figure), an item’s field. Empty for a widget that holds none.

Source

pub fn children_mut(&mut self) -> Vec<&mut Widget>

Widget::children, to change in place.

Source

pub fn walk<'a>(&'a self, visit: &mut impl FnMut(&'a Widget))

This widget and every widget it holds, at any depth, each before its children.

Source

pub fn walk_mut(&mut self, visit: &mut impl FnMut(&mut Widget))

Widget::walk, to change in place.

Source

pub fn id(&self) -> Option<&str>

The id its events carry, for a widget that has one.

Source

pub fn field_label(&self) -> Option<&str>

The label a field writes in its label column, for a field that has one: a check box’s or a button’s own words are not one.

Trait Implementations§

Source§

impl Clone for Widget

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Widget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Widget

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Alert> for Widget

Source§

fn from(block: Alert) -> Self

Converts to this type from the input type.
Source§

impl From<Caption> for Widget

Source§

fn from(block: Caption) -> Self

Converts to this type from the input type.
Source§

impl From<Card> for Widget

Source§

fn from(block: Card) -> Self

Converts to this type from the input type.
Source§

impl From<Cells> for Widget

Source§

fn from(block: Cells) -> Self

Converts to this type from the input type.
Source§

impl From<Check> for Widget

Source§

fn from(block: Check) -> Self

Converts to this type from the input type.
Source§

impl From<ColorField> for Widget

Source§

fn from(block: ColorField) -> Self

Converts to this type from the input type.
Source§

impl From<Entry> for Widget

Source§

fn from(block: Entry) -> Self

Converts to this type from the input type.
Source§

impl From<FieldGrid> for Widget

Source§

fn from(block: FieldGrid) -> Self

Converts to this type from the input type.
Source§

impl From<Fields> for Widget

Source§

fn from(block: Fields) -> Self

Converts to this type from the input type.
Source§

impl From<Fill> for Widget

Source§

fn from(block: Fill) -> Self

Converts to this type from the input type.
Source§

impl From<FilterField> for Widget

Source§

fn from(block: FilterField) -> Self

Converts to this type from the input type.
Source§

impl From<Flow> for Widget

Source§

fn from(block: Flow) -> Self

Converts to this type from the input type.
Source§

impl From<Gallery> for Widget

Source§

fn from(block: Gallery) -> Self

Converts to this type from the input type.
Source§

impl From<Gap> for Widget

Source§

fn from(block: Gap) -> Self

Converts to this type from the input type.
Source§

impl From<Inline> for Widget

Source§

fn from(block: Inline) -> Self

Converts to this type from the input type.
Source§

impl From<Item> for Widget

Source§

fn from(block: Item) -> Self

Converts to this type from the input type.
Source§

impl From<ItemList> for Widget

Source§

fn from(block: ItemList) -> Self

Converts to this type from the input type.
Source§

impl From<PanelAction> for Widget

Source§

fn from(block: PanelAction) -> Self

Converts to this type from the input type.
Source§

impl From<PanelSection> for Widget

Source§

fn from(block: PanelSection) -> Self

Converts to this type from the input type.
Source§

impl From<PickChip> for Widget

Source§

fn from(block: PickChip) -> Self

Converts to this type from the input type.
Source§

impl From<Plot> for Widget

Source§

fn from(block: Plot) -> Self

Converts to this type from the input type.
Source§

impl From<Quantity> for Widget

Source§

fn from(block: Quantity) -> Self

Converts to this type from the input type.
Source§

impl From<Range> for Widget

Source§

fn from(block: Range) -> Self

Converts to this type from the input type.
Source§

impl From<RowButton> for Widget

Source§

fn from(block: RowButton) -> Self

Converts to this type from the input type.
Source§

impl From<Select> for Widget

Source§

fn from(block: Select) -> Self

Converts to this type from the input type.
Source§

impl From<Selectable> for Widget

Source§

fn from(block: Selectable) -> Self

Converts to this type from the input type.
Source§

impl From<SettingsGroup> for Widget

Source§

fn from(block: SettingsGroup) -> Self

Converts to this type from the input type.
Source§

impl From<Stack> for Widget

Source§

fn from(block: Stack) -> Self

Converts to this type from the input type.
Source§

impl From<StatusLine> for Widget

Source§

fn from(block: StatusLine) -> Self

Converts to this type from the input type.
Source§

impl From<Swatches> for Widget

Source§

fn from(block: Swatches) -> Self

Converts to this type from the input type.
Source§

impl From<TaskHeader> for Widget

Source§

fn from(block: TaskHeader) -> Self

Converts to this type from the input type.
Source§

impl From<Toggles> for Widget

Source§

fn from(block: Toggles) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Widget

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Widget

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Widget

Auto Trait Implementations§

§

impl Forget for Widget

§

impl Freeze for Widget

§

impl Move for Widget

§

impl RefUnwindSafe for Widget

§

impl Send for Widget

§

impl Sync for Widget

§

impl Unpin for Widget

§

impl UnsafeUnpin for Widget

§

impl UnwindSafe for Widget

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.