Hide Property<T> and PropertyTracker<T> from the public C++ API

Move those two classes into the private_api namespace, which is excluded
from the API reference documentation.

For generate code the explicit qualification of Property<T> is changed,
for the cbindgen generated item types the private_api namespace is
pulled into the cbindgen_private namespace.
This commit is contained in:
Simon Hausmann 2021-06-21 11:38:51 +02:00 committed by Simon Hausmann
parent 596912a521
commit 7f8f1b3105
6 changed files with 23 additions and 17 deletions

View file

@ -477,7 +477,7 @@ public:
template<typename C, typename ModelData>
class Repeater
{
Property<std::shared_ptr<Model<ModelData>>> model;
private_api::Property<std::shared_ptr<Model<ModelData>>> model;
#if !defined(DOXYGEN) // hide from public API
struct RepeaterInner : AbstractRepeaterView
@ -489,7 +489,7 @@ class Repeater
std::optional<ComponentHandle<C>> ptr;
};
std::vector<ComponentWithState> data;
Property<bool> is_dirty { true };
private_api::Property<bool> is_dirty { true };
void row_added(int index, int count) override
{
@ -559,9 +559,10 @@ public:
}
template<typename Parent>
void ensure_updated_listview(const Parent *parent, const Property<float> *viewport_width,
const Property<float> *viewport_height,
[[maybe_unused]] const Property<float> *viewport_y,
void ensure_updated_listview(const Parent *parent,
const private_api::Property<float> *viewport_width,
const private_api::Property<float> *viewport_height,
[[maybe_unused]] const private_api::Property<float> *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<C *>(&(**x.ptr)) };
}
float compute_layout_listview(const Property<float> *viewport_width, float listview_width) const
float compute_layout_listview(const private_api::Property<float> *viewport_width,
float listview_width) const
{
float offset = 0;
viewport_width->set(listview_width);

View file

@ -209,6 +209,8 @@ RgbaColor<float> Color::to_argb_float() const
return RgbaColor<float>(*this);
}
namespace private_api {
template<>
inline void
Property<Color>::set_animated_value(const Color &new_value,
@ -218,4 +220,6 @@ Property<Color>::set_animated_value(const Color &new_value,
&animation_data);
}
}
} // namespace private_api
} // namespace sixtyfps

View file

@ -65,8 +65,6 @@ inline void sixtyfps_property_set_animated_binding_helper(
handle, binding, user_data, drop_user_data, animation_data, transition_data);
}
}
template<typename T>
struct Property
{
@ -303,4 +301,6 @@ private:
cbindgen_private::PropertyTrackerOpaque inner;
};
} // namespace private_api
} // namespace sixtyfps