mirror of
https://github.com/hyprwm/hyprutils.git
synced 2025-12-20 04:40:08 +01:00
adapt Animation test
This commit is contained in:
parent
d981fe6a7c
commit
778e536a7f
1 changed files with 8 additions and 9 deletions
|
|
@ -21,7 +21,7 @@ template <typename VarType>
|
|||
using CAnimatedVariable = CGenericAnimatedVariable<VarType, EmtpyContext>;
|
||||
|
||||
template <typename VarType>
|
||||
using PANIMVAR = SP<CAnimatedVariable<VarType>>;
|
||||
using PANIMVAR = UP<CAnimatedVariable<VarType>>;
|
||||
|
||||
template <typename VarType>
|
||||
using PANIMVARREF = WP<CAnimatedVariable<VarType>>;
|
||||
|
|
@ -48,7 +48,7 @@ class CMyAnimationManager : public CAnimationManager {
|
|||
public:
|
||||
void tick() {
|
||||
for (size_t i = 0; i < m_vActiveAnimatedVariables.size(); i++) {
|
||||
const auto PAV = m_vActiveAnimatedVariables[i].lock();
|
||||
const auto PAV = m_vActiveAnimatedVariables[i];
|
||||
if (!PAV || !PAV->ok() || !PAV->isBeingAnimated())
|
||||
continue;
|
||||
|
||||
|
|
@ -93,11 +93,10 @@ class CMyAnimationManager : public CAnimationManager {
|
|||
template <typename VarType>
|
||||
void createAnimation(const VarType& v, PANIMVAR<VarType>& av, const std::string& animationConfigName) {
|
||||
constexpr const eAVTypes EAVTYPE = std::is_same_v<VarType, int> ? eAVTypes::INT : eAVTypes::TEST;
|
||||
const auto PAV = makeShared<CGenericAnimatedVariable<VarType, EmtpyContext>>();
|
||||
av = makeUnique<CGenericAnimatedVariable<VarType, EmtpyContext>>();
|
||||
|
||||
PAV->create(EAVTYPE, sc<CAnimationManager*>(this), PAV, v);
|
||||
PAV->setConfig(animationTree.getConfig(animationConfigName));
|
||||
av = std::move(PAV);
|
||||
av->create(EAVTYPE, sc<CAnimationManager*>(this), av, v);
|
||||
av->setConfig(animationTree.getConfig(animationConfigName));
|
||||
}
|
||||
|
||||
virtual void scheduleTick() {
|
||||
|
|
@ -298,7 +297,7 @@ TEST(Animation, animation) {
|
|||
// test adding / removing vars during a tick
|
||||
s.m_iA->resetAllCallbacks();
|
||||
s.m_iA->setUpdateCallback([&vars](WP<CBaseAnimatedVariable> v) {
|
||||
if (v.lock() != vars.back())
|
||||
if (v.get() != vars.back().get())
|
||||
vars.back()->warp();
|
||||
});
|
||||
s.m_iA->setCallbackOnEnd([&s, &vars](auto) {
|
||||
|
|
@ -350,7 +349,7 @@ TEST(Animation, animation) {
|
|||
*s.m_iA = 5;
|
||||
s.m_iA->setCallbackOnEnd([&endCallbackRan](WP<CBaseAnimatedVariable> v) {
|
||||
endCallbackRan++;
|
||||
const auto PAV = dc<CAnimatedVariable<int>*>(v.lock().get());
|
||||
const auto PAV = dc<CAnimatedVariable<int>*>(v.get());
|
||||
|
||||
*PAV = 10;
|
||||
PAV->setCallbackOnEnd([&endCallbackRan](WP<CBaseAnimatedVariable> v) { endCallbackRan++; });
|
||||
|
|
@ -394,4 +393,4 @@ TEST(Animation, animation) {
|
|||
} // a gets destroyed
|
||||
|
||||
EXPECT_EQ(pAnimationManager.get(), nullptr);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue