pub struct Model {
pub full: char,
pub full_color: Color,
pub empty: char,
pub empty_color: Color,
pub show_percentage: bool,
pub percent_format: String,
pub percentage_style: Style,
/* private fields */
}Expand description
Model stores values we’ll use when rendering the progress bar.
Fields§
§full: char“Filled” sections of the progress bar.
full_color: ColorThe color used for the filled sections.
empty: char“Empty” sections of the progress bar.
empty_color: ColorThe color used for the empty sections.
show_percentage: boolSettings for rendering the numeric percentage.
percent_format: StringA fmt string for a float.
percentage_style: StyleThe style used for the percentage.
Implementations§
Source§impl Model
impl Model
Sourcepub fn update(&mut self, msg: &dyn Msg) -> Cmd
pub fn update(&mut self, msg: &dyn Msg) -> Cmd
Update is used to animate the progress bar during transitions. Use
set_percent to create the command you’ll need
to trigger the animation.
If you’re rendering with view_as you won’t need
this.
Sourcepub fn set_spring_options(&mut self, frequency: f64, damping: f64)
pub fn set_spring_options(&mut self, frequency: f64, damping: f64)
SetSpringOptions sets the frequency and damping for the current spring. Frequency corresponds to speed, and damping to bounciness.
Sourcepub fn percent(&self) -> f64
pub fn percent(&self) -> f64
Percent returns the current visible percentage on the model. This is only relevant when you’re animating the progress bar.
If you’re rendering with view_as you won’t need
this.
Sourcepub fn set_percent(&mut self, p: f64) -> Cmd
pub fn set_percent(&mut self, p: f64) -> Cmd
SetPercent sets the percentage state of the model as well as a command necessary for animating the progress bar to this new percentage.
If you’re rendering with view_as you won’t need
this.
Sourcepub fn incr_percent(&mut self, v: f64) -> Cmd
pub fn incr_percent(&mut self, v: f64) -> Cmd
IncrPercent increments the percentage by a given amount, returning a command necessary to animate the progress bar to the new percentage.
If you’re rendering with view_as you won’t need
this.
Sourcepub fn decr_percent(&mut self, v: f64) -> Cmd
pub fn decr_percent(&mut self, v: f64) -> Cmd
DecrPercent decrements the percentage by a given amount, returning a command necessary to animate the progress bar to the new percentage.
If you’re rendering with view_as you won’t need
this.
Sourcepub fn view(&self) -> String
pub fn view(&self) -> String
View renders an animated progress bar in its current state. To render
a static progress bar based on your own calculations use
view_as instead.
Sourcepub fn view_as(&self, percent: f64) -> String
pub fn view_as(&self, percent: f64) -> String
ViewAs renders the progress bar with a given percentage.
Sourcepub fn is_animating(&self) -> bool
pub fn is_animating(&self) -> bool
IsAnimating returns false if the progress bar reached equilibrium and is no longer animating.