Skip to main content

teksilo_core/styles/
progress_bar_style.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! Tier-3 style protocol for `ProgressBar`. See `docs/styling-system.md`.
5//!
6//! Themes the stationary chrome — the track and (for determinate
7//! bars) the proportional fill. The indeterminate sweep itself stays
8//! widget-owned (principle 6: motion infrastructure is not chrome) —
9//! the `ProgressBar` widget mounts a sibling sweep leaf inside its
10//! `build()` and the leaf's `paint()` issues the
11//! `draw_animated_quad` call (horizontal-shader path) or the
12//! signal-driven moving fill (vertical / reduced-motion path).
13
14use std::rc::Rc;
15
16use teksilo_tokens::Orientation;
17
18use crate::build_context::BuildContext;
19use crate::color_prop::ColorProp;
20use crate::signal::Prop;
21use crate::widget_id::WidgetId;
22
23#[derive(Clone, Debug)]
24pub enum ProgressKind {
25    /// A determinate bar fills proportionally to a `Prop<f32>` in
26    /// `[0.0, 1.0]`.
27    Determinate(Prop<f32>),
28    /// An indeterminate bar — the recipe paints only the track; the
29    /// `ProgressBar` widget mounts the sweep on top.
30    Indeterminate,
31}
32
33#[derive(Clone, Debug)]
34pub struct ProgressBarStyleConfig {
35    pub orientation: Orientation,
36    pub progress: ProgressKind,
37    /// Caller override for the track background — `None` means "use
38    /// the recipe default" (`SurfaceRole::Sunken`).
39    pub track_color_override: Option<ColorProp>,
40    /// Caller override for the determinate fill / indeterminate sweep
41    /// tint — `None` means "use the recipe default"
42    /// (`SurfaceRole::Accent`).
43    pub fill_color_override: Option<ColorProp>,
44}
45
46pub trait ProgressBarStyle: 'static {
47    fn make_body(&self, cfg: &ProgressBarStyleConfig, ctx: &mut BuildContext) -> WidgetId;
48}
49
50pub type SharedProgressBarStyle = Rc<dyn ProgressBarStyle>;