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
Text
Note
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
Choice
Toggle
TextField
Button
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.
List
Selectable rows.
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
Group
Progress
Fields
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
shapes: Vec<DiagramShape>Header
A task panel’s title with an icon, on a raised band.
Value
A label and a value beside it, read only.
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.
Hinted
A widget with words shown while the pointer rests on it.
HintedFigure
A widget with words and a figure under them (a Widget::Diagram)
shown while the pointer rests on it.
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
Sheet
Rows of cells under column titles, some cells editable; it scrolls sideways when wider than the panel.
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
impl Widget
Sourcepub fn children(&self) -> Vec<&Widget>
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.
Sourcepub fn children_mut(&mut self) -> Vec<&mut Widget>
pub fn children_mut(&mut self) -> Vec<&mut Widget>
Widget::children, to change in place.
Sourcepub fn walk<'a>(&'a self, visit: &mut impl FnMut(&'a Widget))
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.
Sourcepub fn walk_mut(&mut self, visit: &mut impl FnMut(&mut Widget))
pub fn walk_mut(&mut self, visit: &mut impl FnMut(&mut Widget))
Widget::walk, to change in place.
Sourcepub fn field_label(&self) -> Option<&str>
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.