Skip to main content

Module recipe_toggle_style

Module recipe_toggle_style 

Source
Expand description

Default ToggleStyle impl driven by paint-recipe data.

RecipeToggleStyle ships the IntUI look out of the box; apps that want a different design language (Material 3 switch, neumorphic toggle, Cupertino) write their own impl ToggleStyle block and install it per-call (Toggle::style(...)) or theme-wide (theme.style_slots.toggle = Some(Rc::new(MyToggle))).

The visual body is a tiny custom leaf widget (ToggleBody) that paints track + knob on the canvas. We could compose RectWidget(track) | Position(knob_x, RectWidget(knob)) instead, but no general-purpose absolute-positioning primitive exists today and the compositional version isn’t free either — it adds one layout pass and two arena nodes per Toggle. The leaf body keeps parity with the paint-cost of the pre-refactor Toggle. Custom ToggleStyle impls are free to compose if they prefer.

Structs§

RecipeToggleStyle
Default ToggleStyle shipped with Teksilo. Reads its dimensions from a ToggleRecipe (defaulting to the IntUI TOGGLE_* constants) and its colors from theme.colors.{accent, surface_sunken, ...}.
ToggleRecipe
Tunable dimensions for RecipeToggleStyle. Default yields the IntUI TOGGLE_* constants; a theme can override individual fields.

Constants§

TOGGLE_THUMB_DIAMETER
TOGGLE_THUMB_INSET
TOGGLE_TRACK_HEIGHT
TOGGLE_TRACK_WIDTH