TiledImage
Description
A TiledImage is a simple widget capable of showing a tiled bitmap. This means that when TiledImage is larger than the provided bitmap, the bitmap is repeated horizontally and vertically. The bitmap can be alpha-blended with the background and have areas of transparency.
Widget Group
The TiledImage can be found in the Images widget group in TouchGFX Designer.
Properties
The properties for a TiledImage 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. 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 | Image Specifies the image that should be used within the widget. An image with a repeating pattern is recommended. |
Offset | X and Y specify the offset of the image where the tile drawing should start. |
Appearance | 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 TiledImage are described in the following sections.
Actions
Standard widget action | 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
A TiledImage does not emit any triggers.
Performance
A TiledImage is dependent on image drawing, and is considered a fast performing widget on most platforms.
A TiledImage redraws the same image multiple times to cover the area of the widget. Therefore, small source images result in a greater number of image draws.
For more details on image drawing performance, read the General UI Component Performance section.
Examples
Generated Code
In the generated code for the View base class we can see how TouchGFX Designer sets up a TiledImage.
mainViewBase.cpp
#include <gui_generated/main_screen/mainViewBase.hpp>
#include "BitmapDatabase.hpp"
mainViewBase::mainViewBase()
{
tiledImage.setBitmap(touchgfx::Bitmap(BITMAP_BLUE_TEXTURES_IRONGRIP_ID));
tiledImage.setPosition(35, 36, 50, 50);
tiledImage.setOffset(0, 0);
add(tiledImage);
}
void mainViewBase::setupScreen()
{
}
Tip
tiledImage.invalidate()
if you change the appearance of the widget.User Code
The following code example shows how to animate movement into a TiledImage by continuously adjusting the offset in the handleTickEvent()
:
mainView.cpp
#include <gui/main_screen/mainView.hpp>
mainView::mainView()
{
}
void mainView::setupScreen()
{
mainViewBase::setupScreen();
}
void mainView::tearDownScreen()
{
mainViewBase::tearDownScreen();
}
void mainView::handleTickEvent()
{
int x = tiledImage.getXOffset();
int y = tiledImage.getYOffset();
tiledImage.setOffset(x + 1, y + 1);
tiledImage.invalidate();
}