Skip to content

UXProgressBar

UXProgressBar displays a UXProgress model. It fills the track to the model’s fraction, or shows the indeterminate treatment when the total is unknown. A long UXOperationQueue job reports through it. The fill-width arithmetic is pure and unit-testable, and drawing goes through the UXControl seam. On backends with a native indicator (macOS NSProgressIndicator, Win32 progress32, iOS UIProgressView, Android ProgressBar, GTK GtkProgressBar) the driver realizes one. On GEM and the web the control draws the theme’s own bezel, bar, and striped indeterminate fill.

#use <UXKit>
UXProgress* p = new UXProgress();
p.setTotal(fileCount);
UXProgressBar* bar = new UXProgressBar();
bar.setProgress(p);
content.addSubview(bar, UXGeom.make(8, 8, 200, 16));
// as work completes:
p.incrementBy(1);
bar.setNeedsDisplay();

A bar with no progress model, or one whose total is zero, is indeterminate: the platform’s barber pole where there is one, the theme’s striped fill where the control draws itself.

  • Inherits UXControl: geometry, enablement, the realization seam. There is no action, because a progress bar only reports.

Model · setProgress · isIndeterminate Geometry · filledWidth Realization · kind

void setProgress(UXProgress* p)

Attaches the model. The bar reads it at draw time, so there is no copy to fall out of date.

bool isIndeterminate(void)

True with no model, or when the model itself says so (zero total).

i32 filledWidth(i16 trackW)

Width of the filled portion for a track trackW wide, from the model’s per-mille fraction. This is pure arithmetic, and the tests call it without a window.

UXKind kind(void)

UXKindProgress: native where the backend has an indicator, the theme’s art everywhere else. The driver decides; the control does not know which.

UXProgressBar on the web backend

The theme’s bezel trough and blue bar fill, drawn on canvas with the same Aristo art GEM draws.

An operation queue reporting into the bar from the run loop:

UXProgress* p = new UXProgress();
p.setTotal(steps);
bar.setProgress(p);
for (i32 i = (i32)0; i < steps; i = i + (i32)1) {
doStep(i);
p.incrementBy(1);
bar.setNeedsDisplay();
gApp.displayIfNeeded();
}