Expand description
A field’s state drawn, announced and reported: the egui side of
egui_pop_model::field.
Experimental: may change in any release
(docs/stability.md).
Every input shows its FieldState the same way, the decorated
input (crate::input) and the sliders alike:
- an edge: a strip along the field’s leading side in the colour
of its first state (
FieldState::edge: disabled, invalid, pending, modified), from thefield.*tokens; - a marker icon per state, so the state never rests on colour alone: a dot (modified), an asterisk (required), a crossed circle (invalid), a clock (pending), a lock (read-only), an “i” (disabled, whose reason is its tooltip);
- assistive technologies get it too: required, invalid (with the message as the description), disabled (with the reason), read-only, busy (pending);
- agents read every field drawn in the last pass, with its
state and its disabled reason, through
describe(and the debug bridge’sfieldscollector).
use egui_pop_core::field;
use egui_pop_model::field::FieldState;
fn exposure_row(ui: &mut egui::Ui) {
let state = FieldState::new().disabled("Needs an open image");
let r = ui.add_enabled(false, egui::Button::new("Pick"));
field::hover(ui, &r, &state);
field::access(ui.ctx(), r.id, &state);
field::record(ui.ctx(), r.id, "Pick", "button", &state);
}Structs§
- Field
Record - One field as drawn, for agents.
- Field
State - A field’s state. The default is a plain field: editable, optional, valid, unchanged.
- Modified
- How a field is modified.
Enums§
- Baseline
- What a modified field differs from.
- Mark
- One state a field shows, for its marker and icon. The order of the variants is the order of precedence: the first state a field has gives its edge.
Functions§
- access
- Gives a field’s state to assistive technologies: required, invalid (its message as the description), disabled (its reason as the description), read-only, busy while pending. A modified field says so in its description.
- color
- The colour of a mark, from the kit’s
field: the muted tone’s text for a disabled or read-only field, else the border colour of the mark’s tone (dangerinvalid,infopending,accentmodified,warningrequired). - describe
- The fields drawn in the last pass as agents read them: each one’s label, kind, marks, whether it can be focused and edited, and the disabled reason and invalid message.
- edge_
width - The width of a field’s edge strip.
- fields
- The fields drawn in the last complete pass.
- hover
- The tooltip a field’s state adds: the disabled reason (shown while disabled), the invalid message, “being checked”. Returns the response with them.
- icon
- The icon of a mark; the required mark is an asterisk, painted as
text (
paint_marker). - markers
- The marks a field shows as markers, in order: every mark it has.
- markers_
width - The width the markers of a state take,
sidepoints each. - paint_
edge - Paints the edge along a field’s leading side, in its first state’s colour; an invalid or pending field is outlined in it too.
- paint_
marker - Paints one mark’s marker in a square.
- paint_
markers - Paints a state’s markers from
at(the left of the first), centred ony; returns where they end. - record
- Records a field drawn this pass (its widget calls it), so agents see
it in
fieldsanddescribefrom the next pass. - text
- What a mark says, in the interface’s language (the disabled and invalid marks say their reason and message).