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 Theme::DARK (as if ProgressBar::theme had been
called); set them with ProgressBar::filled_style/ProgressBar::empty_style.
area.height() is ignored; only the first row is drawn.
§Examples
use retroglyph_core::grid::{Grid, Rect};
use retroglyph_ui::{ProgressBar, Surface, Widget};
let area = Rect::new(0, 0, 10, 1);
let mut grid = Grid::new(10, 1);
ProgressBar::new(5, 10).render(&mut Surface::new(&mut grid, area, 0));Implementations§
Source§impl ProgressBar
impl ProgressBar
Sourcepub fn new(value: u32, max: u32) -> Self
pub fn new(value: u32, max: u32) -> Self
A bar filling value / max, styled from Theme::DARK (as if ProgressBar::theme had
been called).
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 moreSource§impl Debug for ProgressBar
impl Debug for ProgressBar
Source§impl Widget for ProgressBar
impl Widget for ProgressBar
impl Copy for ProgressBar
Auto Trait Implementations§
impl Freeze for ProgressBar
impl RefUnwindSafe for ProgressBar
impl Send for ProgressBar
impl Sync for ProgressBar
impl Unpin for ProgressBar
impl UnsafeUnpin for ProgressBar
impl UnwindSafe for ProgressBar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<C> WithAlpha for Cwhere
C: Copy,
impl<C> WithAlpha for Cwhere
C: Copy,
§fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
self with alpha, storing alpha before the color in memory
(see [AlphaFirst]).§fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
self with alpha, storing alpha after the color in memory
(see [AlphaLast]).