mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 05:44:52 +00:00
Implement property animations for C++
This commit is contained in:
parent
f50a705e00
commit
e6b386ab53
4 changed files with 241 additions and 32 deletions
|
@ -1,5 +1,12 @@
|
|||
#pragma once
|
||||
#include <string_view>
|
||||
|
||||
namespace sixtyfps {
|
||||
namespace internal {
|
||||
struct PropertyAnimation;
|
||||
}
|
||||
}
|
||||
|
||||
#include "sixtyfps_properties_internal.h"
|
||||
|
||||
namespace sixtyfps {
|
||||
|
@ -41,8 +48,56 @@ struct Property
|
|||
new F(binding), [](void *user_data) { delete reinterpret_cast<F *>(user_data); });
|
||||
}
|
||||
|
||||
inline void set_animated_value(const T &value,
|
||||
const internal::PropertyAnimation &animation_data);
|
||||
template<typename F>
|
||||
inline void set_animated_binding(F binding, const internal::PropertyAnimation &animation_data);
|
||||
|
||||
private:
|
||||
internal::PropertyHandleOpaque inner;
|
||||
mutable T value{};
|
||||
};
|
||||
|
||||
template<>
|
||||
void Property<int32_t>::set_animated_value(const int32_t &value,
|
||||
const internal::PropertyAnimation &animation_data)
|
||||
{
|
||||
internal::sixtyfps_property_set_animated_value_int(&inner, value, &animation_data);
|
||||
}
|
||||
|
||||
template<>
|
||||
void Property<float>::set_animated_value(const float &value,
|
||||
const internal::PropertyAnimation &animation_data)
|
||||
{
|
||||
internal::sixtyfps_property_set_animated_value_float(&inner, value, &animation_data);
|
||||
}
|
||||
|
||||
template<>
|
||||
template<typename F>
|
||||
void Property<int32_t>::set_animated_binding(F binding,
|
||||
const internal::PropertyAnimation &animation_data)
|
||||
{
|
||||
internal::sixtyfps_property_set_animated_binding_int(
|
||||
&inner,
|
||||
[](void *user_data, const internal::EvaluationContext *context, int32_t *value) {
|
||||
*reinterpret_cast<int32_t *>(value) = (*reinterpret_cast<F *>(user_data))(context);
|
||||
},
|
||||
new F(binding), [](void *user_data) { delete reinterpret_cast<F *>(user_data); },
|
||||
&animation_data);
|
||||
}
|
||||
|
||||
template<>
|
||||
template<typename F>
|
||||
void Property<float>::set_animated_binding(F binding,
|
||||
const internal::PropertyAnimation &animation_data)
|
||||
{
|
||||
internal::sixtyfps_property_set_animated_binding_float(
|
||||
&inner,
|
||||
[](void *user_data, const internal::EvaluationContext *context, float *value) {
|
||||
*reinterpret_cast<float *>(value) = (*reinterpret_cast<F *>(user_data))(context);
|
||||
},
|
||||
new F(binding), [](void *user_data) { delete reinterpret_cast<F *>(user_data); },
|
||||
&animation_data);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue