Skip to main content

Crate makeover_immediate

Crate makeover_immediate 

Source
Expand description

The immediate-mode renderer for makeover_layout.

Named for the mode, not the library, the way makeover-tui is named for the target and not for ratatui. Immediate mode is the constraint that actually separates this renderer from the other two, and egui is the backend it is written against.

It is the harshest renderer the description has to survive: no box-shadow, no inset, no cascade, no retained tree to mutate, and Visuals.widgets.*.bg_stroke is a single stroke with no per-side control. A two-tone lit edge is not something egui can be configured into producing, so it gets painted by hand here, once, instead of in every consuming app.

§What this crate does and does not own

It owns the expression: two mitred polylines for a bevel and a Frame for a filled region. It owns no colours and no sizes, and no longer owns a substitution: it briefly supplied the page for a well, which was a stand-in for surface-well before makeover derived it, and every consumer reads the real token now. Palette is supplied by the caller, already resolved, and every radius, margin and stroke width arrives in FrameStyle.

That split is why the crate has no dependency on makeover itself: the app already resolves a theme, and coupling a renderer to a colour crate’s version would buy nothing.

§The cascade is the real difference

A stylesheet can say “a pressed button inverts its bevel” once and let the cascade carry it. An immediate-mode renderer has nowhere to put that, so every call site decides. makeover_layout::Depth::pressed is what keeps the decision from being re-derived per widget.

§Forms

0.5.0 adds the field vocabulary on top of the depth vocabulary: makeover_layout::Field rendered to egui widgets, in field, and a set of them laid down a column in group. Before it, a description saying “text field, labelled, required, with this hint” had no way to become a widget here, and audiofiles’ forms stayed hand-rolled.

makeover-webview got there first and its form emitter is the precedent followed rather than re-derived, including the parts that are bug fixes: a select handed a value none of its options carries keeps that value visible instead of silently reading as the first option, which is a save-the-wrong- thing bug goingson hit for real.

What differs is forced by the mode and not chosen:

  • The value arrives as a &mut. Filling borrows the app’s own field and the widget writes through it. There is no DOM to read back out of, which is also why the description deliberately does not carry the value.
  • A text control is drawn as a well and a select is not. The description holds that a well is for anything the user looks into, and a text field is its own example; a select and a checkbox are pressed rather than looked into, so they keep egui’s own control painting.
  • makeover_layout::State::Focus is not drawn here. egui already paints exactly one focus stroke, and the description’s rule is one ring rather than a ring per primitive, so adding a second would break the rule it came from. makeover_layout::State::Disabled is drawn, because egui has no opinion about it until told.

Structs§

FieldStyle
The geometry a field group is drawn with.
FrameStyle
The geometry a framed region is drawn with.
Palette
The resolved colours this renderer needs, as flat values.

Enums§

Filling
What the field currently holds, borrowed from wherever the app keeps it.

Functions§

field
One field, as the column the app drops into its form.
frame
Draw a region at a given Depth: its fill and its edge, together.
group
A set of fields, laid down a column.
paint_bevel
Paint a two-tone edge just inside rect.