Replace a few qualified abi::primitives paths with uses

That'll make it easier to do the next rename :-)
This commit is contained in:
Simon Hausmann 2020-08-03 10:13:32 +02:00
parent 44109130f0
commit c29791fbaa
3 changed files with 21 additions and 27 deletions

View file

@ -593,13 +593,13 @@ impl<T: Clone + InterpolatedPropertyValue + 'static> Property<T> {
struct PropertyValueAnimationData<T> { struct PropertyValueAnimationData<T> {
from_value: T, from_value: T,
to_value: T, to_value: T,
details: crate::abi::primitives::PropertyAnimation, details: PropertyAnimation,
start_time: instant::Instant, start_time: instant::Instant,
loop_iteration: i32, loop_iteration: i32,
} }
impl<T: InterpolatedPropertyValue> PropertyValueAnimationData<T> { impl<T: InterpolatedPropertyValue> PropertyValueAnimationData<T> {
fn new(from_value: T, to_value: T, details: crate::abi::primitives::PropertyAnimation) -> Self { fn new(from_value: T, to_value: T, details: PropertyAnimation) -> Self {
let start_time = let start_time =
crate::animations::CURRENT_ANIMATION_DRIVER.with(|driver| driver.current_tick()); crate::animations::CURRENT_ANIMATION_DRIVER.with(|driver| driver.current_tick());
@ -691,8 +691,8 @@ impl<T: InterpolatedPropertyValue> BindingCallable for AnimatedBindingCallable<T
#[test] #[test]
fn properties_simple_test() { fn properties_simple_test() {
use std::rc::Rc;
use pin_weak::rc::PinWeak; use pin_weak::rc::PinWeak;
use std::rc::Rc;
fn g(prop: &Property<i32>) -> i32 { fn g(prop: &Property<i32>) -> i32 {
unsafe { Pin::new_unchecked(prop).get() } unsafe { Pin::new_unchecked(prop).get() }
} }
@ -845,7 +845,7 @@ fn c_set_animated_value<T: InterpolatedPropertyValue>(
handle: &PropertyHandleOpaque, handle: &PropertyHandleOpaque,
from: T, from: T,
to: T, to: T,
animation_data: &crate::abi::primitives::PropertyAnimation, animation_data: &PropertyAnimation,
) { ) {
let d = RefCell::new(PropertyValueAnimationData::new(from, to, animation_data.clone())); let d = RefCell::new(PropertyValueAnimationData::new(from, to, animation_data.clone()));
handle.0.set_binding(move |val: *mut ()| { handle.0.set_binding(move |val: *mut ()| {
@ -869,7 +869,7 @@ pub unsafe extern "C" fn sixtyfps_property_set_animated_value_int(
handle: &PropertyHandleOpaque, handle: &PropertyHandleOpaque,
from: i32, from: i32,
to: i32, to: i32,
animation_data: &crate::abi::primitives::PropertyAnimation, animation_data: &PropertyAnimation,
) { ) {
c_set_animated_value(handle, from, to, animation_data) c_set_animated_value(handle, from, to, animation_data)
} }
@ -880,7 +880,7 @@ pub unsafe extern "C" fn sixtyfps_property_set_animated_value_float(
handle: &PropertyHandleOpaque, handle: &PropertyHandleOpaque,
from: f32, from: f32,
to: f32, to: f32,
animation_data: &crate::abi::primitives::PropertyAnimation, animation_data: &PropertyAnimation,
) { ) {
c_set_animated_value(handle, from, to, animation_data) c_set_animated_value(handle, from, to, animation_data)
} }
@ -891,7 +891,7 @@ pub unsafe extern "C" fn sixtyfps_property_set_animated_value_color(
handle: &PropertyHandleOpaque, handle: &PropertyHandleOpaque,
from: Color, from: Color,
to: Color, to: Color,
animation_data: &crate::abi::primitives::PropertyAnimation, animation_data: &PropertyAnimation,
) { ) {
c_set_animated_value(handle, from, to, animation_data); c_set_animated_value(handle, from, to, animation_data);
} }
@ -901,7 +901,7 @@ unsafe fn c_set_animated_binding<T: InterpolatedPropertyValue>(
binding: extern "C" fn(*mut c_void, *mut T), binding: extern "C" fn(*mut c_void, *mut T),
user_data: *mut c_void, user_data: *mut c_void,
drop_user_data: Option<extern "C" fn(*mut c_void)>, drop_user_data: Option<extern "C" fn(*mut c_void)>,
animation_data: &crate::abi::primitives::PropertyAnimation, animation_data: &PropertyAnimation,
) { ) {
let binding = core::mem::transmute::< let binding = core::mem::transmute::<
extern "C" fn(*mut c_void, *mut T), extern "C" fn(*mut c_void, *mut T),
@ -932,7 +932,7 @@ pub unsafe extern "C" fn sixtyfps_property_set_animated_binding_int(
binding: extern "C" fn(*mut c_void, *mut i32), binding: extern "C" fn(*mut c_void, *mut i32),
user_data: *mut c_void, user_data: *mut c_void,
drop_user_data: Option<extern "C" fn(*mut c_void)>, drop_user_data: Option<extern "C" fn(*mut c_void)>,
animation_data: &crate::abi::primitives::PropertyAnimation, animation_data: &PropertyAnimation,
) { ) {
c_set_animated_binding(handle, binding, user_data, drop_user_data, animation_data); c_set_animated_binding(handle, binding, user_data, drop_user_data, animation_data);
} }
@ -944,7 +944,7 @@ pub unsafe extern "C" fn sixtyfps_property_set_animated_binding_float(
binding: extern "C" fn(*mut c_void, *mut f32), binding: extern "C" fn(*mut c_void, *mut f32),
user_data: *mut c_void, user_data: *mut c_void,
drop_user_data: Option<extern "C" fn(*mut c_void)>, drop_user_data: Option<extern "C" fn(*mut c_void)>,
animation_data: &crate::abi::primitives::PropertyAnimation, animation_data: &PropertyAnimation,
) { ) {
c_set_animated_binding(handle, binding, user_data, drop_user_data, animation_data); c_set_animated_binding(handle, binding, user_data, drop_user_data, animation_data);
} }
@ -956,7 +956,7 @@ pub unsafe extern "C" fn sixtyfps_property_set_animated_binding_color(
binding: extern "C" fn(*mut c_void, *mut Color), binding: extern "C" fn(*mut c_void, *mut Color),
user_data: *mut c_void, user_data: *mut c_void,
drop_user_data: Option<extern "C" fn(*mut c_void)>, drop_user_data: Option<extern "C" fn(*mut c_void)>,
animation_data: &crate::abi::primitives::PropertyAnimation, animation_data: &PropertyAnimation,
) { ) {
c_set_animated_binding(handle, binding, user_data, drop_user_data, animation_data); c_set_animated_binding(handle, binding, user_data, drop_user_data, animation_data);
} }

View file

@ -4,6 +4,7 @@
*/ */
pub type FieldOffset<T, U> = const_field_offset::FieldOffset<T, U, const_field_offset::PinnedFlag>; pub type FieldOffset<T, U> = const_field_offset::FieldOffset<T, U, const_field_offset::PinnedFlag>;
use crate::abi::primitives::PropertyAnimation;
use core::convert::{TryFrom, TryInto}; use core::convert::{TryFrom, TryInto};
use core::pin::Pin; use core::pin::Pin;
@ -33,13 +34,13 @@ pub trait PropertyInfo<Item, Value> {
&self, &self,
item: Pin<&Item>, item: Pin<&Item>,
value: Value, value: Value,
animation: Option<crate::abi::primitives::PropertyAnimation>, animation: Option<PropertyAnimation>,
) -> Result<(), ()>; ) -> Result<(), ()>;
fn set_binding( fn set_binding(
&self, &self,
item: Pin<&Item>, item: Pin<&Item>,
binding: Box<dyn Fn() -> Value>, binding: Box<dyn Fn() -> Value>,
animation: Option<crate::abi::primitives::PropertyAnimation>, animation: Option<PropertyAnimation>,
) -> Result<(), ()>; ) -> Result<(), ()>;
/// The offset of the property in the item. /// The offset of the property in the item.
@ -69,7 +70,7 @@ where
&self, &self,
item: Pin<&Item>, item: Pin<&Item>,
value: Value, value: Value,
animation: Option<crate::abi::primitives::PropertyAnimation>, animation: Option<PropertyAnimation>,
) -> Result<(), ()> { ) -> Result<(), ()> {
if animation.is_some() { if animation.is_some() {
Err(()) Err(())
@ -82,7 +83,7 @@ where
&self, &self,
item: Pin<&Item>, item: Pin<&Item>,
binding: Box<dyn Fn() -> Value>, binding: Box<dyn Fn() -> Value>,
animation: Option<crate::abi::primitives::PropertyAnimation>, animation: Option<PropertyAnimation>,
) -> Result<(), ()> { ) -> Result<(), ()> {
if animation.is_some() { if animation.is_some() {
Err(()) Err(())
@ -117,7 +118,7 @@ where
&self, &self,
item: Pin<&Item>, item: Pin<&Item>,
value: Value, value: Value,
animation: Option<crate::abi::primitives::PropertyAnimation>, animation: Option<PropertyAnimation>,
) -> Result<(), ()> { ) -> Result<(), ()> {
if let Some(animation) = &animation { if let Some(animation) = &animation {
self.apply_pin(item).set_animated_value(value.try_into().map_err(|_| ())?, animation); self.apply_pin(item).set_animated_value(value.try_into().map_err(|_| ())?, animation);
@ -130,7 +131,7 @@ where
&self, &self,
item: Pin<&Item>, item: Pin<&Item>,
binding: Box<dyn Fn() -> Value>, binding: Box<dyn Fn() -> Value>,
animation: Option<crate::abi::primitives::PropertyAnimation>, animation: Option<PropertyAnimation>,
) -> Result<(), ()> { ) -> Result<(), ()> {
if let Some(animation) = &animation { if let Some(animation) = &animation {
self.apply_pin(item).set_animated_binding( self.apply_pin(item).set_animated_binding(

View file

@ -11,7 +11,7 @@ use sixtyfps_corelib::abi::datastructures::{
ComponentVTable, ItemTreeNode, ItemVTable, ItemVisitorRefMut, LayoutInfo, Resource, ComponentVTable, ItemTreeNode, ItemVTable, ItemVisitorRefMut, LayoutInfo, Resource,
WindowProperties, WindowProperties,
}; };
use sixtyfps_corelib::abi::primitives::PropertyAnimation; use sixtyfps_corelib::abi::primitives::{Flickable, PropertyAnimation, Rectangle};
use sixtyfps_corelib::abi::{properties::PropertyListenerScope, slice::Slice}; use sixtyfps_corelib::abi::{properties::PropertyListenerScope, slice::Slice};
use sixtyfps_corelib::rtti::PropertyInfo; use sixtyfps_corelib::rtti::PropertyInfo;
use sixtyfps_corelib::ComponentRefPin; use sixtyfps_corelib::ComponentRefPin;
@ -279,16 +279,9 @@ fn generate_component(root_component: &Rc<object_tree::Component>) -> Rc<Compone
if is_flickable_rect { if is_flickable_rect {
use vtable::HasStaticVTable; use vtable::HasStaticVTable;
let offset = items_types[&item.id].offset let offset = items_types[&item.id].offset
+ sixtyfps_corelib::abi::primitives::Flickable::field_offsets() + Flickable::field_offsets().viewport.get_byte_offset();
.viewport
.get_byte_offset();
tree_array.push(ItemTreeNode::Item { tree_array.push(ItemTreeNode::Item {
item: unsafe { item: unsafe { vtable::VOffset::from_raw(Rectangle::static_vtable(), offset) },
vtable::VOffset::from_raw(
sixtyfps_corelib::abi::primitives::Rectangle::static_vtable(),
offset,
)
},
children_index: tree_array.len() as u32 + 1, children_index: tree_array.len() as u32 + 1,
chilren_count: item.children.len() as _, chilren_count: item.children.len() as _,
}); });