주요 내용으로 건너뛰기

AnimatedImage

A widget capable of basic animation using a range of bitmaps. The AnimatedImage is capable of running the animation from start to end or, in reverse order, end to start. It is capable of doing a single animation or looping the animation until stopped or paused.

Inherits from: Image, Widget, Drawable

Public Functions

AnimatedImage(const BitmapId & start, const BitmapId & end, const uint8_t & updateInterval =1)
Constructs an AnimatedImage.
AnimatedImage(const uint8_t & updateInterval =1)
Constructs an AnimatedImage without initializing bitmaps.
virtual voidhandleTickEvent()
Called periodically by the framework if the Drawable instance has subscribed to timer ticks.
boolisAnimatedImageRunning() const
Gets the running state of the AnimatedImage.
boolisReverse()
Query if this object is running in reverse.
virtual voidpauseAnimation()
Toggles the running state of an animation.
virtual voidsetBitmap(const Bitmap & bmp)
Sets the bitmap for this Image and updates the width and height of this widget to match those of the Bitmap.
virtual voidsetBitmapEnd(const Bitmap & bmp)
Sets the end bitmap for this AnimatedImage sequence.
voidsetBitmaps(BitmapId start, BitmapId end)
Sets the bitmaps that are used by the animation.
voidsetDoneAction(GenericCallback< const AnimatedImage & > & callback)
Associates an action to be performed when the animation of the AnimatedImage is done.
voidsetUpdateTicksInterval(uint8_t updateInterval)
Sets the update interval.
virtual voidstartAnimation(const bool rev, const bool reset =false, const bool loop =false)
Starts the animation with the given parameters for animation direction, normal or reverse, whether to restart the animation and finally if the animation should loop automatically upon completion.
virtual voidstopAnimation()
Stops and resets the animation.

Protected Attributes

GenericCallback< const AnimatedImage & > *animationDoneAction
Pointer to the callback to be executed when animation is done.
BitmapIdendId
Id of last bitmap in animation.
boolloopAnimation
If true, continuously loop animation.
boolreverse
If true, run in reverse direction (last to first).
boolrunning
If true, animation is running.
BitmapIdstartId
Id of first bitmap in animation.
uint8_tticksSinceUpdate
Number of ticks since last animation update.
uint8_tupdateTicksInterval
Number of ticks between each animation update (image change).

Additional inherited members

Public Functions inherited from Image

virtual voiddraw(const Rect & invalidatedArea) const
Draw this drawable.
uint8_tgetAlpha() const
Gets the current alpha value of the widget.
BitmapgetBitmap() const
Gets the Bitmap currently assigned to the Image widget.
BitmapIdgetBitmapId() const
Gets the BitmapId currently assigned to the Image widget.
virtual RectgetSolidRect() const
Get (the largest possible) rectangle that is guaranteed to be solid (opaque).
Image(const Bitmap & bmp =Bitmap())
Constructs a new Image with a default alpha value of 255 (solid) and a default Bitmap (undefined) if none is specified.
virtual voidinvalidateContent() const
Tell the framework that the contents of the Drawable needs to be redrawn.
voidsetAlpha(uint8_t newAlpha)
Sets the opacity (alpha value).

Protected Attributes inherited from Image

uint8_talpha
The Alpha for this image.
Bitmapbitmap
The Bitmap to display.

Public Functions inherited from Widget

virtual voidgetLastChild(int16_t , int16_t , Drawable ** last)
Since a Widget is only one Drawable, Widget::getLastChild simply yields itself as result, but only if the Widget isVisible and isTouchable.

Public Functions inherited from Drawable

voidcenter()
Centers the Drawable inside its parent.
voidcenterX()
Center the Drawable horizontally inside its parent.
voidcenterY()
Center the Drawable vertically inside its parent.
virtual voidchildGeometryChanged()
This function can be called on parent nodes to signal that the size or position of one or more of its children has changed.
virtual voiddraw(const Rect & invalidatedArea) const =0
Draw this drawable.
Drawable()
Initializes a new instance of the Drawable class.
voiddrawToDynamicBitmap(BitmapId id)
Render the Drawable object into a dynamic bitmap.
voidexpand(int margin =0)
Expands the Drawable to have the same size as its parent with a given margin around the edge.
RectgetAbsoluteRect() const
Helper function for obtaining the rectangle this Drawable covers, expressed in absolute coordinates.
virtual Drawable *getFirstChild()
Function for obtaining the first child of this drawable if any.
int16_tgetHeight() const
Gets the height of this Drawable.
virtual voidgetLastChild(int16_t x, int16_t y, Drawable ** last) =0
Function for obtaining the the last child of this drawable that intersects with the specified point.
Drawable *getNextSibling()
Gets the next sibling node.
Drawable *getParent() const
Returns the parent node.
const Rect &getRect() const
Gets the rectangle this Drawable covers, in coordinates relative to its parent.
virtual RectgetSolidRect() const =0
Get (the largest possible) rectangle that is guaranteed to be solid (opaque).
virtual RectgetSolidRectAbsolute()
Helper function for obtaining the largest solid rect (as implemented by getSolidRect()) expressed in absolute coordinates.
virtual voidgetVisibleRect(Rect & rect) const
Function for finding the visible part of this drawable.
int16_tgetWidth() const
Gets the width of this Drawable.
int16_tgetX() const
Gets the x coordinate of this Drawable, relative to its parent.
int16_tgetY() const
Gets the y coordinate of this Drawable, relative to its parent.
virtual voidhandleClickEvent(const ClickEvent & event)
Defines the event handler interface for ClickEvents.
virtual voidhandleDragEvent(const DragEvent & event)
Defines the event handler interface for DragEvents.
virtual voidhandleGestureEvent(const GestureEvent & event)
Defines the event handler interface for GestureEvents.
virtual voidinvalidate() const
Tell the framework that this entire Drawable needs to be redrawn.
virtual voidinvalidateContent() const
Tell the framework that the contents of the Drawable needs to be redrawn.
virtual voidinvalidateRect(Rect & invalidatedArea) const
Request that a region of this drawable is redrawn.
boolisTouchable() const
Gets whether this Drawable receives touch events or not.
boolisVisible() const
Gets whether this Drawable is visible.
virtual voidmoveRelative(int16_t x, int16_t y)
Moves the drawable.
virtual voidmoveTo(int16_t x, int16_t y)
Moves the drawable.
virtual voidsetHeight(int16_t height)
Sets the height of this drawable.
voidsetPosition(const Drawable & drawable)
Sets the position of the Drawable to the same as the given Drawable.
voidsetPosition(int16_t x, int16_t y, int16_t width, int16_t height)
Sets the size and position of this Drawable, relative to its parent.
voidsetTouchable(bool touch)
Controls whether this Drawable receives touch events or not.
voidsetVisible(bool vis)
Controls whether this Drawable should be visible.
virtual voidsetWidth(int16_t width)
Sets the width of this drawable.
voidsetWidthHeight(const Bitmap & bitmap)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
voidsetWidthHeight(const Drawable & drawable)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
voidsetWidthHeight(const Rect & other)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
voidsetWidthHeight(int16_t width, int16_t height)
Sets the dimensions (width and height) of the Drawable without changing the x and y coordinates).
virtual voidsetX(int16_t x)
Sets the x coordinate of this Drawable, relative to its parent.
voidsetXY(const Drawable & drawable)
Sets the x and y coordinates of this Drawable.
voidsetXY(int16_t x, int16_t y)
Sets the x and y coordinates of this Drawable, relative to its parent.
virtual voidsetY(int16_t y)
Sets the y coordinate of this Drawable, relative to its parent.
virtual voidtranslateRectToAbsolute(Rect & r) const
Helper function for converting a region of this Drawable to absolute coordinates.
virtual ~Drawable()
Finalizes an instance of the Drawable class.

Protected Attributes inherited from Drawable

Drawable *nextSibling
Pointer to the next Drawable.
Drawable *parent
Pointer to this drawable's parent.
Rectrect
The coordinates of this Drawable, relative to its parent.
booltouchable
True if this drawable should receive touch events.
boolvisible
True if this drawable should be drawn.

Public Functions Documentation

AnimatedImage

AnimatedImage(const BitmapId &start ,
const BitmapId &end ,
const uint8_t &updateInterval =1
)

Constructs an AnimatedImage.

The start and the end specifies the range of bitmaps to be used for animation. The update interval defines how often the animation should be updated. The animation will iterate over the bitmaps that lies between the IDs of start and end, both included.

Parameters:
startDefines the start of the range of images in the animation.
endDefines the end of the range of images in the animation.
updateInterval(Optional) Defines the number of ticks between each animation step. Higher value results in a slower animation. Default is to update the image on every tick.

AnimatedImage

AnimatedImage(const uint8_t &updateInterval =1)

Constructs an AnimatedImage without initializing bitmaps.

Parameters:
updateInterval(Optional) Defines the number of ticks between each animation step. Higher value results in a slower animation.
Note

The bitmaps to display must be configured through set setBitmaps function before this widget displays anything.

handleTickEvent

virtual void handleTickEvent()

Called periodically by the framework if the Drawable instance has subscribed to timer ticks.

See also:

Reimplements: touchgfx::Drawable::handleTickEvent

isAnimatedImageRunning

Gets the running state of the AnimatedImage.

Returns:

true if the animation is currently running, false otherwise.

isReverse

bool isReverse()

Query if this object is running in reverse.

Returns:

true if the animation is performed in reverse order.

pauseAnimation

virtual void pauseAnimation()

Toggles the running state of an animation.

Pauses the animation if the animation is running. Continues the animation if previously paused.

See also:

setBitmap

virtual void setBitmap(const Bitmap &bmp)

Sets the bitmap for this Image and updates the width and height of this widget to match those of the Bitmap.

Parameters:
bmpThe bitmap instance.
Note

The user code must call invalidate() in order to update the image on the display.This only sets the start image.

See also:

Reimplements: touchgfx::Image::setBitmap

setBitmapEnd

virtual void setBitmapEnd(const Bitmap &bmp)

Sets the end bitmap for this AnimatedImage sequence.

Parameters:
bmpThe bitmap.
See also:

setBitmaps

void setBitmaps(BitmapIdstart ,
BitmapIdend
)

Sets the bitmaps that are used by the animation.

The animation will iterate over the bitmaps that lies between the IDs of start and end, both inclusive.

Parameters:
startDefines the start of the range of images in the animation.
endDefines the end of the range of images in the animation.
See also:

setDoneAction

void setDoneAction(GenericCallback< const AnimatedImage & > &callback)

Associates an action to be performed when the animation of the AnimatedImage is done.

If the animation is set to loop at the end, the action is also triggered when the animation starts over.

Parameters:
callbackThe callback is executed when done. The callback is given the animated image.

setUpdateTicksInterval

void setUpdateTicksInterval(uint8_tupdateInterval)

Sets the update interval.

The value specifies the number of ticks between each step of the animation. The default update interval for animated images is 1, which means results in the fastest possible animation.

Parameters:
updateIntervalDefines the number of ticks between each animation step. Higher value results in a slower animation.

startAnimation

virtual void startAnimation(const boolrev ,
const boolreset =false,
const boolloop =false
)

Starts the animation with the given parameters for animation direction, normal or reverse, whether to restart the animation and finally if the animation should loop automatically upon completion.

Parameters:
revDefines if the animation should be performed in reverse order.
reset(Optional) Defines if the animation should reset and start from the first (or last if reverse order) bitmap.
loop(Optional) Defines if the animation should loop or do a single animation.

stopAnimation

virtual void stopAnimation()

Stops and resets the animation.

If the animation should not reset to the first image in the animation sequence, use pauseAnimation().

See also:

Protected Attributes Documentation

animationDoneAction

GenericCallback< const AnimatedImage & > * animationDoneAction

Pointer to the callback to be executed when animation is done.

endId

BitmapId endId

Id of last bitmap in animation.

loopAnimation

bool loopAnimation

If true, continuously loop animation.

reverse

bool reverse

If true, run in reverse direction (last to first).

running

bool running

If true, animation is running.

startId

BitmapId startId

Id of first bitmap in animation.

ticksSinceUpdate

uint8_t ticksSinceUpdate

Number of ticks since last animation update.

updateTicksInterval

uint8_t updateTicksInterval

Number of ticks between each animation update (image change).