Add support for animating color properties

This commit is contained in:
Simon Hausmann 2020-06-27 16:51:48 +02:00
parent be75cb2b21
commit b8ca0fe3c9
9 changed files with 91 additions and 2 deletions

View file

@ -1,6 +1,7 @@
#pragma once
#include "sixtyfps_color_internal.h"
#include "sixtyfps_properties.h"
#include <stdint.h>
@ -30,4 +31,25 @@ private:
internal::types::Color inner;
};
template<>
void Property<Color>::set_animated_value(const Color &value,
const internal::PropertyAnimation &animation_data)
{
internal::sixtyfps_property_set_animated_value_color(&inner, &value, &animation_data);
}
template<>
template<typename F>
void Property<Color>::set_animated_binding(F binding,
const internal::PropertyAnimation &animation_data)
{
internal::sixtyfps_property_set_animated_binding_color(
&inner,
[](void *user_data, const internal::EvaluationContext *context, Color *value) {
*reinterpret_cast<Color *>(value) = (*reinterpret_cast<F *>(user_data))(context);
},
new F(binding), [](void *user_data) { delete reinterpret_cast<F *>(user_data); },
&animation_data);
}
}