diff --git a/api/sixtyfps-cpp/include/sixtyfps.h b/api/sixtyfps-cpp/include/sixtyfps.h index 6be2d0b67..654be49e5 100644 --- a/api/sixtyfps-cpp/include/sixtyfps.h +++ b/api/sixtyfps-cpp/include/sixtyfps.h @@ -477,7 +477,7 @@ public: template class Repeater { - Property>> model; + private_api::Property>> model; #if !defined(DOXYGEN) // hide from public API struct RepeaterInner : AbstractRepeaterView @@ -489,7 +489,7 @@ class Repeater std::optional> ptr; }; std::vector data; - Property is_dirty { true }; + private_api::Property is_dirty { true }; void row_added(int index, int count) override { @@ -559,9 +559,10 @@ public: } template - void ensure_updated_listview(const Parent *parent, const Property *viewport_width, - const Property *viewport_height, - [[maybe_unused]] const Property *viewport_y, + void ensure_updated_listview(const Parent *parent, + const private_api::Property *viewport_width, + const private_api::Property *viewport_height, + [[maybe_unused]] const private_api::Property *viewport_y, float listview_width, [[maybe_unused]] float listview_height) const { // TODO: the rust code in model.rs try to only allocate as many items as visible items @@ -589,7 +590,8 @@ public: return { &C::static_vtable, const_cast(&(**x.ptr)) }; } - float compute_layout_listview(const Property *viewport_width, float listview_width) const + float compute_layout_listview(const private_api::Property *viewport_width, + float listview_width) const { float offset = 0; viewport_width->set(listview_width); diff --git a/api/sixtyfps-cpp/include/sixtyfps_color.h b/api/sixtyfps-cpp/include/sixtyfps_color.h index 7da0e04fb..3bc9e8612 100644 --- a/api/sixtyfps-cpp/include/sixtyfps_color.h +++ b/api/sixtyfps-cpp/include/sixtyfps_color.h @@ -209,6 +209,8 @@ RgbaColor Color::to_argb_float() const return RgbaColor(*this); } +namespace private_api { + template<> inline void Property::set_animated_value(const Color &new_value, @@ -218,4 +220,6 @@ Property::set_animated_value(const Color &new_value, &animation_data); } -} +} // namespace private_api + +} // namespace sixtyfps diff --git a/api/sixtyfps-cpp/include/sixtyfps_properties.h b/api/sixtyfps-cpp/include/sixtyfps_properties.h index a716a4d2d..fc79e8a9b 100644 --- a/api/sixtyfps-cpp/include/sixtyfps_properties.h +++ b/api/sixtyfps-cpp/include/sixtyfps_properties.h @@ -65,8 +65,6 @@ inline void sixtyfps_property_set_animated_binding_helper( handle, binding, user_data, drop_user_data, animation_data, transition_data); } -} - template struct Property { @@ -303,4 +301,6 @@ private: cbindgen_private::PropertyTrackerOpaque inner; }; +} // namespace private_api + } // namespace sixtyfps diff --git a/api/sixtyfps-cpp/tests/datastructures.cpp b/api/sixtyfps-cpp/tests/datastructures.cpp index eeac62631..45aa8d603 100644 --- a/api/sixtyfps-cpp/tests/datastructures.cpp +++ b/api/sixtyfps-cpp/tests/datastructures.cpp @@ -53,7 +53,7 @@ TEST_CASE("Basic SharedVector API", "[vector]") TEST_CASE("Property Tracker") { - using namespace sixtyfps; + using namespace sixtyfps::private_api; PropertyTracker tracker1; PropertyTracker tracker2; Property prop(42); diff --git a/sixtyfps_compiler/generator/cpp.rs b/sixtyfps_compiler/generator/cpp.rs index 4bb2461a6..d7001078b 100644 --- a/sixtyfps_compiler/generator/cpp.rs +++ b/sixtyfps_compiler/generator/cpp.rs @@ -373,7 +373,7 @@ fn handle_property_binding( )); } else if let Expression::TwoWayBinding(nr, next) = &binding_expression { init.push(format!( - "sixtyfps::Property<{ty}>::link_two_way(&{p1}, &{p2});", + "sixtyfps::private_api::Property<{ty}>::link_two_way(&{p1}, &{p2});", ty = prop_type.cpp_type().unwrap_or_default(), p1 = access_member(elem, prop_name, &component, "this"), p2 = access_named_reference(nr, &component, "this") @@ -400,7 +400,7 @@ fn handle_property_binding( let is_state_info = matches!(prop_type, Type::Struct { name: Some(name), .. } if name.ends_with("::StateInfo")); if is_state_info { - format!("sixtyfps::set_state_binding({}, {});", cpp_prop, binding_code) + format!("sixtyfps::private_api::set_state_binding({}, {});", cpp_prop, binding_code) } else { match item.property_animations.get(prop_name) { Some(crate::object_tree::PropertyAnimation::Static(anim)) => { @@ -754,7 +754,7 @@ fn generate_component( }), )); } - format!("sixtyfps::Property<{}>", cpp_type) + format!("sixtyfps::private_api::Property<{}>", cpp_type) }; if property_decl.is_alias.is_none() { @@ -775,7 +775,7 @@ fn generate_component( component_struct.members.push(( Access::Private, Declaration::Var(Var { - ty: "sixtyfps::Property".into(), + ty: "sixtyfps::private_api::Property".into(), name: "index".into(), init: None, }), @@ -784,7 +784,7 @@ fn generate_component( component_struct.members.push(( Access::Private, Declaration::Var(Var { - ty: format!("sixtyfps::Property<{}>", cpp_model_data_type), + ty: format!("sixtyfps::private_api::Property<{}>", cpp_model_data_type), name: "model_data".into(), init: None, }), @@ -847,7 +847,7 @@ fn generate_component( Declaration::Function(Function { name: "listview_layout".into(), signature: - "(float *offset_y, const sixtyfps::Property *viewport_width) const -> void" + "(float *offset_y, const sixtyfps::private_api::Property *viewport_width) const -> void" .to_owned(), statements: Some(vec![ "float vp_w = viewport_width->get();".to_owned(), diff --git a/xtask/src/cbindgen.rs b/xtask/src/cbindgen.rs index b20ac6a29..5eaefa416 100644 --- a/xtask/src/cbindgen.rs +++ b/xtask/src/cbindgen.rs @@ -308,7 +308,7 @@ fn gen_corelib(root_dir: &Path, include_dir: &Path) -> anyhow::Result<()> { r" namespace sixtyfps {{ namespace private_api {{ enum class VersionCheck {{ Major = {}, Minor = {}, Patch = {} }}; class ComponentWindow; }} - namespace cbindgen_private {{ using sixtyfps::private_api::ComponentWindow; using namespace vtable; struct KeyEvent; }} + namespace cbindgen_private {{ using sixtyfps::private_api::ComponentWindow; using namespace vtable; struct KeyEvent; using namespace private_api; }} }}", 0, 0, 6, ))