pub struct ProgressBar { /* private fields */ }Expand description
A horizontal progress bar that fills value / max of the area it’s
rendered into.
filled_style/empty_style default to Style::new(); set them with
ProgressBar::filled_style/ProgressBar::empty_style.
area.height() is ignored; only the first row is drawn.
§Examples
use retroglyph_core::{Grid, Rect};
use retroglyph_widgets::{ProgressBar, Surface, Widget};
let area = Rect::new(0, 0, 10, 1);
let mut grid = Grid::new(10, 1);
ProgressBar::new(5, 10).render(area, &mut Surface::new(&mut grid, area, 0));Implementations§
Source§impl ProgressBar
impl ProgressBar
Sourcepub const fn filled_style(self, style: Style) -> Self
pub const fn filled_style(self, style: Style) -> Self
Set the style of the filled portion.
Sourcepub const fn empty_style(self, style: Style) -> Self
pub const fn empty_style(self, style: Style) -> Self
Set the style of the empty portion.
Sourcepub fn theme(self, theme: Theme) -> Self
pub fn theme(self, theme: Theme) -> Self
Applies theme’s named roles to this bar: filled_style becomes theme.accent (progress
reads as emphasis, the same role super::Tabs::theme/super::Button::theme use for a
selected/focused state) on theme.panel_bg, and empty_style becomes theme.dim on
theme.panel_bg.
Both set an explicit background rather than leaving it at Style::new()’s default: an
unset background isn’t “transparent” once a real backend draws it (a bare Color::Default
cell paints as solid black behind the glyph; see retroglyph-software’s DEFAULT_BG),
which matters most for empty_style’s '░' glyph (it doesn’t fully cover its cell the way
filled_style’s '█' does, so its background actually shows). This widget assumes it’s
drawn on theme.panel_bg, true when composed with a themed super::Panel/
super::Modal. Drawing this bar directly on the raw screen background instead needs a
manual .filled_style(...)/.empty_style(...) override afterwards.
Call before any manual ProgressBar::filled_style/ProgressBar::empty_style override
you want to keep.
Sourcepub fn theme_on(self, theme: Theme, bg: Color) -> Self
pub fn theme_on(self, theme: Theme, bg: Color) -> Self
Same as ProgressBar::theme, but filled_style/empty_style are drawn on bg instead
of theme.panel_bg: for a bar drawn directly on a backdrop other than a themed
super::Panel/super::Modal’s fill. ProgressBar::theme is exactly
theme_on(theme, theme.panel_bg).
Trait Implementations§
Source§impl Clone for ProgressBar
impl Clone for ProgressBar
Source§fn clone(&self) -> ProgressBar
fn clone(&self) -> ProgressBar
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more