mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 22:01:13 +00:00
C++: Hide AbstractRepeaterView, Repeater and ModelPeer
These are not public API.
This commit is contained in:
parent
f377b5db6c
commit
51bc21c9a5
3 changed files with 19 additions and 17 deletions
|
@ -333,12 +333,9 @@ inline LayoutInfo LayoutInfo::merge(const LayoutInfo &other) const
|
||||||
namespace cbindgen_private {
|
namespace cbindgen_private {
|
||||||
inline bool operator==(const LayoutInfo &a, const LayoutInfo &b)
|
inline bool operator==(const LayoutInfo &a, const LayoutInfo &b)
|
||||||
{
|
{
|
||||||
return a.min == b.min &&
|
return a.min == b.min && a.max == b.max && a.min_percent == b.min_percent
|
||||||
a.max == b.max &&
|
&& a.max_percent == b.max_percent && a.preferred == b.preferred
|
||||||
a.min_percent == b.min_percent &&
|
&& a.stretch == b.stretch;
|
||||||
a.max_percent == b.max_percent &&
|
|
||||||
a.preferred == b.preferred &&
|
|
||||||
a.stretch == b.stretch;
|
|
||||||
}
|
}
|
||||||
inline bool operator!=(const LayoutInfo &a, const LayoutInfo &b)
|
inline bool operator!=(const LayoutInfo &a, const LayoutInfo &b)
|
||||||
{
|
{
|
||||||
|
@ -346,6 +343,7 @@ inline bool operator!=(const LayoutInfo &a, const LayoutInfo &b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace private_api {
|
||||||
// models
|
// models
|
||||||
struct AbstractRepeaterView
|
struct AbstractRepeaterView
|
||||||
{
|
{
|
||||||
|
@ -356,6 +354,8 @@ struct AbstractRepeaterView
|
||||||
};
|
};
|
||||||
using ModelPeer = std::weak_ptr<AbstractRepeaterView>;
|
using ModelPeer = std::weak_ptr<AbstractRepeaterView>;
|
||||||
|
|
||||||
|
} // namespace private_api
|
||||||
|
|
||||||
template<typename ModelData>
|
template<typename ModelData>
|
||||||
class Model
|
class Model
|
||||||
{
|
{
|
||||||
|
@ -376,8 +376,9 @@ public:
|
||||||
/// row_changed.
|
/// row_changed.
|
||||||
virtual void set_row_data(int, const ModelData &) {};
|
virtual void set_row_data(int, const ModelData &) {};
|
||||||
|
|
||||||
|
/// \private
|
||||||
/// Internal function called by the view to register itself
|
/// Internal function called by the view to register itself
|
||||||
void attach_peer(ModelPeer p) { peers.push_back(std::move(p)); }
|
void attach_peer(private_api::ModelPeer p) { peers.push_back(std::move(p)); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Notify the views that a specific row was changed
|
/// Notify the views that a specific row was changed
|
||||||
|
@ -410,7 +411,7 @@ private:
|
||||||
}),
|
}),
|
||||||
peers.end());
|
peers.end());
|
||||||
}
|
}
|
||||||
std::vector<ModelPeer> peers;
|
std::vector<private_api::ModelPeer> peers;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A Model backed by an array of constant size
|
/// A Model backed by an array of constant size
|
||||||
|
@ -474,12 +475,13 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace private_api {
|
||||||
|
|
||||||
template<typename C, typename ModelData>
|
template<typename C, typename ModelData>
|
||||||
class Repeater
|
class Repeater
|
||||||
{
|
{
|
||||||
private_api::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
|
struct RepeaterInner : AbstractRepeaterView
|
||||||
{
|
{
|
||||||
enum class State { Clean, Dirty };
|
enum class State { Clean, Dirty };
|
||||||
|
@ -512,7 +514,6 @@ class Repeater
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif // !defined(DOXYGEN) -- hide from public API
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// FIXME: should be private, but layouting code uses it.
|
// FIXME: should be private, but layouting code uses it.
|
||||||
|
@ -620,6 +621,8 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace private_api
|
||||||
|
|
||||||
Flickable::Flickable()
|
Flickable::Flickable()
|
||||||
{
|
{
|
||||||
sixtyfps_flickable_data_init(&data);
|
sixtyfps_flickable_data_init(&data);
|
||||||
|
@ -674,12 +677,11 @@ inline void quit_event_loop()
|
||||||
/// You can use this to set properties or use any other SixtyFPS APIs from other threads,
|
/// You can use this to set properties or use any other SixtyFPS APIs from other threads,
|
||||||
/// by collecting the code in a functor and queuing it up for invocation within the event loop.
|
/// by collecting the code in a functor and queuing it up for invocation within the event loop.
|
||||||
template<typename Functor>
|
template<typename Functor>
|
||||||
void invoke_from_event_loop(Functor f) {
|
void invoke_from_event_loop(Functor f)
|
||||||
|
{
|
||||||
cbindgen_private::sixtyfps_post_event(
|
cbindgen_private::sixtyfps_post_event(
|
||||||
[](void *data) { (*reinterpret_cast<Functor *>(data))(); },
|
[](void *data) { (*reinterpret_cast<Functor *>(data))(); }, new Functor(std::move(f)),
|
||||||
new Functor(std::move(f)),
|
[](void *data) { delete reinterpret_cast<Functor *>(data); });
|
||||||
[](void *data) { delete reinterpret_cast<Functor *>(data); }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace private_api {
|
namespace private_api {
|
||||||
|
|
|
@ -440,7 +440,7 @@ inline Value::Value(const std::shared_ptr<sixtyfps::Model<Value>> &model)
|
||||||
{
|
{
|
||||||
using cbindgen_private::ModelAdaptorVTable;
|
using cbindgen_private::ModelAdaptorVTable;
|
||||||
using vtable::VRef;
|
using vtable::VRef;
|
||||||
struct ModelWrapper : AbstractRepeaterView
|
struct ModelWrapper : private_api::AbstractRepeaterView
|
||||||
{
|
{
|
||||||
std::shared_ptr<sixtyfps::Model<Value>> model;
|
std::shared_ptr<sixtyfps::Model<Value>> model;
|
||||||
cbindgen_private::ModelNotifyOpaque notify;
|
cbindgen_private::ModelNotifyOpaque notify;
|
||||||
|
|
|
@ -532,7 +532,7 @@ fn handle_repeater(
|
||||||
Access::Private,
|
Access::Private,
|
||||||
Declaration::Var(Var {
|
Declaration::Var(Var {
|
||||||
ty: format!(
|
ty: format!(
|
||||||
"sixtyfps::Repeater<class {}, {}>",
|
"sixtyfps::private_api::Repeater<class {}, {}>",
|
||||||
component_id(base_component),
|
component_id(base_component),
|
||||||
model_data_type(&parent_element, diag)
|
model_data_type(&parent_element, diag)
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue