Struct vizia_core::views::ProgressBar
source · pub struct ProgressBar;
Expand description
A simple ProgressBar that can be used to show progress of something.
the input lens need to be a f32 with range of 0.0..1.0
§Example
§Vertical ProgressBar bound to the input lens
ProgressBar::vertical(cx, AppData::progress);
§Horizontal ProgressBar bound to the input lens
ProgressBar::horizontal(cx, AppData::progress);
§A Horizontal ProgressBar with a label beside it to show the progress
HStack::new(cx, |cx| {
ProgressBar::horizontal(cx, AppData::progress);
Label::new(cx, AppData::progress.map(|v| format!("{:.0}%", v * 100.0)));
});
§A Horizontal ProgressBar with dynamic bar background color using a lens
we can dynamically change the background color of the bar using bar_color
method on Handle
ProgressBar::horizontal(cx, AppData::progress).bar_color(AppData::color);
Implementations§
source§impl ProgressBar
impl ProgressBar
sourcepub fn new<L>(
cx: &mut Context,
lens: L,
orientation: Orientation,
) -> Handle<'_, Self>
pub fn new<L>( cx: &mut Context, lens: L, orientation: Orientation, ) -> Handle<'_, Self>
Creates a new progress bar bound to the value targeted by the lens.
§Example
ProgressBar::new(cx, AppData::value, Orientation::Horizontal);
sourcepub fn horizontal<L>(cx: &mut Context, lens: L) -> Handle<'_, Self>
pub fn horizontal<L>(cx: &mut Context, lens: L) -> Handle<'_, Self>
Creates a new horizontal progress bar bound to the value targeted by the lens.
Trait Implementations§
source§impl View for ProgressBar
impl View for ProgressBar
source§fn element(&self) -> Option<&'static str>
fn element(&self) -> Option<&'static str>
Specifies a name for the view type which can be used as an element selector in css. Read more
source§fn build<F>(self, cx: &mut Context, content: F) -> Handle<'_, Self>
fn build<F>(self, cx: &mut Context, content: F) -> Handle<'_, Self>
Builds the view into the tree and returns a handle which can be used to apply style and layout modifiers to the view. Read more
source§fn event(&mut self, cx: &mut EventContext<'_>, event: &mut Event)
fn event(&mut self, cx: &mut EventContext<'_>, event: &mut Event)
Handles any events received by the view. Read more
source§fn draw(&self, cx: &mut DrawContext<'_>, canvas: &Canvas)
fn draw(&self, cx: &mut DrawContext<'_>, canvas: &Canvas)
Provides custom drawing for the view. Read more
fn accessibility(&self, cx: &mut AccessContext<'_>, node: &mut AccessNode)
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
Mutably borrows from an owned value. Read more
§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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.