A progress bar for any long-running operation (downloads, uploads, decompression, loading).

Two modes:

  • Determinate — assign progress (0..1); the fill tweens smoothly to the new value (smoothing = false snaps instead).
  • Indeterminate — set indeterminate = true for unknown-length work; an accent band sweeps the track until turned off.

Layout follows the labelled-row convention (label left, optional percent, bar right); an empty label makes the bar span the full width. Idle-free by construction: a per-frame ticker runs only while the sweep animation or a smoothing tween is active, so a settled bar performs zero work.

Constructor

@:value({ progress : 0 })new(label:String, width:Float, progress:Float = 0)

Parameters:

label

the row text on the left (empty = the bar spans the whole row)

width

layout width

progress

the initial progress 0..1

Variables

barWidth:Float

Width of the bar area on the right when a label is present.

@:value("")fallback:String = ""

@:value(0)fillOverride:Int = 0

Explicit ARGB fill (e.g. UITheme.danger on failure); 0 uses the theme accent.

@:value(12)fontSize:Int = 12

Base (unscaled) font size for the label/percent.

@:value(false)indeterminate:Bool = false

Unknown-length mode: a sweeping band replaces the fill until turned off.

@:value(null)key:String = null

label:String

@:value(0)progress:Float = 0

Target progress 0..1 (clamped). Assigning tweens the fill when smoothing is on.

@:value(false)showPercent:Bool = false

Renders a right-aligned percent readout beside the bar (hidden while indeterminate).

@:value(true)smoothing:Bool = true

Tween progress assignments instead of snapping.

@:value(1100)sweepMs:Float = 1100

Full sweep period of the indeterminate band, in ms.

@:value(6)thickness:Float = 6

Base (unscaled) bar thickness.

Methods

localize(key:String, fallback:String):Void

Switches the label to a localized string.

Parameters:

key

the translation key

fallback

the source-language text

reset():Void

Snaps to 0 and clears indeterminate mode (reuse between operations).

@:value({ animate : true })setProgress(value:Float, animate:Bool = true):Void

Sets the progress with explicit control over animation.

Parameters:

value

the target progress 0..1 (clamped)

animate

true tweens the fill, false snaps immediately

inlinesetRatio(done:Float, total:Float):Void

Convenience for byte/item counters.

Parameters:

done

the amount completed

total

the total amount (<= 0 switches to indeterminate)

Inherited Variables

Defined by UIComponent

@:value(true)enabled:Bool = true

Disabled widgets ignore the pointer and typically render dimmed.

@:value(0)read onlyh:Float = 0

Layout height in UI units.

@:value(MouseCursor.BUTTON)hoverCursor:MouseCursor = MouseCursor.BUTTON

Native cursor while hovering (interactive widgets; null keeps the arrow).

@:value(false)read onlyhovered:Bool = false

true while the cursor is over this widget.

@:value(null)onClick:() ‑> Void = null

Fired on a completed click (press + release on this widget).

@:value(null)onHover:() ‑> Void = null

Fired when the cursor first enters this widget (hover-driven descriptions/previews).

@:value(null)onRightClick:() ‑> Void = null

Fired on a right mouse press over this widget (context menus).

@:value(false)read onlypressed:Bool = false

true while a press that started here is held.

@:value(null)tooltip:String = null

Optional tooltip text (already-localized or a fixed string).

@:value(null)tooltipShortcut:String = null

Optional right-aligned shortcut hint rendered in the tooltip.

@:value(0)read onlyw:Float = 0

Layout width in UI units (independent of DisplayObject's content-derived width).

Inherited Methods

Defined by UIComponent

invalidate():Void

Schedules a repaint for the next frame (cheap; deduplicated).

resize(width:Float, height:Float):Void

Sets the layout size and repaints when it changed.

Parameters:

width

the new layout width in UI units

height

the new layout height in UI units