pub struct RadialProgress { /* private fields */ }Expand description
A determinate circular progress indicator, 0.0 to 1.0.
Not interactive, not focusable, not a tab stop. It reports; it does not take
input. The value contract is Progress’s exactly — NaN
draws an empty ring, out of range clamps, and update
reports whether the value actually moved — because the number is done / total
here too, and total is eventually zero.
RadialProgress::new(0.7).with_label("70 %");
RadialProgress::new(used / capacity).with_role(Role::Warning);§It is a circle, so it inscribes rather than fills
The ring takes min(width, height) / 2 as its radius and centres itself in
the rectangle. A radial progress squashed into an ellipse is not a radial
progress, and the alternative — demanding a square — would make every caller
do this arithmetic instead.
§It takes a label, and Progress deliberately does not
Not an inconsistency. A percentage drawn inside a bar sits on the fill at
one end and on the track at the other, so it needs two colours in one string
to stay readable; that is why Progress has no text.
A ring has an empty middle. The label sits on the panel behind the widget
rather than on the ring, so it is one colour — the same arrangement
Divider’s label already uses. The two-colour problem
simply does not arise, which is the whole reason this is where the number
goes.
The caller formats it. A widget that turned 0.7 into "70 %" would be
choosing decimals and a locale on the caller’s behalf, and
update plus set_label
are two calls in the place that already knows both.
Implementations§
Source§impl RadialProgress
impl RadialProgress
Sourcepub fn new(value: f32) -> Self
pub fn new(value: f32) -> Self
A ring at value, which is clamped — see RadialProgress::set_value.
Sourcepub fn with_label(self, label: impl Into<String>) -> Self
pub fn with_label(self, label: impl Into<String>) -> Self
Puts text in the middle of the ring.
Sourcepub fn with_role(self, role: Role) -> Self
pub fn with_role(self, role: Role) -> Self
Sets the colour of the filled arc.
Warning or Error for a ring that means something is running out
rather than something is being achieved.
Sourcepub fn with_thickness(self, thickness: i32) -> Self
pub fn with_thickness(self, thickness: i32) -> Self
Sets the ring’s thickness in pixels, instead of deriving it.
Clamped to the radius: a thickness at or past it fills to the centre, which is a pie chart rather than a ring and leaves no hole for a label.
Sourcepub fn with_style(self, style: TextStyle) -> Self
pub fn with_style(self, style: TextStyle) -> Self
Sets the label’s font and size.
Sourcepub fn set_value(&mut self, value: f32)
pub fn set_value(&mut self, value: f32)
Sets the value, clamped into range, with NaN as zero.
The reasoning is Progress::set_value’s: a
panic inside a paint loop on a kiosk is a black screen with no way to
report itself, so a nonsense number draws an honest empty ring instead.
Sourcepub fn update(&mut self, value: f32) -> bool
pub fn update(&mut self, value: f32) -> bool
Sets the value, reporting whether it actually changed.
A panel writes its readings every cycle whether or not they moved, and repainting for a value that did not change is how an idle device stops being idle.
Sourcepub fn update_label(&mut self, label: &str) -> bool
pub fn update_label(&mut self, label: &str) -> bool
Replaces the label, reporting whether it actually changed.
Trait Implementations§
Source§impl Clone for RadialProgress
impl Clone for RadialProgress
Source§fn clone(&self) -> RadialProgress
fn clone(&self) -> RadialProgress
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RadialProgress
impl Debug for RadialProgress
Source§impl Default for RadialProgress
impl Default for RadialProgress
Source§impl Describe for RadialProgress
impl Describe for RadialProgress
Source§const KIND: &'static str = "radial-progress"
const KIND: &'static str = "radial-progress"
Source§const DOC: &'static str = "A ring that fills clockwise, with room for a number inside it."
const DOC: &'static str = "A ring that fills clockwise, with room for a number inside it."
Source§const ICON: &'static Icon
const ICON: &'static Icon
Source§const PROPERTIES: &'static [Property]
const PROPERTIES: &'static [Property]
Source§impl<M: 'static> Widget<M> for RadialProgress
impl<M: 'static> Widget<M> for RadialProgress
Source§fn describe(&self) -> Option<&dyn DynDescribe>
fn describe(&self) -> Option<&dyn DynDescribe>
Source§fn describe_mut(&mut self) -> Option<&mut dyn DynDescribe>
fn describe_mut(&mut self) -> Option<&mut dyn DynDescribe>
describe.Source§fn paint(&self, ctx: &mut PaintCtx<'_>, canvas: &mut Pen<'_>)
fn paint(&self, ctx: &mut PaintCtx<'_>, canvas: &mut Pen<'_>)
canvas, which is already clipped to this widget’s bounds
intersected with the damage region being repainted. Read moreSource§fn on_event(&mut self, event: &Event<'_>, ctx: &mut EventCtx<'_, M>) -> Handled
fn on_event(&mut self, event: &Event<'_>, ctx: &mut EventCtx<'_, M>) -> Handled
Source§fn measure(&self, ctx: &mut MeasureCtx<'_>, offered: Offer) -> Measured
fn measure(&self, ctx: &mut MeasureCtx<'_>, offered: Offer) -> Measured
Source§fn accepts_pointer(&self) -> bool
fn accepts_pointer(&self) -> bool
true if the pointer can hit this widget. Read moreSource§fn preserves_focus(&self) -> bool
fn preserves_focus(&self) -> bool
true if a press on this widget should leave focus exactly where
it is. Read moreSource§fn animate(&mut self, now_ms: u64) -> Animation
fn animate(&mut self, now_ms: u64) -> Animation
EventCtx::request_animation — and stops being called
the moment it answers Wake::Never. Read moreAuto Trait Implementations§
impl Freeze for RadialProgress
impl RefUnwindSafe for RadialProgress
impl Send for RadialProgress
impl Sync for RadialProgress
impl Unpin for RadialProgress
impl UnsafeUnpin for RadialProgress
impl UnwindSafe for RadialProgress
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DynDescribe for Twhere
T: Describe,
impl<T> DynDescribe for Twhere
T: Describe,
Source§fn kind(&self) -> &'static str
fn kind(&self) -> &'static str
Describe::KIND.Source§fn properties(&self) -> &'static [Property]
fn properties(&self) -> &'static [Property]
Describe::PROPERTIES.Source§fn get_property(&self, name: &str) -> Option<Value>
fn get_property(&self, name: &str) -> Option<Value>
Describe::get.Source§fn set_property(
&mut self,
name: &str,
value: Value,
) -> Result<(), PropertyError>
fn set_property( &mut self, name: &str, value: Value, ) -> Result<(), PropertyError>
Describe::set.