forked from CoretechR/OMOTE
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Animation class to help with animations
Add GetParent API to UIElement
- Loading branch information
MatthewColvin
committed
Oct 17, 2023
1 parent
efa2d4a
commit 73b9e7d
Showing
4 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "Animation.hpp" | ||
|
||
using namespace UI; | ||
|
||
Animation::Animation(std::function<void(int32_t)> aAnimator, | ||
int32_t aAnimationTime, int32_t aStart, int32_t aEnd) | ||
: mAnimator(aAnimator) { | ||
lv_anim_init(&mAnimation); | ||
mAnimation.user_data = this; | ||
lv_anim_set_custom_exec_cb(&mAnimation, AnimatorImpl); | ||
lv_anim_set_values(&mAnimation, aStart, aEnd); | ||
lv_anim_set_time(&mAnimation, aAnimationTime); | ||
} | ||
|
||
Animation::~Animation() { lv_anim_custom_del(&mAnimation, AnimatorImpl); } | ||
|
||
void Animation::Start() { lv_anim_start(&mAnimation); } | ||
|
||
//////////////////////// Statics ///////////////////////////////////////// | ||
|
||
void Animation::AnimatorImpl(lv_anim_t *aSelf, int32_t aNextValue) { | ||
auto self = reinterpret_cast<Animation *>(aSelf->user_data); | ||
self->mAnimator(aNextValue); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
#include <functional> | ||
#include <lvgl.h> | ||
|
||
namespace UI { | ||
|
||
class Animation { | ||
public: | ||
Animation(std::function<void(int32_t)> aAnimator, int32_t aAnimationTime, | ||
int32_t aStart = 0, int32_t aEnd = 100); | ||
|
||
virtual ~Animation(); | ||
|
||
void Start(); | ||
|
||
private: | ||
lv_anim_t mAnimation; | ||
std::function<void(int32_t)> mAnimator = nullptr; | ||
|
||
static void AnimatorImpl(lv_anim_t *aSelf, int32_t aNextValue); | ||
}; | ||
|
||
} // namespace UI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters