Line Progress
A Line Progress shows the current progress by using a Line as the progress indicator on top of a background Image. The line does not need to be either horizontal or vertical, but can start at any coordinate and finish at any coordinate.
Widget Group
The Line Progress can be found in the Progress Indicators widget group in TouchGFX Designer.
Properties
The properties for a Line Progress in TouchGFX Designer.
Property Group | Property Descriptions |
---|---|
Name | Name of the widget. Name is the unique identifier used in TouchGFX Designer and code. |
Location | X and Y specify the top left corner of the widget relative to its parent. W and H specify the width and height of the widget. The size of a Line Progress is determined by the size of the selected background image. Lock specifies if the widget should be locked in its current X, Y, W and H. Locking the widget also disables interacting with the widget through the screen. Visible specifies the visibility of the widget. Making the widget invisible also disables interacting with the widget through the screen. |
Style | Style specifies a predefined setup of the widget, that sets select properties to predefined values. These styles contain images that are free to use. |
Image & Color | Background specifies background image. Image specifies which image to use as fill for the line. The image selected will be placed in top left corner of the widget. Color specifies which color to use as fill for the line. |
Values | Range Min and Range Max specify the minimum and maximum integer values of the indicator. Initial specifies the initial value of the progress indicator.Steps Total specifies at what granularity the progress indicator reports new values. For instance, if the progress needs to be reported as 0%, 10%, 20%, ..., 100%, the total value should be set to 10. Steps Min specifies the minimum steps the progress indicator shows. |
Appearance | Start Position X and Start Position Y specify the coordinate where the line should start. End Position X and End Position Yspecify the coordinate where the line should end. Line Width specifies the width of the line. Cap Style specifies line ending style. Alpha specifies the transparency of the widget. The alpha value ranges between 0 and 255 for the widget. 0 is fully transparent and 255 is solid. |
Mixins | Draggable specifies if the widget is draggable at runtime. ClickListener specifies if the widget emits a callback when clicked. FadeAnimator specifies if the widget can animate changes to its Alpha value. MoveAnimator specifies if the widget can animate changes to X and Y values. |
Interactions
The actions and triggers supported by the Line Progress are described in the following sections.
Actions
Widget specific actions | Description |
---|---|
Set value | Sets the value of a progress indicator to a desired value |
Standard widget actions | Description |
---|---|
Move widget | Move a widget to a new position over time. |
Fade widget | Modify alpha value of widget over time. |
Hide widget | Hides a widget (sets visibility to false). |
Show widget | Make a hidden widget visible (sets visibility to true). |
Triggers
The Line Progress does not emit any triggers.
Performance
A Line Progress consists of an Image and a Line. A Line is a CanvasWidget and is heavily dependent on the MCU for rendering. Therefore, the Line Progress is considered a demanding widget on most platforms.
For more details on CanvasWidget drawing performance, read the UI Component Performance Overview.
Examples
Generated Code
In the generated code for the View base class we can see how TouchGFX Designer sets up a Line Progress.
Screen1ViewBase.cpp
#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include "BitmapDatabase.hpp"
#include <touchgfx/Color.hpp>
Screen1ViewBase::Screen1ViewBase()
{
touchgfx::CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE);
lineProgress.setXY(45, 71);
lineProgress.setProgressIndicatorPosition(0, 0, 391, 130);
lineProgress.setRange(0, 100);
lineProgress.setBackground(touchgfx::Bitmap(BITMAP_BLUE_PROGRESSINDICATORS_BG_LARGE_PROGRESS_INDICATOR_BG_ROUND_DEGREES_ID));
lineProgressPainter.setColor(touchgfx::Color::getColorFrom24BitRGB(0, 151, 255));
lineProgress.setPainter(lineProgressPainter);
lineProgress.setStart(17, 17);
lineProgress.setEnd(374, 113);
lineProgress.setLineWidth(30);
lineProgress.setLineEndingStyle(touchgfx::Line::ROUND_CAP_ENDING);
lineProgress.setValue(60);
add(lineProgress);
}
void Screen1ViewBase::setupScreen()
{
}
Tip
lineProgress.invalidate()
if you change the appearance of the widget.User Code
The following example illustrates how to implement the handleTickEvent()
function to simulate progress. Running this code creates the application shown at the beginning of this article.
Screen1View.hpp
class Screen1View : public Screen1ViewBase
{
public:
Screen1View();
virtual ~Screen1View() {}
virtual void setupScreen();
virtual void tearDownScreen();
virtual void handleTickEvent();
protected:
bool increase = true;
};
Screen1View.cpp
void Screen1View::handleTickEvent()
{
int currentValue = lineProgress.getValue();
int16_t max;
int16_t min;
lineProgress.getRange(min, max);
if (currentValue == min)
{
increase = true;
}
else if (currentValue == max)
{
increase = false;
}
int nextValue = increase == true ? currentValue+1 : currentValue-1;
lineProgress.setValue(nextValue);
}
TouchGFX Designer Examples
To further explore the Line Progress, try creating a new application within TouchGFX Designer with one of the following UI templates: