@@ -261,10 +261,10 @@ unsafe fn c_set_animated_binding<T: InterpolatedPropertyValue + Clone>(
261261 binding : extern "C" fn ( * mut c_void , * mut T ) ,
262262 user_data : * mut c_void ,
263263 drop_user_data : Option < extern "C" fn ( * mut c_void ) > ,
264- animation_data : Option < & PropertyAnimation > ,
265- transition_data : Option <
266- extern "C" fn ( user_data : * mut c_void , start_instant : & mut u64 ) -> PropertyAnimation ,
267- > ,
264+ transition_data : extern "C" fn (
265+ user_data : * mut c_void ,
266+ start_instant : & mut * mut u64 ,
267+ ) -> PropertyAnimation ,
268268) {
269269 unsafe {
270270 let binding = core:: mem:: transmute :: <
@@ -286,27 +286,31 @@ unsafe fn c_set_animated_binding<T: InterpolatedPropertyValue + Clone>(
286286 let animation_data = RefCell :: new ( properties_animations:: PropertyValueAnimationData :: new (
287287 T :: default ( ) ,
288288 T :: default ( ) ,
289- animation_data . cloned ( ) . unwrap_or_default ( ) ,
289+ PropertyAnimation :: default ( ) ,
290290 ) ) ;
291- if let Some ( transition_data) = transition_data {
292- handle. 0 . set_binding ( properties_animations:: AnimatedBindingCallable :: < T , _ > {
293- original_binding,
294- state : Cell :: new ( properties_animations:: AnimatedBindingState :: NotAnimating ) ,
295- animation_data,
296- compute_animation_details : move || -> properties_animations:: AnimationDetail {
297- let mut start_instant = 0 ;
298- let anim = transition_data ( user_data, & mut start_instant) ;
299- Some ( ( anim, crate :: animations:: Instant ( start_instant) ) )
300- } ,
301- } ) ;
302- } else {
303- handle. 0 . set_binding ( properties_animations:: AnimatedBindingCallable :: < T , _ > {
304- original_binding,
305- state : Cell :: new ( properties_animations:: AnimatedBindingState :: NotAnimating ) ,
306- animation_data,
307- compute_animation_details : || -> properties_animations:: AnimationDetail { None } ,
308- } ) ;
309- }
291+
292+ handle. 0 . set_binding ( properties_animations:: AnimatedBindingCallable :: < T , _ > {
293+ original_binding,
294+ state : Cell :: new ( properties_animations:: AnimatedBindingState :: NotAnimating ) ,
295+ animation_data,
296+ compute_animation_details : move || -> properties_animations:: AnimationDetail {
297+ // The transition_data function receives a *mut *mut u64 pointer for the
298+ // timestamp.
299+ // If the function sets the pointer to nullptr, it doesn't provide a start_time.
300+ // Otherwise, we assume it has written a value to the start_instant.
301+ // This basically models a `&mut Option<u64>`, which is then converted to an
302+ // `Option<Instant>`
303+ let mut start_instant = 0u64 ;
304+ let mut start_instant_ref = & mut start_instant as * mut u64 ;
305+ let anim = transition_data ( user_data, & mut start_instant_ref) ;
306+ let start_instant = if start_instant_ref. is_null ( ) {
307+ None
308+ } else {
309+ Some ( crate :: animations:: Instant ( start_instant) )
310+ } ;
311+ ( anim, start_instant)
312+ } ,
313+ } ) ;
310314 handle. 0 . mark_dirty ( ) ;
311315 }
312316}
@@ -318,20 +322,13 @@ pub unsafe extern "C" fn slint_property_set_animated_binding_int(
318322 binding : extern "C" fn ( * mut c_void , * mut core:: ffi:: c_int ) ,
319323 user_data : * mut c_void ,
320324 drop_user_data : Option < extern "C" fn ( * mut c_void ) > ,
321- animation_data : Option < & PropertyAnimation > ,
322- transition_data : Option <
323- extern "C" fn ( user_data : * mut c_void , start_instant : & mut u64 ) -> PropertyAnimation ,
324- > ,
325+ transition_data : extern "C" fn (
326+ user_data : * mut c_void ,
327+ start_instant : & mut * mut u64 ,
328+ ) -> PropertyAnimation ,
325329) {
326330 unsafe {
327- c_set_animated_binding (
328- handle,
329- binding,
330- user_data,
331- drop_user_data,
332- animation_data,
333- transition_data,
334- ) ;
331+ c_set_animated_binding ( handle, binding, user_data, drop_user_data, transition_data) ;
335332 }
336333}
337334
@@ -342,20 +339,13 @@ pub unsafe extern "C" fn slint_property_set_animated_binding_float(
342339 binding : extern "C" fn ( * mut c_void , * mut f32 ) ,
343340 user_data : * mut c_void ,
344341 drop_user_data : Option < extern "C" fn ( * mut c_void ) > ,
345- animation_data : Option < & PropertyAnimation > ,
346- transition_data : Option <
347- extern "C" fn ( user_data : * mut c_void , start_instant : & mut u64 ) -> PropertyAnimation ,
348- > ,
342+ transition_data : extern "C" fn (
343+ user_data : * mut c_void ,
344+ start_instant : & mut * mut u64 ,
345+ ) -> PropertyAnimation ,
349346) {
350347 unsafe {
351- c_set_animated_binding (
352- handle,
353- binding,
354- user_data,
355- drop_user_data,
356- animation_data,
357- transition_data,
358- ) ;
348+ c_set_animated_binding ( handle, binding, user_data, drop_user_data, transition_data) ;
359349 }
360350}
361351
@@ -366,20 +356,13 @@ pub unsafe extern "C" fn slint_property_set_animated_binding_color(
366356 binding : extern "C" fn ( * mut c_void , * mut Color ) ,
367357 user_data : * mut c_void ,
368358 drop_user_data : Option < extern "C" fn ( * mut c_void ) > ,
369- animation_data : Option < & PropertyAnimation > ,
370- transition_data : Option <
371- extern "C" fn ( user_data : * mut c_void , start_instant : & mut u64 ) -> PropertyAnimation ,
372- > ,
359+ transition_data : extern "C" fn (
360+ user_data : * mut c_void ,
361+ start_instant : & mut * mut u64 ,
362+ ) -> PropertyAnimation ,
373363) {
374364 unsafe {
375- c_set_animated_binding (
376- handle,
377- binding,
378- user_data,
379- drop_user_data,
380- animation_data,
381- transition_data,
382- ) ;
365+ c_set_animated_binding ( handle, binding, user_data, drop_user_data, transition_data) ;
383366 }
384367}
385368
@@ -390,20 +373,13 @@ pub unsafe extern "C" fn slint_property_set_animated_binding_brush(
390373 binding : extern "C" fn ( * mut c_void , * mut Brush ) ,
391374 user_data : * mut c_void ,
392375 drop_user_data : Option < extern "C" fn ( * mut c_void ) > ,
393- animation_data : Option < & PropertyAnimation > ,
394- transition_data : Option <
395- extern "C" fn ( user_data : * mut c_void , start_instant : & mut u64 ) -> PropertyAnimation ,
396- > ,
376+ transition_data : extern "C" fn (
377+ user_data : * mut c_void ,
378+ start_instant : & mut * mut u64 ,
379+ ) -> PropertyAnimation ,
397380) {
398381 unsafe {
399- c_set_animated_binding (
400- handle,
401- binding,
402- user_data,
403- drop_user_data,
404- animation_data,
405- transition_data,
406- ) ;
382+ c_set_animated_binding ( handle, binding, user_data, drop_user_data, transition_data) ;
407383 }
408384}
409385
0 commit comments