What to try
Click the button to increase progress and observe the percentage.
Usage notes
Native progress values range from 0 to 1; the application converts them to percentages. Use Progress for known progress and Spinner for an unknown duration.
Create through Screen
The Screen constructor returns a node ID. Pass that ID to Screen layout, state and event APIs. It is separate from the standalone control object documented below.
Native Xu setup fragment: call configure during initialization of an existing Screen. See the complete example for window creation, event dispatch and cleanup.
#ui/widgets
fn configure(screen $&widgets.Screen) int {
id := screen.progress(0.4) or >>
screen.place(id,24.0,24.0,320.0,80.0) or >>
<< id
}
($&Screen) progress
pub fn (s $&Screen) progress(value f64) int
Purpose
Create Progress in Screen and return the component node ID; throw on creation failure.
Parameters
s $&Screen- The
Screen instance used by this call (exclusive borrow).
value f64- value (f64)
Returns
int — component node ID for place and other Screen methods.
Placement, state and events
The application owns the component. Screen.place positions nodes; Screen.set_enabled and Screen.set_visible control availability and visibility. Present again after state changes, handle or errors, and keep topology changes outside paint callbacks. ToastHost uses its own queue API.
Action · Styles · UI lifecycle and styling guide
Screen.place · Screen.set_enabled · Screen.set_visible
Standalone control object API
These types and methods support applications that manage control objects, input and painting directly. Their receiver is a control object, not a Screen node ID. For Screen usage, use the constructor above and the Screen methods in the Widgets module.
struct Progress
Purpose
Progress context or state structure.
Public fields
This type has no public fields.
See usage example
(&Progress) value
pub fn (progress &Progress) value() f64
Purpose
Execute value on &Progress.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
Returns
f64 — a value of this type
(&Progress) needs_paint
pub fn (progress &Progress) needs_paint() bool
Purpose
Return whether the control needs repainting; call painted after painting to clear the flag.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
Returns
bool — true or false
($&Progress) painted
pub fn (progress $&Progress) painted()
Purpose
Acknowledge the painted frame and clear the dirty flag; this is not a query.
Parameters
progress $&Progress- The
Progress instance used by this call (exclusive borrow).
Returns
This call does not return a value.
(&Progress) is_selectable
pub fn (progress &Progress) is_selectable() bool
Purpose
Operation on &Progress: whether it is selectable.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
Returns
bool — true or false
($&Progress) set_selectable
pub fn (progress $&Progress) set_selectable(selectable bool)
Purpose
Operation on $&Progress: set selectable.
Parameters
progress $&Progress- The
Progress instance used by this call (exclusive borrow).
selectable bool- selectable (bool)
Returns
This call does not return a value.
($&Progress) set_value
pub fn (progress $&Progress) set_value(value f64) int
Purpose
Operation on $&Progress: set value. Throws on failure; handle the error or propagate it to the caller.
Parameters
progress $&Progress- The
Progress instance used by this call (exclusive borrow).
value f64- value (f64)
Returns
int — a value of this type
($&Progress) set_bounds
pub fn (progress $&Progress) set_bounds(bounds &layout.Rect) int
Purpose
Operation on $&Progress: set bounds. Throws on failure; handle the error or propagate it to the caller.
Parameters
progress $&Progress- The
Progress instance used by this call (exclusive borrow).
bounds &layout.Rect- bounds (read-only borrow; caller keeps the original; type &layout.Rect)
Returns
int — a value of this type
(&Progress) paint
pub fn (progress &Progress) paint(frame $&draw.Frame,theme &Theme) int
Purpose
Paint the control visually onto the target canvas. Throws on failure; handle the error or propagate it to the caller.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
frame $&draw.Frame- frame (exclusive borrow; may modify the original; type $&draw.Frame)
theme &Theme- theme (read-only borrow; caller keeps the original; type &Theme)
Returns
int — a value of this type
(&Progress) clone
pub fn (value &Progress) clone() Progress
Purpose
Copy the control or style snapshot into an independent Progress value.
Parameters
value &Progress- The
Progress instance used by this call (borrow).
Returns
Progress — a value of this type
(&Progress) bounds
pub fn (progress &Progress) bounds() layout.Rect
Purpose
Return the bounding Rectangle of the control or geometry.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
Returns
layout.Rect — a value of this type
(&Progress) is_enabled
pub fn (progress &Progress) is_enabled() bool
Purpose
Return whether the control is currently enabled.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
Returns
bool — true or false
(&Progress) is_invalid
pub fn (progress &Progress) is_invalid() bool
Purpose
Operation on &Progress: whether it is invalid.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
Returns
bool — true or false
(&Progress) is_focused
pub fn (progress &Progress) is_focused() bool
Purpose
Return whether the control currently has input focus.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
Returns
bool — true or false
(&Progress) is_selected
pub fn (progress &Progress) is_selected() bool
Purpose
Operation on &Progress: whether it is selected.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
Returns
bool — true or false
($&Progress) set_focus
pub fn (progress $&Progress) set_focus(focused bool)
Purpose
Operation on $&Progress: set focus.
Parameters
progress $&Progress- The
Progress instance used by this call (exclusive borrow).
focused bool- focused (bool)
Returns
This call does not return a value.
($&Progress) set_selected
pub fn (progress $&Progress) set_selected(selected bool)
Purpose
Operation on $&Progress: set selected.
Parameters
progress $&Progress- The
Progress instance used by this call (exclusive borrow).
selected bool- selected (bool)
Returns
This call does not return a value.
(&Progress) visual_state
pub fn (progress &Progress) visual_state() int
Purpose
Operation on &Progress: visual state.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
Returns
int — a value of this type
(&Progress) has_style
pub fn (progress &Progress) has_style() bool
Purpose
Operation on &Progress: whether it has style.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
Returns
bool — true or false
(&Progress) style_or
pub fn (progress &Progress) style_or(styles &Styles) ControlStyle
Purpose
Operation on &Progress: style or.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
styles &Styles- styles (read-only borrow; caller keeps the original; type &Styles)
Returns
ControlStyle — a value of this type
($&Progress) set_style
pub fn (progress $&Progress) set_style(style &ControlStyle) int
Purpose
Operation on $&Progress: set style. Throws on failure; handle the error or propagate it to the caller.
Parameters
progress $&Progress- The
Progress instance used by this call (exclusive borrow).
style &ControlStyle- style (read-only borrow; caller keeps the original; type &ControlStyle)
Returns
int — a value of this type
($&Progress) clear_style
pub fn (progress $&Progress) clear_style()
Purpose
Operation on $&Progress: clear style.
Parameters
progress $&Progress- The
Progress instance used by this call (exclusive borrow).
Returns
This call does not return a value.
(&Progress) measure_styled
pub fn (progress &Progress) measure_styled(styles &Styles) layout.Size
Purpose
Operation on &Progress: measure styled.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
styles &Styles- styles (read-only borrow; caller keeps the original; type &Styles)
Returns
layout.Size — a value of this type
(&Progress) paint_styled
pub fn (progress &Progress) paint_styled(frame $&draw.Frame,styles &Styles) int
Purpose
Paint Progress using the complete theme; control bounds and Frame use the same local coordinates.
Parameters
progress &Progress- The
Progress instance used by this call (borrow).
frame $&draw.Frame- frame (exclusive borrow; may modify the original; type $&draw.Frame)
styles &Styles- styles (read-only borrow; caller keeps the original; type &Styles)
Returns
0 on success; throws on failure
($&Progress) set_enabled
pub fn (progress $&Progress) set_enabled(enabled bool)
Purpose
Operation on $&Progress: set enabled.
Parameters
progress $&Progress- The
Progress instance used by this call (exclusive borrow).
enabled bool- enabled (bool)
Returns
This call does not return a value.
($&Progress) set_invalid
pub fn (progress $&Progress) set_invalid(invalid bool)
Purpose
Operation on $&Progress: set invalid.
Parameters
progress $&Progress- The
Progress instance used by this call (exclusive borrow).
invalid bool- invalid (bool)
Returns
This call does not return a value.
($&Progress) set_buffer
pub fn (progress $&Progress) set_buffer(value f64) int
Purpose
Operation on $&Progress: set buffer. Throws on failure; handle the error or propagate it to the caller.
Parameters
progress $&Progress- The
Progress instance used by this call (exclusive borrow).
value f64- value (f64)
Returns
int — a value of this type
Complete native example
Component Workshop · Back to Widgets