pub struct MaterialProgress { /* private fields */ }Expand description
Material Design progress indicator component
Progress indicators inform users about the status of ongoing processes, such as loading an app, submitting a form, or saving updates. They communicate an app’s state and indicate available actions.
§Usage Examples
// Linear progress with value
ui.add(MaterialProgress::linear()
.value(0.65)
.size(Vec2::new(300.0, 6.0)));
// Circular progress with value
ui.add(MaterialProgress::circular()
.value(0.8)
.size(Vec2::splat(64.0)));
// Indeterminate linear progress (loading)
ui.add(MaterialProgress::linear()
.indeterminate(true));
// Buffered linear progress (like video loading)
ui.add(MaterialProgress::linear()
.value(0.3)
.buffer(0.6));§Material Design Spec
- Linear: 4dp height (default), variable width
- Circular: 48dp diameter (default), 4dp stroke width
- Colors: Primary color for progress, surfaceVariant for track
- Animation: Smooth transitions, indeterminate animations
- Corner radius: 2dp for linear progress
Implementations§
Source§impl MaterialProgress
impl MaterialProgress
Sourcepub fn new(variant: ProgressVariant) -> Self
pub fn new(variant: ProgressVariant) -> Self
Sourcepub fn linear() -> Self
pub fn linear() -> Self
Create a linear progress bar
Linear progress indicators display progress along a horizontal line. Best for showing progress of tasks with known duration.
§Material Design Usage
- File downloads/uploads
- Form submission progress
- Loading content with known steps
Sourcepub fn circular() -> Self
pub fn circular() -> Self
Create a circular progress indicator
Circular progress indicators display progress along a circular path. Best for compact spaces or indeterminate progress.
§Material Design Usage
- Loading states in buttons or cards
- Refreshing content
- Background processing
Sourcepub fn value(self, value: f32) -> Self
pub fn value(self, value: f32) -> Self
Set the current progress value
§Parameters
value: Progress value (will be clamped between 0.0 and max)
Sourcepub fn max(self, max: f32) -> Self
pub fn max(self, max: f32) -> Self
Set the maximum value for progress calculation
The progress percentage will be calculated as value/max.
§Parameters
max: Maximum value (default is 1.0 for 0-100% range)
Sourcepub fn buffer(self, buffer: f32) -> Self
pub fn buffer(self, buffer: f32) -> Self
Set the buffer value for buffered progress
Buffered progress shows an additional value indicating estimated completion. Useful for tasks like video buffering where loading status is variable.
§Parameters
buffer: Buffer value (will be clamped between 0.0 and max)
Sourcepub fn indeterminate(self, indeterminate: bool) -> Self
pub fn indeterminate(self, indeterminate: bool) -> Self
Enable or disable indeterminate progress animation
Indeterminate progress is used when the actual progress is unknown, such as during loading states. It shows a looping animation to indicate activity.
§Parameters
indeterminate: true to enable indeterminate mode, false to disable
Sourcepub fn four_color_enabled(self, enabled: bool) -> Self
pub fn four_color_enabled(self, enabled: bool) -> Self
Enable or disable four-color animation for indeterminate progress
Four-color animation provides a more dynamic indeterminate animation using four distinct colors. This can be visually appealing but may impact performance due to increased draw calls.
§Parameters
enabled: true to enable four-color animation, false to disable
Sourcepub fn size(self, size: Vec2) -> Self
pub fn size(self, size: Vec2) -> Self
Set the size of the progress indicator
§Parameters
size: Desired size (width, height) of the progress indicator
Sourcepub fn width(self, width: f32) -> Self
pub fn width(self, width: f32) -> Self
Set the width of the progress indicator (for linear variant)
§Parameters
width: Desired width of the progress indicator
Sourcepub fn height(self, height: f32) -> Self
pub fn height(self, height: f32) -> Self
Set the height of the progress indicator (for circular variant)
§Parameters
height: Desired height of the progress indicator
Sourcepub fn four_color(self, enabled: bool) -> Self
👎Deprecated: Use four_color_enabled() instead
pub fn four_color(self, enabled: bool) -> Self
Enable or disable four-color animation (deprecated, use four_color_enabled)
§Parameters
enabled: true to enable four-color animation, false to disable
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MaterialProgress
impl RefUnwindSafe for MaterialProgress
impl Send for MaterialProgress
impl Sync for MaterialProgress
impl Unpin for MaterialProgress
impl UnwindSafe for MaterialProgress
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.