mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-03 18:29:09 +00:00
Platform: Add a Resized event and use that to convey the changes in size (#2759)
This commit is contained in:
parent
846c48b81d
commit
dd5ef9993f
12 changed files with 121 additions and 47 deletions
|
@ -61,6 +61,9 @@ public:
|
|||
/// do that in the next iteration of the event loop, or in a callback from the window manager.
|
||||
virtual void request_redraw() const { }
|
||||
|
||||
/// Returns the actual physical size of the window
|
||||
virtual slint::PhysicalSize physical_size() const = 0;
|
||||
|
||||
private:
|
||||
friend class Platform;
|
||||
virtual cbindgen_private::WindowAdapterRcOpaque initialize() = 0;
|
||||
|
@ -94,7 +97,11 @@ private:
|
|||
},
|
||||
[](void *wa) { reinterpret_cast<const WA *>(wa)->show(); },
|
||||
[](void *wa) { reinterpret_cast<const WA *>(wa)->hide(); },
|
||||
[](void *wa) { reinterpret_cast<const WA *>(wa)->request_redraw(); }, &self);
|
||||
[](void *wa) { reinterpret_cast<const WA *>(wa)->request_redraw(); },
|
||||
[](void *wa) -> cbindgen_private::IntSize {
|
||||
return reinterpret_cast<const WA *>(wa)->physical_size();
|
||||
},
|
||||
&self);
|
||||
m_renderer.init(&self);
|
||||
was_initialized = true;
|
||||
return self;
|
||||
|
@ -143,6 +150,16 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
/// Set the logical size of this window after a resize event
|
||||
// Note: in rust, this is an event on the Window
|
||||
void dispatch_resize_event(slint::LogicalSize s)
|
||||
{
|
||||
private_api::assert_main_thread();
|
||||
if (was_initialized) {
|
||||
cbindgen_private::slint_windowrc_dispatch_resize_event(&self, s.width, s.height);
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the window is currently animating
|
||||
bool has_active_animations() const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue