Progress Bar Widget Documentation
Introduction
The Progress Bar widget in Microchip Graphics Composer (MGC) is highly customizable, allowing developers to tailor its appearance and behavior to fit the specific needs of their applications. With intuitive drag-and-drop functionality and a wide range of configuration options, the progress bar enhances user experience by updating the progress value and integrate event callbacks for interactive feedback.
This Progress Bar widget document covers the following topics:
- Creating and customizing Progress Bar widgets using Microchip Graphics Suite (MGS) Harmony Composer
- Progress Bar properties
- Handling Progress Bar widget properties and events through application code
- Progress Bar widget example project
- Application Program Interfaces (APIs) specific to the Progress Bar widget
Designing Progress Bar Widget Using MGS Harmony Composer
To add the Progress Bar widget to your design, follow the steps given below:
In the Graphics Composer, select and drag the Progress Bar from the Toolbox to your screen designer workspace as shown in the accompanying image:

Figure 1: Progress Bar from Toolbox
To customize the Progress Bar, select it from the Screen Tree and modify its properties using the Object Editor.
To set the Border aspect property of the progress bar, click on the button beside it and from the Border window choose the desired aspect as shown in the accompanying image:

Figure 2: Border Aspect
Setting the progress bar initial value can be done by adding any numerical value, from 0 to 100, in the Value section as in Figure 3. (The example from Step 2.1 presents a progress bar with a value of 0.)

Figure 3: Progress Bar Value
The progress bar filling direction can be set from the Fill Direction section. (The previous example, Step 2.2, shows the Fill Direction as Right.)

Figure 4: Fill Direction
To set an event handler function when the Progress Bar widget value is changed, select the corresponding checkbox under Events as shown in the following image:

Figure 5: Value Changed Event
The rest of the checkboxes can be set using the Object Editor depending on your needs. An example is shown in the accompanying image:

Figure 6: Object Editor
Managing Progress Bar Widget Schemes
Schemes control the look and feel of a widget.
To learn how to set the scheme for the progress bar, click on the question mark (?) button next to the Scheme Property editor of the Object Editor.

Figure 7: Scheme Helper Button
This launches the Progress Bar Scheme Helper window containing tips on how different sections of the scheme color table manipulate various elements of the widget:

Figure 8: Progress Bar Scheme Helper Window
Figuure 9 shows an example color scheme and the resulting appearance of the Progress Bar:

Figure 9: Color Scheme Example
The information about the Progress Bar scheme adjustments and the example color scheme are summarized in Figure 10:

Figure 10: Color Scheme Table
Progress Bar Properties
You can set the following properties of the Progress Bar using the Object Editor:
Name | This will be used to reference the progress bar by the application. Example - Screen0_ProgressBarWidget_0. |
Fill Direction | Set the progress bar filling direction, as in Section 2.3. |
Value | Sets a value for the progress bar as shown in Section 2.2. |
Value Changed | This will set the event that is generated when the progress bar value is changed. |
Table 1: Progress Bar Widget Properties |
Managing Progress Bar through Programming
Once you complete creating your graphical interface with MGS Harmony Composer, the MPLAB® Code Configurator (MCC) automatically produces the necessary code for each widget according to the settings specified in the Object Editor. For additional details on the workflow from UI design to application code development, consult the "Designing an Application with Microchip Graphics Suite (MGS)" page.
Let's suppose that a new Progress Bar widget is created with the following properties in MGS Harmony Composer:

Figure 11: Example
For the Progress Bar widget with the properties shown in the figure above, MCC will automatically generate the following lines of code in
src\confg\default\gfx\legato\generated\screen\le_gen_screen_Screen0.c
- A new Progress Bar widget is created by the variable name Screen0_ProgressBarWidget_0:
Screen0_ ProgressBarWidget _0 = leProgressBarWidget _New(); - Its position is set to pixel location 100x45:
Screen0_ProgressBarWidget_0->fn->setPosition(Screen0_ProgressBarWidget_0, 100, 45); - The Progress Bar size is set to have a width of 600 pixels and a height of 130:
Screen0_ProgressBarWidget_0->fn->setSize(Screen0_ProgressBarWidget_0, 600, 130); - Its background and filling color is set based on the selected color scheme:
Screen0_ProgressBarWidget_0->fn->setScheme(Screen0_ProgressBarWidget_0, &ProgressBarScheme); - The Progress Bar filling value is set at 50%, by using a numerical character:
Screen0_ProgressBarWidget_0->fn->setValue(Screen0_ProgressBarWidget_0, 50); - The setValueChangedCallback API adds callback function when the Progress Bar value is changed. These callback functions are implemented in the application code:
Screen0_ProgressBarWidget_0->fn->setValueChangedCallback(Screen0_ProgressBarWidget_0, event_Screen0_ProgressBarWidget_0_ValueChanged); - Finally, the progress bar is added to the screen:
root0->fn->addChild(root0, (leWidget*)Screen0_ProgressBarWidget_0);
Application Code
The default code generated by MCC establishes the initial state of the widget. You can modify the properties or behavior of the widgets using the APIs mentioned earlier in the application code. Further discussion on application code related to the Progress Bar widget is provided below.
Here is an example of activating the event when the Progress Bar value is changed, modifying the size of the Progress Bar widget and setting the filling direction:
Screen0_ProgressBarWidget_0->fn->setSize(Screen0_ProgressBarWidget_0, 200, 200);
Screen0_ProgressBarWidget_0->fn->setDirection(Screen0_ProgressBarWidget_0, LE_PROGRESSBAR_DIRECTION_DOWN);
Screen0_ProgressBarWidget_0->fn->setValueChangedCallback(Screen0_ProgressBarWidget_0, event_Screen0_ProgressBarWidget_0_ValueChanged);
Progress Bar Widget Example Project
An example project for the Progress Bar widget is provided.
In this example, we show:
- How to create a Progress Bar widget, which gets filled depending on a Slider widget
- How to show the value of the progress bar, using its event
MGS Simulator Output
Adjusting the slider widget triggers its associated event handler within the application code, allowing the user to modify the progress bar’s value according to the slider’s current position. When the progress bar value is updated, its event handler is subsequently invoked, which then updates the label to display the corresponding percentage of completion.
- The Slider Event Callback gets invoked when the slider's position is moved and it takes the position of the slider, transforming it into the value:
{
/*Get the value of the slider*/
sliderValue = Screen0_SliderWidget_0->fn->getValue(Screen0_SliderWidget_0);
sliderChanged = true;
}
- The screen's function, called "Screen0_On_Update", which gets called repeatedly in the application code, checks the value of the bool variable set in the function above and if it's true, the value of the Progress Bar widget is set using its API:
{
/*Update the value of the Progress Bar Widget when the event of the Slider is entered*/
if(sliderChanged == true)
{
Screen0_ProgressBarWidget_0->fn->setValue(Screen0_ProgressBarWidget_0, sliderValue);
sliderChanged = false;
}
}
- The Progress Bar Event Callback gets called every time the progress bar's value gets changed and updates a string value, which is placed in a label:
{
/*Update the string value shown on the widget when the Progress Bar value changes*/
char valueCStr[VALUE_STR_SIZE_8] = {0};
snprintf(valueCStr, VALUE_STR_SIZE_8, "%u", sliderValue);
sliderStr.fn->setFromCStr(&sliderStr, valueCStr);
Screen0_LabelWidget_1->fn->setString(Screen0_LabelWidget_1, (leString *) &sliderStr);
}
Progress Bar Widget APIs Description
This section describes the APIs specific to Progress Bar widget. For a description of APIs common to all widgets, refer to the "Base Widget Documentation" page.
getDirection()
The following gets the progress bar filling direction: leProgressBarDirection getDirection(const leProgressBarWidget* _this).
Parameters
const leProgressBarWidget* | _this | Progress Bar widget pointer to operate on |
This returns the filling direction.
setDirection()
The following sets the progress bar filling direction: leResult setDirection(leProgressBarWidget* _this, leProgressBarDirection dir).
Parameters
leProgressBarWidget* | _this | Progress Bar widget pointer to operate on |
leProgressBarDirection | dir | Filling Direction (LE_PROGRESSBAR_DIRECTION_RIGHT, LE_PROGRESSBAR_DIRECTION_UP, LE_PROGRESSBAR_DIRECTION_LEFT, LE_PROGRESSBAR_DIRECTION_DOWN). |
This returns LE_SUCCESS or LE_FAILURE.
getValue()
The following gets the progress bar valueuint32_t getValue(const leProgressBarWidget* _this).
Parameters
const leProgressBarWidget* | _this | Progress Bar widget pointer to operate on |
This returns the progress bar value.
setValue()
The following gets the progress bar value: leResult setValue(leProgressBarWidget* _this, uint32_t value).
Parameters
leProgressBarWidget* | _this | Progress Bar widget pointer to operate on |
uint32_t | value | Progress Bar value |
This returns LE_SUCCESS or LE_FAILURE.
getValueChangedEventCallback()
The following gets value changed event callback pointer: leProgressBar_ValueChangedEventCallback getValueChangedEventCallback(const leProgressBar* _this).
Parameters
leProgressBar* | _this | Progress Bar widget pointer to operate on |
This returns the callback pointer.
setValueChangedCallback()
The following sets value changed event callback pointer: leResult setValueChangedCallback(leProgressBar* _this, leProgressBar_ValueChangedEventCallback cb).
Parameters
leProgressBar* | _this | Progress Bar widget pointer to operate on |
leProgressBar_ValueChangedEventCallback | cb | The callback pointer |
This returns LE_SUCCESS or LE_FAILURE.