Skip to main content

ProgressBar

Struct ProgressBar 

Source
pub struct ProgressBar { /* private fields */ }
Expand description

A progress bar using Unicode 8-segment block characters.

Displays a bar of width cells filled to ratio (0.0–1.0). Purely visual — not focusable, no keyboard interaction. Combine with #[reactive] and Event::Tick for animated progress.

Implementations§

Source§

impl ProgressBar

Source

pub fn new() -> Self

Creates a new progress bar at 0%, 20 cells wide.

Source

pub fn label(self, show: bool) -> Self

Builder: shows a percentage label (e.g. “75%”).

Source

pub fn ratio(self, ratio: f64) -> Self

Builder: sets the fill ratio (0.0–1.0).

Source

pub fn width(self, width: u16) -> Self

Builder: sets the bar width in character cells.

Source

pub fn style(self, style: Style) -> Self

Builder: sets the filled-portion style.

Source

pub fn track_style(self, style: Style) -> Self

Builder: sets the unfilled-portion (track) style.

Source

pub fn set_ratio(&mut self, ratio: f64, cx: &mut EventCx<'_>)

Sets the fill ratio and marks paint dirty.

Trait Implementations§

Source§

impl Component for ProgressBar

Source§

fn render(&self, cx: &mut RenderCx<'_>)

渲染组件内容
Source§

fn measure(&self, _constraint: Constraint, _cx: &mut MeasureCx) -> Size

测量组件在给定约束下的自适应尺寸 Read more
Source§

fn event(&mut self, _event: &Event, _cx: &mut EventCx<'_>)

处理事件(可选实现)
Source§

fn layout(&mut self, _rect: Rect, _cx: &mut LayoutCx<'_>)

布局回调——组件在此计算子节点 rect 并调用 child.layout() Read more
Source§

fn focusable(&self) -> bool

是否可聚焦(Tab 导航会跳过不可聚焦的组件)
Source§

fn style(&self) -> Style

返回组件样式(可选实现)
Source§

fn mount(&mut self, _cx: &mut EventCx<'_>)

首次挂载(初始化后调用)
Source§

fn unmount(&mut self, _cx: &mut EventCx<'_>)

从树卸载(退出前调用)
Source§

fn update(&mut self, _cx: &mut EventCx<'_>)

每次事件分发前调用
Source§

fn type_name(&self) -> &str

组件类型名(用于样式表类型选择器匹配)
Source§

fn id(&self) -> Option<&str>

组件 ID(用于样式表 #id 选择器匹配)
Source§

fn class(&self) -> Option<&str>

组件 class(用于样式表 .class 选择器匹配)
Source§

fn for_each_child(&self, _f: &mut dyn FnMut(&Node))

遍历子节点(为焦点系统等提供统一的树遍历接口)
Source§

fn for_each_child_mut(&mut self, _f: &mut dyn FnMut(&mut Node))

遍历子节点(可变版本)

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.