Fix C++ compilation

After adding an Image in a builtin struct, some code and include need to
be moved a bit around
This commit is contained in:
Olivier Goffart 2025-05-19 17:52:24 +02:00
parent c09ed19a85
commit de9eb69f60
3 changed files with 11 additions and 20 deletions

View file

@ -14,9 +14,6 @@ fn enums(path: &Path) -> anyhow::Result<()> {
);
writeln!(enums_priv, "#pragma once")?;
writeln!(enums_priv, "// This file is auto-generated from {}", file!())?;
writeln!(enums_priv, "#include <slint_properties.h>")?;
writeln!(enums_priv, "#include <slint_color.h>")?;
writeln!(enums_priv, "#include <slint_image.h>")?;
writeln!(enums_priv, "#include \"slint_enums.h\"")?;
writeln!(enums_priv, "namespace slint::cbindgen_private {{")?;
let mut enums_pub = BufWriter::new(
@ -123,6 +120,7 @@ fn builtin_structs(path: &Path) -> anyhow::Result<()> {
writeln!(structs_priv, "#include \"slint_builtin_structs.h\"")?;
writeln!(structs_priv, "#include \"slint_enums_internal.h\"")?;
writeln!(structs_priv, "#include \"slint_point.h\"")?;
writeln!(structs_priv, "#include \"slint_image.h\"")?;
writeln!(structs_priv, "namespace slint::cbindgen_private {{")?;
writeln!(structs_priv, "enum class KeyEventType : uint8_t;")?;
macro_rules! struct_file {
@ -500,7 +498,7 @@ fn gen_corelib(
"BorrowedOpenGLTextureOrigin"
],
"slint_image_internal.h",
"namespace slint::cbindgen_private { struct ParsedSVG{}; struct HTMLImage{}; using namespace vtable; namespace types{ struct NineSliceImage{}; } }",
"#include \"slint_color.h\"\nnamespace slint::cbindgen_private { struct ParsedSVG{}; struct HTMLImage{}; using namespace vtable; namespace types{ struct NineSliceImage{}; } }",
),
(
vec!["Color", "slint_color_brighter", "slint_color_darker",

View file

@ -4,9 +4,6 @@
#pragma once
#include "slint_color_internal.h"
#include "slint_properties.h"
#include <stdint.h>
namespace slint {
@ -285,17 +282,4 @@ 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,
const cbindgen_private::PropertyAnimation &animation_data) const
{
cbindgen_private::slint_property_set_animated_value_color(&inner, value, new_value,
&animation_data);
}
} // namespace private_api
} // namespace slint

View file

@ -212,6 +212,15 @@ Property<float>::set_animated_value(const float &new_value,
&animation_data);
}
template<>
inline void
Property<Color>::set_animated_value(const Color &new_value,
const cbindgen_private::PropertyAnimation &animation_data) const
{
cbindgen_private::slint_property_set_animated_value_color(&inner, value, new_value,
&animation_data);
}
template<typename F>
void set_state_binding(const Property<StateInfo> &property, F binding)
{