mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
C++: Do not expose private types in the sixtyfps namespace
This commit is contained in:
parent
be83d60bd8
commit
f9f90e1b4e
2 changed files with 23 additions and 30 deletions
|
@ -384,19 +384,7 @@ private:
|
|||
int64_t id;
|
||||
};
|
||||
|
||||
// layouts:
|
||||
using cbindgen_private::BoxLayoutCellData;
|
||||
using cbindgen_private::BoxLayoutData;
|
||||
using cbindgen_private::GridLayoutCellData;
|
||||
using cbindgen_private::GridLayoutData;
|
||||
using cbindgen_private::LayoutAlignment;
|
||||
using cbindgen_private::LayoutInfo;
|
||||
using cbindgen_private::Orientation;
|
||||
using cbindgen_private::Padding;
|
||||
using cbindgen_private::PathLayoutData;
|
||||
using cbindgen_private::Rect;
|
||||
|
||||
#if !defined(DOXYGEN)
|
||||
namespace cbindgen_private {
|
||||
inline LayoutInfo LayoutInfo::merge(const LayoutInfo &other) const
|
||||
{
|
||||
// Note: This "logic" is duplicated from LayoutInfo::merge in layout.rs.
|
||||
|
@ -407,10 +395,8 @@ inline LayoutInfo LayoutInfo::merge(const LayoutInfo &other) const
|
|||
std::max(preferred, other.preferred),
|
||||
std::min(stretch, other.stretch) };
|
||||
}
|
||||
#endif
|
||||
|
||||
/// FIXME! this should be done by cbindgen
|
||||
namespace cbindgen_private {
|
||||
inline bool operator==(const LayoutInfo &a, const LayoutInfo &b)
|
||||
{
|
||||
return a.min == b.min && a.max == b.max && a.min_percent == b.min_percent
|
||||
|
@ -425,7 +411,8 @@ inline bool operator!=(const LayoutInfo &a, const LayoutInfo &b)
|
|||
|
||||
namespace private_api {
|
||||
|
||||
inline SharedVector<float> solve_box_layout(const BoxLayoutData &data, Slice<int> repeater_indexes)
|
||||
inline SharedVector<float> solve_box_layout(const cbindgen_private::BoxLayoutData &data,
|
||||
Slice<int> repeater_indexes)
|
||||
{
|
||||
SharedVector<float> result;
|
||||
Slice<uint32_t> ri { reinterpret_cast<uint32_t *>(repeater_indexes.ptr), repeater_indexes.len };
|
||||
|
@ -433,31 +420,36 @@ inline SharedVector<float> solve_box_layout(const BoxLayoutData &data, Slice<int
|
|||
return result;
|
||||
}
|
||||
|
||||
inline SharedVector<float> solve_grid_layout(const GridLayoutData &data)
|
||||
inline SharedVector<float> solve_grid_layout(const cbindgen_private::GridLayoutData &data)
|
||||
{
|
||||
SharedVector<float> result;
|
||||
cbindgen_private::sixtyfps_solve_grid_layout(&data, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
inline LayoutInfo grid_layout_info(Slice<GridLayoutCellData> cells, float spacing,
|
||||
const Padding &padding)
|
||||
inline cbindgen_private::LayoutInfo
|
||||
grid_layout_info(Slice<cbindgen_private::GridLayoutCellData> cells, float spacing,
|
||||
const cbindgen_private::Padding &padding)
|
||||
{
|
||||
return cbindgen_private::sixtyfps_grid_layout_info(cells, spacing, &padding);
|
||||
}
|
||||
|
||||
inline LayoutInfo box_layout_info(Slice<BoxLayoutCellData> cells, float spacing,
|
||||
const Padding &padding, LayoutAlignment alignment)
|
||||
inline cbindgen_private::LayoutInfo
|
||||
box_layout_info(Slice<cbindgen_private::BoxLayoutCellData> cells, float spacing,
|
||||
const cbindgen_private::Padding &padding,
|
||||
cbindgen_private::LayoutAlignment alignment)
|
||||
{
|
||||
return cbindgen_private::sixtyfps_box_layout_info(cells, spacing, &padding, alignment);
|
||||
}
|
||||
|
||||
inline LayoutInfo box_layout_info_ortho(Slice<BoxLayoutCellData> cells, const Padding &padding)
|
||||
inline cbindgen_private::LayoutInfo
|
||||
box_layout_info_ortho(Slice<cbindgen_private::BoxLayoutCellData> cells,
|
||||
const cbindgen_private::Padding &padding)
|
||||
{
|
||||
return cbindgen_private::sixtyfps_box_layout_info_ortho(cells, &padding);
|
||||
}
|
||||
|
||||
inline SharedVector<float> solve_path_layout(const PathLayoutData &data,
|
||||
inline SharedVector<float> solve_path_layout(const cbindgen_private::PathLayoutData &data,
|
||||
Slice<int> repeater_indexes)
|
||||
{
|
||||
SharedVector<float> result;
|
||||
|
|
|
@ -345,8 +345,8 @@ impl CppType for Type {
|
|||
|
||||
fn to_cpp_orientation(o: Orientation) -> &'static str {
|
||||
match o {
|
||||
Orientation::Horizontal => "sixtyfps::Orientation::Horizontal",
|
||||
Orientation::Vertical => "sixtyfps::Orientation::Vertical",
|
||||
Orientation::Horizontal => "sixtyfps::cbindgen_private::Orientation::Horizontal",
|
||||
Orientation::Vertical => "sixtyfps::cbindgen_private::Orientation::Vertical",
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -925,7 +925,7 @@ fn generate_item_tree(
|
|||
Declaration::Function(Function {
|
||||
name: "layout_info".into(),
|
||||
signature:
|
||||
"([[maybe_unused]] sixtyfps::private_api::ComponentRef component, sixtyfps::Orientation o) -> sixtyfps::LayoutInfo"
|
||||
"([[maybe_unused]] sixtyfps::private_api::ComponentRef component, sixtyfps::cbindgen_private::Orientation o) -> sixtyfps::cbindgen_private::LayoutInfo"
|
||||
.into(),
|
||||
is_static: true,
|
||||
statements: Some(vec![format!(
|
||||
|
@ -1307,7 +1307,7 @@ fn generate_sub_component(
|
|||
Access::Public,
|
||||
Declaration::Function(Function {
|
||||
name: "layout_info".into(),
|
||||
signature: "(sixtyfps::cbindgen_private::Orientation o) const -> sixtyfps::LayoutInfo"
|
||||
signature: "(sixtyfps::cbindgen_private::Orientation o) const -> sixtyfps::cbindgen_private::LayoutInfo"
|
||||
.into(),
|
||||
statements: Some(vec![
|
||||
"[[maybe_unused]] auto self = this;".into(),
|
||||
|
@ -1421,7 +1421,7 @@ fn generate_repeated_component(
|
|||
Access::Public, // Because Repeater accesses it
|
||||
Declaration::Function(Function {
|
||||
name: "box_layout_data".into(),
|
||||
signature: "(sixtyfps::Orientation o) const -> sixtyfps::BoxLayoutCellData".to_owned(),
|
||||
signature: "(sixtyfps::cbindgen_private::Orientation o) const -> sixtyfps::cbindgen_private::BoxLayoutCellData".to_owned(),
|
||||
statements: Some(vec!["return { layout_info({&static_vtable, const_cast<void *>(static_cast<const void *>(this))}, o) };".into()]),
|
||||
|
||||
..Function::default()
|
||||
|
@ -2204,7 +2204,8 @@ fn box_layout_function(
|
|||
ctx: &llr_EvaluationContext<String>,
|
||||
) -> String {
|
||||
let repeated_indices = repeated_indices.map(ident);
|
||||
let mut push_code = "std::vector<sixtyfps::BoxLayoutCellData> cells_vector;".to_owned();
|
||||
let mut push_code =
|
||||
"std::vector<sixtyfps::cbindgen_private::BoxLayoutCellData> cells_vector;".to_owned();
|
||||
let mut repeater_idx = 0usize;
|
||||
|
||||
for item in elements {
|
||||
|
@ -2246,7 +2247,7 @@ fn box_layout_function(
|
|||
format!("std::array<int, {}> {}_array;", 2 * repeater_idx, ri)
|
||||
});
|
||||
format!(
|
||||
"[&]{{ {} {} sixtyfps::Slice<sixtyfps::BoxLayoutCellData>{}{{cells_vector.data(), cells_vector.size()}}; return {}; }}()",
|
||||
"[&]{{ {} {} sixtyfps::Slice<sixtyfps::cbindgen_private::BoxLayoutCellData>{}{{cells_vector.data(), cells_vector.size()}}; return {}; }}()",
|
||||
ri,
|
||||
push_code,
|
||||
ident(cells_variable),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue