Skip to main content

Module indicator

Module indicator 

Source
Expand description

Micro-indicators: the small marks that say a state in very little space, beside or on another widget. Six kinds need nothing but the theme, plus icons that follow a state:

Experimental: may change in any release (docs/stability.md).
  • a dot or an LED (Led: off, on, busy, warning, error), each state with a shape of its own (hollow, filled, pulsing, a triangle, a square);
  • a badge: a count capped at 99+ (zero hidden unless asked), or a short text;
  • an activity pip (Pip): a spinner, a ring, done, failed;
  • a flag (Flag: modified, pinned, required, invalid, or a FlagShape of the application’s): a corner triangle, a stripe, a diamond, a triangle, a square, an asterisk;
  • a swatch (Swatch): a colour over egui’s alpha checkerboard, no colour (a slash), or mixed (a dash);
  • a dynamic icon: a built-in Icon, or one of two by a state;
  • a value’s mark (ValueMark): changed from its default (a dot), held by another party (a square), moved by another party (a diamond), drawn as the dot and the flags are.

They are drawn by the kit (docs/kit.md) like every other component: indicator-dot, indicator-badge, indicator-flag, indicator-swatch, indicator-outline and indicator-button (the target of an interactive mark), with pips on spinner and progress-ring. Colours follow the kit’s one Tone. The shapes of the LEDs and of the named flags are the kit’s glyph roles (glyph.led-*, glyph.flag-*), which a kit remaps to any icon; the kit refuses two states that would share a shape (egui_pop_tokens::kit::DISTINCT_GLYPHS). A state is never said by colour alone: each has a shape, a glyph or a text, and a name.

Passive by default. A passive mark takes no click and no focus. On a widget (Indicator::on, IndicatorExt::with_indicator) its meaning joins that widget’s accessible name (“Notifications, 3”); inline ([Ui::add]) it is read as an image with its meaning for a name. Its tooltip says the meaning too.

Interactive (Indicator::interactive): the button rules of egui-pop, a target of at least indicator.target (24 points) around the mark, the focus ring, Space and Enter, a tooltip, an AccessKit node of its own (a button, or a check box for an icon that toggles) whose description is the mark’s meaning, a reason when disabled, and a command (Indicator::command) that the application runs.

Anchoring. Inline with ui.add, or on any rectangle with Indicator::paint_at: a corner, the start or end edge (centred vertically) or the centre (Anchor). Start and end follow the Direction (left to right unless set). Badges and dots overhang a corner by half their height and are drawn on a layer of their own just above the host’s, never clipped; the others sit inside.

Motion. A busy LED pulses; any mark can call attention after a change (Indicator::attention) for indicator.pulse.count pulses. The pulse runs on the motion clock (a frozen clock gives the same frame), and under reduced motion it is a still ring instead.

Agents. Marks with an id (Indicator::id) are recorded each pass: drawn lists them, and the debug bridge’s indicators collector shows them as JSON (Record), so an agent reads states instead of pixels.

use egui_pop_core::icon::Icon;
use egui_pop_core::indicator::{Anchor, Indicator, IndicatorExt as _, Led, Pip, Tone};

fn status(ui: &mut egui::Ui, unread: u64, rendering: bool) {
    // Passive, inline: read as "On".
    ui.add(Indicator::led(Led::On).id("node").tooltip("Node connected"));
    if rendering {
        ui.add(Indicator::pip(Pip::Busy).name("Rendering"));
    }
    // On a button's corner: the button reads "Notifications, 3".
    ui.add(Icon::Notification.label("Notifications").sense_click())
        .with_indicator(ui, Indicator::count(unread).tone(Tone::Danger), Anchor::TopEnd);
    // Interactive: a button of its own.
    if ui
        .add(Indicator::dot(Tone::Accent).name("Changed").interactive("Reset exposure"))
        .clicked()
    { /* reset */ }
}

Re-exports§

pub use crate::kit::Tone;

Structs§

Indicator
A micro-indicator, built then added inline (ui.add) or painted on a widget (Indicator::on, Indicator::paint_at).
Record
What agents and tests see of a drawn indicator.

Enums§

Anchor
Where a mark goes on its host.
Direction
The interface’s direction: where start and end are. egui has none of its own yet; an application in a right-to-left language sets it with set_direction.
Flag
The flags egui-pop names, each with its shape and tone.
FlagShape
A flag’s shape.
Led
An LED’s state; each has its own shape and default tone.
Pip
An activity pip’s state.
Size
A size step (never points): the tokens’ sizes scaled.
Swatch
What a swatch shows.
ValueMark
A value’s marks, beside the control showing it: it is not at its default, another party holds it, another party just moved it. Each has its shape and its meaning (in the current language), so none rests on colour alone:

Constants§

CAP
A badge’s cap by default: 99+ past it.
MIN_TARGET
The smallest target of an interactive mark, whatever the kit says (WCAG 2.5.8).

Traits§

IndicatorExt
Indicators on a widget’s response.

Functions§

annotate
Adds a meaning to a widget’s accessible name: “Masks” becomes “Masks, 3 errors”. A widget named by another node (labelled_by) gets it as its description instead. Call it after the widget gave its own name, each pass.
badge_text
The text a badge shows for a count: cap+ past its cap.
direction
Where start and end are (set_direction).
drawn
The indicators with an id drawn in the last complete pass: empty when that pass drew none (a frame hiding every bar).
find
One drawn indicator by id.
set_direction
Sets where start and end are for the marks of this context.
take_commands
The commands interactive indicators asked for since the last call; the application runs them (an egui-pop App does, each frame).