mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
Add support for set_position(), position(), and set_physical_size() to the C++ WindowAdapter (#3367)
Closes #3349
This commit is contained in:
parent
d3b89df095
commit
d160eb7a31
5 changed files with 137 additions and 2 deletions
|
@ -201,9 +201,25 @@ class WindowAdapter
|
|||
[](void *wa) -> cbindgen_private::IntSize {
|
||||
return reinterpret_cast<const WindowAdapter *>(wa)->physical_size();
|
||||
},
|
||||
[](void *wa, cbindgen_private::IntSize size) {
|
||||
reinterpret_cast<WindowAdapter *>(wa)->set_physical_size(
|
||||
slint::PhysicalSize({ size.width, size.height }));
|
||||
},
|
||||
[](void *wa, const WindowProperties *p) {
|
||||
reinterpret_cast<WindowAdapter *>(wa)->update_window_properties(*p);
|
||||
},
|
||||
[](void *wa, cbindgen_private::Point2D<int32_t> *point) -> bool {
|
||||
if (auto pos = reinterpret_cast<const WindowAdapter *>(wa)->position()) {
|
||||
*point = *pos;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
[](void *wa, cbindgen_private::Point2D<int32_t> point) {
|
||||
reinterpret_cast<WindowAdapter *>(wa)->set_position(
|
||||
slint::PhysicalPosition({ point.x, point.y }));
|
||||
},
|
||||
&self);
|
||||
was_initialized = true;
|
||||
return self;
|
||||
|
@ -232,9 +248,37 @@ public:
|
|||
/// do that in the next iteration of the event loop, or in a callback from the window manager.
|
||||
virtual void request_redraw() { }
|
||||
|
||||
/// Request a new size for the window to the specified size on the screen, in physical or
|
||||
/// logical pixels and excluding a window frame (if present).
|
||||
///
|
||||
/// This is called from slint::Window::set_size().
|
||||
///
|
||||
/// The default implementation does nothing
|
||||
///
|
||||
/// This function should sent the size to the Windowing system. If the window size actually
|
||||
/// changes, you should call slint::Window::dispatch_resize_event to propagate the new size
|
||||
/// to the slint view.
|
||||
virtual void set_physical_size(slint::PhysicalSize) { }
|
||||
|
||||
/// Returns the actual physical size of the window
|
||||
virtual slint::PhysicalSize physical_size() const = 0;
|
||||
|
||||
/// Sets the position of the window on the screen, in physical screen coordinates and including
|
||||
/// a window frame (if present).
|
||||
///
|
||||
/// The default implementation does nothing
|
||||
///
|
||||
/// Called from slint::Window::set_position().
|
||||
virtual void set_position(slint::PhysicalPosition) { }
|
||||
|
||||
/// Returns the position of the window on the screen, in physical screen coordinates and
|
||||
/// including a window frame (if present).
|
||||
///
|
||||
/// The default implementation returns std::nullopt.
|
||||
///
|
||||
/// Called from slint::Window::position().
|
||||
virtual std::optional<slint::PhysicalPosition> position() const { return std::nullopt; }
|
||||
|
||||
/// Re-implement this function to update the properties such as window title or layout
|
||||
/// constraints.
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue