Skip to main content

Module strips

Module strips 

Source
Expand description

Slim strips, as a plugin (StripsPlugin, opt-in): the activity bar, a column of icons along the start edge, one per panel that lives in the start side bar (an icon shows its panel, a click on the shown one folds the side bar to the strip, as the workbench’s workbench.toggle.primarySideBar does on Ctrl+B), and the status bar with indicators: small items whose state is fed by the host’s events (a job’s progress, a connection, a count), each with an optional command run on a click.

Experimental: may change in any release (docs/stability.md).

An indicator is a reducer over the journal: egui-pop hands it every new event whose name starts with its prefix, in order, and draws its state. Nothing polls: the host publishes, the indicator follows.

use egui_pop_api::strips::{Indicator, IndicatorState, Tone};

// Jobs: `job.started` adds one, `job.done` removes one.
let jobs = Indicator::new("jobs", "Jobs", "job.").reduce(|state, event| {
    let n = state.count.unwrap_or(0);
    match event.name.as_str() {
        "job.started" => state.count = Some(n + 1),
        "job.done" => state.count = Some(n.saturating_sub(1)),
        _ => {}
    }
    state.text = format!("{} running", state.count.unwrap_or(0));
    state.tone = if state.count == Some(0) { Tone::Neutral } else { Tone::Accent };
});

An indicator may follow the context (Indicator::when): a when clause over the context keys (the context stack’s place, mode.<group>, a frame’s own keys), the grammar of commands. The bar shows it only where its clause holds; hidden, it keeps reducing events, so its state is right the moment it shows again. Indicator::during writes the clause of a frame for it.

With the context stack (crate::contexts) installed too, the status bar starts with where the user is: the breadcrumb (a click on a crumb goes back to that place; the current one does nothing), then a chip per active mode of a group declared FrameSpec::visible (a click leaves the mode; a pushed mode shows a back mark and goes back to what it replaced; a mode whose guard refuses keeps its chip and says why in its tooltip). On a narrow window the middle crumbs collapse into … (a menu of them) first, then the heaviest indicators give way; chips never hide, since they show active states. StripsPlugin::breadcrumb turns this off.

The user hides status items and orders them (an item’s context menu, or status.item.hide and status.item.move); only status items can be muted. The choices (Choices) are kept per place of the context stack, in its view document, so a bar arranged for the darkroom comes back as it was; a place without choices of its own takes the root’s. Without the context stack they last the session.

Agents read what the bar shows: status lists every item with why it is hidden (its when, the user, a narrow bar), context.read gives the visible ones in its status field, and the strips debug collector shows the breadcrumb, the chips, the items and the choices.

Steps (ADR 0011): workbench.fold ({ "area", "folded" }): an area folded to its strip or unfolded.

While a floating palette is dragged over a place it docks in, the bar’s start says how to dock it or not (crate::palettes::drag_hint).

Structs§

Choices
The user’s choices for the status bar in a place: the items hidden, and their order from the bar’s end (the items not listed follow, by weight).
Indicator
An indicator, as declared.
IndicatorState
What an indicator shows.
StatusEntry
A status item as the bar has it now.
StripsPlugin
The plugin.
StripsService
The status bar’s own state.

Enums§

Alignment
Which end of the status bar an item sits at.
HiddenBy
Why a status item is not shown.
Tone
How an indicator looks: egui-pop’s one tone (egui_pop_core::kit::Tone). Neutral (nothing to say) is the status-indicator’s own box, drawn muted; Accent says something is going on; Record that something records. What a part says, the same names for every component. Neutral is the component’s own box (no tone); the others are read from component.tone.<name>, their defaults aliasing the system’s status tokens (accent.default, info, success, warning, danger, text.muted; record aliases danger too). Serialized by its token name ("danger").

Constants§

CHOICES_VALUE
The name the choices are kept under, per place (contexts::place_value).
CMD_HIDE_ITEM
Hides a status item where the user is, or shows it again.
CMD_HOVER_ITEM
Opens a status item’s hover card, as hovering it does.
CMD_MOVE_ITEM
Moves a status item one step towards the bar’s start or end.
CMD_OPEN_ITEM
Opens a status item’s popover, or closes it.
CMD_TOGGLE_SIDE_BAR
Folds or unfolds the start side bar. It has no key and no menu item of its own: Ctrl+B and the View menu run the workbench’s workbench.toggle.primarySideBar (layout_controls).
STRIPS
The status bar’s state: the choices when there is no context stack to keep them per place.

Functions§

choices
The choices of the place shown: its own, else the root’s (the session’s without a context stack).
focused_item
The status item with the keyboard focus last pass.
hide
Hides a status item where the user is, or shows it again.
move_item
Moves a status item one step towards the bar’s end (toward_end) or its start, among the items of its group (start or end) the bar shows here.
open_card
Opens a status item’s hover card as the keyboard does (the focus on its first link). False when it has no card, or is not in the bar.
open_item
The status item whose popover is open.
open_popover
Opens a status item’s popover (closing any other), or closes it. False when there is no such item, or it has no popover.
status
Every status item in the bar’s order from its end, with why it is hidden. Empty without the strips plugin.
visible
The status items the bar shows, as context.read gives them.

Type Aliases§

HoverFn
A hover card’s content, built from the item’s state when shown (and when an agent reads it).
PopoverFn
A popover’s content: a small layout drawn while it is open.
ReduceFn
A reducer: updates a state from an event.