Chesto 0.9
A declarative and element-based library for creating GUIs on homebrew'd consoles
Public Member Functions | Public Attributes | List of all members
Chesto::Animation Class Reference

Public Member Functions

 Animation (int startTime, int duration, std::function< void(float)> onStep, std::function< void()> onFinish)
 
bool isFinished ()
 
bool step ()
 

Public Attributes

int startTime = 0
 
int duration = 0
 
std::function< void(float)> onStep = NULL
 
std::function< void()> onFinish = NULL
 

Detailed Description

Definition at line 6 of file Animation.hpp.

Constructor & Destructor Documentation

◆ Animation()

Chesto::Animation::Animation ( int  startTime,
int  duration,
std::function< void(float)>  onStep,
std::function< void()>  onFinish 
)

Definition at line 6 of file Animation.cpp.

6 {
7 this->startTime = startTime;
8 this->duration = duration;
9 this->onStep = onStep;
10 this->onFinish = onFinish;
11}

Member Function Documentation

◆ isFinished()

bool Chesto::Animation::isFinished ( )

Definition at line 13 of file Animation.cpp.

13 {
14 return CST_GetTicks() > startTime + duration;
15}

◆ step()

bool Chesto::Animation::step ( )

Definition at line 17 of file Animation.cpp.

17 {
18 if (isFinished()) {
19 onFinish();
20 return true;
21 }
22
23 if (onStep != NULL) {
24 float progress = (float)(CST_GetTicks() - startTime) / (float)duration;
25 onStep(progress);
26 }
27 return false;
28}

Member Data Documentation

◆ duration

int Chesto::Animation::duration = 0

Definition at line 14 of file Animation.hpp.

◆ onFinish

std::function<void()> Chesto::Animation::onFinish = NULL

Definition at line 16 of file Animation.hpp.

◆ onStep

std::function<void(float)> Chesto::Animation::onStep = NULL

Definition at line 15 of file Animation.hpp.

◆ startTime

int Chesto::Animation::startTime = 0

Definition at line 13 of file Animation.hpp.


The documentation for this class was generated from the following files: