pub struct ProgressBar {
pub value: f32,
pub fill: Color,
}Expand description
A linear progress indicator for determinate operations.
Renders a horizontal track with a coloured fill from the left edge to
value × width. value is clamped to [0.0, 1.0] at construction.
For indeterminate progress (the operation has no ETA) prefer an
animated spinner — ltk has no built-in spinner widget yet; build one
from a Container that rotates a glyph
while crate::App::is_animating returns true.
// In view():
column()
.push( text( format!( "Downloading… {}%", ( self.progress * 100.0 ) as u32 ) ) )
.push( progress_bar( self.progress ) )
.into()Fields§
§value: f32Current progress in [0.0, 1.0]. Always clamped at construction.
fill: ColorFill colour. Defaults to the theme’s accent palette slot.
Implementations§
Source§impl ProgressBar
impl ProgressBar
Sourcepub fn new(value: f32) -> Self
pub fn new(value: f32) -> Self
Create a progress bar at the given fraction. value outside
[0.0, 1.0] is clamped silently.
Sourcepub fn color(self, color: Color) -> Self
pub fn color(self, color: Color) -> Self
Override the fill colour. Useful for “danger” / “success” variants (red for nearly-full disks, green for completed work).
Sourcepub fn preferred_size(&self, max_width: f32) -> (f32, f32)
pub fn preferred_size(&self, max_width: f32) -> (f32, f32)
Return the preferred (width, height). Width fills the available
max_width; height is the theme-defined row height.
pub fn draw(&self, canvas: &mut Canvas, rect: Rect)
Trait Implementations§
Source§impl<Msg: Clone> From<ProgressBar> for Element<Msg>
impl<Msg: Clone> From<ProgressBar> for Element<Msg>
Source§fn from(p: ProgressBar) -> Self
fn from(p: ProgressBar) -> Self
Auto Trait Implementations§
impl Freeze for ProgressBar
impl RefUnwindSafe for ProgressBar
impl Send for ProgressBar
impl Sync for ProgressBar
impl Unpin 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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more