pub struct Spinner { /* private fields */ }
Expand description
An animated spinner widget for showing a loading state.
To customize the spinner’s size, you can place it inside a SizedBox
that has a fixed width and height.
Implementations§
source§impl Spinner
impl Spinner
sourcepub fn new() -> Spinner
pub fn new() -> Spinner
Create a spinner widget
Examples found in repository?
examples/blocking_function.rs (line 52)
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
fn ui_builder() -> impl Widget<AppState> {
let button = Button::new("Start slow increment")
.on_click(|ctx, data: &mut AppState, _env| {
data.processing = true;
// In order to make sure that the other thread can communicate with the main thread we
// have to pass an external handle to the second thread.
// Using this handle we can send commands back to the main thread.
wrapped_slow_function(ctx.get_external_handle(), data.value);
})
.padding(5.0);
let button_placeholder = Flex::column()
.with_child(Label::new(LocalizedString::new("Processing...")).padding(5.0))
.with_child(Spinner::new());
// Hello-counter is defined in the built-in localisation file. This maps to "Current value is {count}"
// localised in english, french, or german. Every time the value is updated it shows the new value.
let text = LocalizedString::new("hello-counter")
.with_arg("count", |data: &AppState, _env| (data.value).into());
let label = Label::new(text).padding(5.0).center();
let either = Either::new(|data, _env| data.processing, button_placeholder, button);
Flex::column().with_child(label).with_child(either)
}
sourcepub fn with_color(self, color: impl Into<KeyOrValue<Color>>) -> Self
pub fn with_color(self, color: impl Into<KeyOrValue<Color>>) -> Self
Builder-style method for setting the spinner’s color.
The argument can be either a Color
or a Key<Color>
.
sourcepub fn set_color(&mut self, color: impl Into<KeyOrValue<Color>>)
pub fn set_color(&mut self, color: impl Into<KeyOrValue<Color>>)
Set the spinner’s color.
The argument can be either a Color
or a Key<Color>
.
Trait Implementations§
source§impl<T: Data> Widget<T> for Spinner
impl<T: Data> Widget<T> for Spinner
source§fn event(
&mut self,
ctx: &mut EventCtx<'_, '_>,
event: &Event,
_data: &mut T,
_env: &Env
)
fn event( &mut self, ctx: &mut EventCtx<'_, '_>, event: &Event, _data: &mut T, _env: &Env )
Handle an event. Read more
source§fn lifecycle(
&mut self,
ctx: &mut LifeCycleCtx<'_, '_>,
event: &LifeCycle,
_data: &T,
_env: &Env
)
fn lifecycle( &mut self, ctx: &mut LifeCycleCtx<'_, '_>, event: &LifeCycle, _data: &T, _env: &Env )
Handle a life cycle notification. Read more
source§fn layout(
&mut self,
_layout_ctx: &mut LayoutCtx<'_, '_>,
bc: &BoxConstraints,
_data: &T,
env: &Env
) -> Size
fn layout( &mut self, _layout_ctx: &mut LayoutCtx<'_, '_>, bc: &BoxConstraints, _data: &T, env: &Env ) -> Size
Compute layout. Read more
source§fn paint(&mut self, ctx: &mut PaintCtx<'_, '_, '_>, _data: &T, env: &Env)
fn paint(&mut self, ctx: &mut PaintCtx<'_, '_, '_>, _data: &T, env: &Env)
Paint the widget appearance. Read more
source§fn compute_max_intrinsic(
&mut self,
axis: Axis,
ctx: &mut LayoutCtx<'_, '_>,
bc: &BoxConstraints,
data: &T,
env: &Env
) -> f64
fn compute_max_intrinsic( &mut self, axis: Axis, ctx: &mut LayoutCtx<'_, '_>, bc: &BoxConstraints, data: &T, env: &Env ) -> f64
Computes max intrinsic/preferred dimension of a widget on the provided axis. Read more
Auto Trait Implementations§
impl RefUnwindSafe for Spinner
impl Send for Spinner
impl Sync for Spinner
impl Unpin for Spinner
impl UnwindSafe for Spinner
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> RoundFrom<T> for T
impl<T> RoundFrom<T> for T
§fn round_from(x: T) -> T
fn round_from(x: T) -> T
Performs the conversion.
§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere U: RoundFrom<T>,
§fn round_into(self) -> U
fn round_into(self) -> U
Performs the conversion.