A UI widget displaying a common progress bar.

This progressbar is simply a rectangle with a line (progress indicator) inside. The indicator value is (by default) a value between 0 and 100, but you can set your own minimum and maximum points.

The progress value’s minimum and maximum is automtically calculated into the correct pixel value, scaled to the pixel width of the progressbar.


// Create the progressbar object
mono::ui::ProgressBarView prgs(mono::geo::Rect(10,10,156,100));

// set the progressbars indicator value to 50%

// display it;

A common mistake

Be aware that the progressbar is painted asynchronously. This means you cannot increment its value inside a for-loop or alike.

This code will not work:

for (int i=0; i<100; i++) {

Even if the loop ran veeery slow, you will not see a moving progress indicator. The reason is that the view is only painted in the run-loop, so no screen updates can happen from inside the for-loop!

You should use a continous timer, with a callback that increments the progress indicator:

void updateProgress(){

mono::Timer tim(500);

This code inject a continous task to the run loop that can increment the progressbar. This is the correct way to animate a progressbar.

Public Functions


Create a ProgressBar with a zero view rect (0,0,0,0)

ProgressBarView::ProgressBarView(geo::Rect rect)

Create a ProgressBarView with values from 0 to 100.

Create a new ProgressBarView, with a defined view rect and default progress value span: 0 to 100, with a current value of 0.

  • rect -

    The view rect where the ProgressBar is painted

void ProgressBarView::setValue(int newValue)

Set a new progress value.

Set a new current value for the progress bar. The value is truncated to the existing value span (min and max values).

Changes to the value will trigger the value changed callback and cause the view to schedule itself for repaint.

  • newValue -

    The new value

void ProgressBarView::setMaximum(int max)

Define a new minimum value for the progress indicator.


void ProgressBarView::setMinimum(int min)

define a new maximum value for the progress indicator

template <typename Owner>
void mono::ui::ProgressBarView::setValueChangedCallback(Owner * cnxt, void(Owner::*)(void) memPtr)

Set a progress value change callback function.

Get notification callback everytime this progressbar changes its value

  • cnxt -

    A pointer to the callback member context (the this pointer)

  • memPtr -

    A pointer to the callback member function

int ProgressBarView::Minimum()


int ProgressBarView::Maximum()


Protected Functions

void ProgressBarView::init()

convenience initializer

virtual void ProgressBarView::repaint()