BSB Developer Docs
Loading...
Searching...
No Matches
anim_player.h File Reference

A widget that plays an AnimFile. More...

#include <gui/widget.h>
#include <anim_file/anim_file.h>

Go to the source code of this file.

Typedefs

typedef struct AnimPlayer AnimPlayer
 
typedef void(* AnimPlayerFrameCallback) (AnimPlayer *instance, const AnimFileFrameInfo *info, void *context)
 Playback frame callback.
 

Enumerations

enum  AnimPlayerOption { AnimPlayerOptionNone = 0 , AnimPlayerOptionIntermediateInternalBuffer , AnimPlayerOptionMAX }
 

Functions

AnimPlayer * anim_player_alloc (Widget *parent)
 Allocates an AnimPlayer GUI element that plays an animation file.
 
void anim_player_free (AnimPlayer *instance)
 Frees an AnimPlayer GUI element.
 
Widget * anim_player_get_base (AnimPlayer *instance)
 Base Widget class.
 
bool anim_player_set_source (AnimPlayer *instance, const char *path)
 Loads the animation file at the specified path.
 
bool anim_player_set_source_ex (AnimPlayer *instance, const char *path, AnimPlayerOption options)
 Loads the animation file at the specified path.
 
bool anim_player_set_offset (AnimPlayer *instance, float x, float y)
 Moves the animation within its widget's viewport.
 
bool anim_player_set_section (AnimPlayer *instance, AnimFilePlayFlag flags, const char *name)
 Sets the current section to be played back, using a section name.
 
bool anim_player_start (AnimPlayer *instance)
 Starts or resumes playback of the animation.
 
bool anim_player_pause (AnimPlayer *instance)
 Pauses playback of the animation.
 
void anim_player_set_frame_callback (AnimPlayer *instance, AnimPlayerFrameCallback callback, void *context)
 Calls the specified callback every time a frame is played.
 

Detailed Description

A widget that plays an AnimFile.

Typedef Documentation

◆ AnimPlayerFrameCallback

typedef void( * AnimPlayerFrameCallback) (AnimPlayer *instance, const AnimFileFrameInfo *info, void *context)

Playback frame callback.

Parameters
[in,out]instanceWidget instance
[in]infoInformation about the just-displayed frame
[in,out]contextCustom context

Function Documentation

◆ anim_player_alloc()

AnimPlayer * anim_player_alloc ( Widget * parent)

Allocates an AnimPlayer GUI element that plays an animation file.

Parameters
[in]parentParent widget
Returns
AnimPlayer GUI element

◆ anim_player_free()

void anim_player_free ( AnimPlayer * instance)

Frees an AnimPlayer GUI element.

Parameters
[in,out]instanceWidget instance

◆ anim_player_get_base()

Widget * anim_player_get_base ( AnimPlayer * instance)

Base Widget class.

Parameters
[in,out]instanceWidget instance
Returns
Base Widget class

◆ anim_player_pause()

bool anim_player_pause ( AnimPlayer * instance)

Pauses playback of the animation.

Parameters
[in,out]instanceWidget instance
Returns
success flag

◆ anim_player_set_frame_callback()

void anim_player_set_frame_callback ( AnimPlayer * instance,
AnimPlayerFrameCallback callback,
void * context )

Calls the specified callback every time a frame is played.

The callback is called from the GUI thread with locked GUI.

Parameters
[in,out]instanceWidget instance
[in]callbackMay be NULL to disable the callback
[in,out]contextCustom context. Must be NULL if callback is NULL.

◆ anim_player_set_offset()

bool anim_player_set_offset ( AnimPlayer * instance,
float x,
float y )

Moves the animation within its widget's viewport.

Parameters
[in,out]instanceWidget instance
[in]xX-axis coordinate (may be out of bounds or non-integer)
[in]yY-axis coordinate (may be out of bounds or non-integer)
Returns
true = operation successful

◆ anim_player_set_section()

bool anim_player_set_section ( AnimPlayer * instance,
AnimFilePlayFlag flags,
const char * name )

Sets the current section to be played back, using a section name.

Parameters
[in]instanceAnimPlayer instance
[in]flagsSee AnimFilePlayFlag
[in]nameName of the section (also see: ANIM_FILE_DEFAULT_SECTION)
Returns
Whether the operation was successful.

◆ anim_player_set_source()

bool anim_player_set_source ( AnimPlayer * instance,
const char * path )

Loads the animation file at the specified path.

If the provided path matches the previous given path which was successful, nothing is reloaded.

Parameters
[in,out]instanceWidget instance
[in]pathFile path
Returns
true = operation successful

◆ anim_player_set_source_ex()

bool anim_player_set_source_ex ( AnimPlayer * instance,
const char * path,
AnimPlayerOption options )

Loads the animation file at the specified path.

If the provided path matches the previous given path which was successful, nothing is reloaded.

Parameters
[in,out]instanceWidget instance
[in]pathFile path
[in]optionsBitmask of options (see AnimPlayerOption documentation)
Returns
true = operation successful

◆ anim_player_start()

bool anim_player_start ( AnimPlayer * instance)

Starts or resumes playback of the animation.

Note
Playback is automatically started in anim_player_set_source
Parameters
[in,out]instanceWidget instance
Returns
success flag