Add API for setting and getting the size of a Window in Rust and C++

This commit is contained in:
Simon Hausmann 2022-07-07 21:42:49 +02:00 committed by Simon Hausmann
parent 372ad60a8f
commit 937c37677e
9 changed files with 146 additions and 8 deletions

View file

@ -188,6 +188,13 @@ public:
cbindgen_private::slint_windowrc_set_position(&inner, pos.x, pos.y);
}
slint::Size<unsigned int> size() const { return cbindgen_private::slint_windowrc_size(&inner); }
void set_size(const slint::Size<unsigned int> &size)
{
cbindgen_private::slint_windowrc_set_size(&inner, &size);
}
private:
cbindgen_private::WindowRcOpaque inner;
};
@ -386,6 +393,14 @@ public:
/// Note that on some windowing systems, such as Wayland, this functionality is not available.
void set_position(const slint::Point<int> &pos) { inner.set_position(pos); }
/// Returns the size of the window on the screen, in physical screen coordinates and excluding
/// a window frame (if present).
slint::Size<unsigned int> size() const { return inner.size(); }
/// Resizes the window to the specified size on the screen, in physical pixels and excluding
/// a window frame (if present).
void set_size(const slint::Size<unsigned int> &size) { inner.set_size(size); }
/// \private
private_api::WindowRc &window_handle() { return inner; }
/// \private