Use Point2D in the C++ ffi when setting the window position

This commit is contained in:
Simon Hausmann 2022-07-08 14:39:00 +02:00 committed by Simon Hausmann
parent 94b4f81be6
commit d6f8048232
3 changed files with 10 additions and 4 deletions

View file

@ -185,7 +185,7 @@ public:
void set_position(const slint::Point<int> &pos)
{
cbindgen_private::slint_windowrc_set_position(&inner, pos.x, pos.y);
cbindgen_private::slint_windowrc_set_position(&inner, &pos);
}
slint::Size<unsigned int> size() const { return cbindgen_private::slint_windowrc_size(&inner); }

View file

@ -19,4 +19,11 @@ struct Point
bool operator==(const Point &other) const = default;
};
namespace cbindgen_private {
// The Size types are expanded to the Point2D<...> type from the euclid crate which
// is binary compatible with Point<T>
template<typename T>
using Point2D = Point<T>;
}
}

View file

@ -945,11 +945,10 @@ pub mod ffi {
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_position(
handle: *const WindowRcOpaque,
x: i32,
y: i32,
pos: &euclid::default::Point2D<i32>,
) {
let window = &*(handle as *const WindowRc);
window.set_position([x, y].into());
window.set_position(euclid::Point2D::from_untyped(*pos));
}
/// Returns the size of the window on the screen, in physical screen coordinates and excluding