Panel Widget Documentation
Introduction
Panel widgets are background elements for the Graphical User Interface (GUI) that enable the users to make the GUI attractive by changing the background color and transparency.
This Panel Widget document covers the following topics:
- Creating and customizing panel widgets using Microchip Graphics Suite (MGS) Harmony Composer
- Panel widget properties
- Managing panel widget with the help of a button through programming
- Panel widget example project
- APIs specific to panel widgets
Designing Panel Widgets using MGS Harmony Composer
To add a panel widget to your design, select and drag PanelWidget from the Tool Box to your screen designer workspace.
Next, select the widget from the Screen Tree and modify its properties using the Object Editor. This will customize the panel widget.
Managing Panel Widget Schemes
Schemes control the look and feel of a widget.
To learn how to set the scheme for a panel, click on the ? button next to the Scheme property editor of the Object Editor.
This launches the Panel Scheme Helper window, which contains tips on how different sections of the scheme color table manipulate various widget elements.
The following is an example of the color scheme and the resulting panel appearance.
The information from the Panel Scheme Helper and the example color scheme is summarized in the following table.
Panel Properties
You can set the following properties of the Panel using the Object Editor:
Name This will be used to reference the panel by the application. Example-
Screen0_PanelWidget_0
Managing Panel Widget Through Programming
Once the graphical design is completed using MGS Harmony Composer, MCC generates the required code for all the widgets based on the properties set in the Object Editor. To learn more about the process flow between designing a UI and developing application code, refer to the "Designing an Application with Microchip Graphics Suite (MGS)" page
Suppose a new panel widget is created with the following properties in MGS Harmony Composer.
For the Panel 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 Panel widget is created by the variable name Screen0_PanelWidget_0
Screen0_PanelWidget_0 = leWidget_New();
- Its position is set to pixel location 256x23.
Screen0_PanelWidget_0->fn->setPosition(Screen0_PanelWidget_0, 256, 23);
- The Panel size is set to have a width of 140 and a height of 103.
Screen0_PanelWidget_0->fn->setSize(Screen0_PanelWidget_0, 140, 103);
- Its background value is set to fill which gives it its gray color. The background can be set to blank.
Screen0_PanelWidget_0->fn->setBackgroundType(Screen0_PanelWidget_0, LE_WIDGET_BACKGROUND_FILL);
- The Panel is set to have a bevel border in this example. However, you can have a line border or no border.
Screen0_PanelWidget_0->fn->setBorderType(Screen0_PanelWidget_0, LE_WIDGET_BORDER_BEVEL);
- Finally, the Panel Widget is added to the screen.
root0->fn->addChild(root0, (leWidget*)Screen0_PanelWidget_0);
Panel Widget Example Project
Refer to the Panel Widget Example Project on GitHub
In this example, we show:
- How to create panels
- How to handle the panel scheme with buttons
MGS Harmony Web Simulator Output
Panel Widget Example
This example shows the pressed and released callback functions of the panel color button that can be added to the application code to change the Scheme of the Panel Widget. See app.c in Github.
/* When the Panel color button is in pressed state, the Screen0_PanelWidget_0 panel
*widget will change the scheme to green and Screen0_PanelWidget_1 change the scheme to Blue*/
void void event_Screen0_ButtonWidget_0_OnPressed(leButtonWidget* btn){
Screen0_PanelWidget_0->fn->setScheme(Screen0_PanelWidget_0, &GreenScheme);
Screen0_PanelWidget_1->fn->setScheme(Screen0_PanelWidget_1, &BlueScheme);
}
/* When the Panel color button is in Released state, the Screen0_PanelWidget_0 panel
*widget will change the scheme back to yellow and Screen0_PanelWidget_1 change the scheme back to Orange*/
void void event_Screen0_ButtonWidget_0_OnReleased(leButtonWidget* btn){
Screen0_PanelWidget_0->fn->setScheme(Screen0_PanelWidget_0, &YellowScheme);
Screen0_PanelWidget_1->fn->setScheme(Screen0_PanelWidget_1, &OrangeScheme);
}
Panel Widget APIs Description
For the description of Panel widget APIs, refer to the “Widget API Description” section.