mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
More work on state properties with transitions
C++ set the proper binding for StateInfo state binding
This commit is contained in:
parent
cfa9413861
commit
c50fc6f51c
5 changed files with 69 additions and 41 deletions
|
@ -21,6 +21,8 @@ struct PropertyAnimation;
|
|||
|
||||
namespace sixtyfps {
|
||||
|
||||
using cbindgen_private::StateInfo;
|
||||
|
||||
template<typename T>
|
||||
struct Property
|
||||
{
|
||||
|
@ -112,6 +114,7 @@ struct Property
|
|||
private:
|
||||
cbindgen_private::PropertyHandleOpaque inner;
|
||||
mutable T value {};
|
||||
template<typename F> friend void set_state_binding(const Property<StateInfo> &property, F binding);
|
||||
};
|
||||
|
||||
template<>
|
||||
|
@ -158,6 +161,15 @@ void Property<float>::set_animated_binding(
|
|||
&animation_data);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
void set_state_binding(const Property<StateInfo> &property, F binding) {
|
||||
cbindgen_private::sixtyfps_property_set_state_binding(
|
||||
&property.inner,
|
||||
[](void *user_data) -> int32_t { return (*reinterpret_cast<F *>(user_data))(); },
|
||||
new F(binding),
|
||||
[](void *user_data) { delete reinterpret_cast<F *>(user_data); });
|
||||
}
|
||||
|
||||
struct PropertyTracker
|
||||
{
|
||||
PropertyTracker() { cbindgen_private::sixtyfps_property_tracker_init(&inner); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue