Associate PopupWindows with an ID for their active popup (#6693)

Popups are stored in a HashMap and are assigned an ID so popup.close(); closes the correct popup and so a single PopupWindow cannot be opened multiple times
This commit is contained in:
Brandon Fowler 2024-11-04 03:17:55 -05:00 committed by GitHub
parent d30dfc0175
commit 6da0f55b05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 459 additions and 74 deletions

View file

@ -106,18 +106,23 @@ public:
}
template<typename Component, typename Parent, typename PosGetter>
void show_popup(const Parent *parent_component, PosGetter pos,
cbindgen_private::PopupClosePolicy close_policy,
cbindgen_private::ItemRc parent_item) const
uint32_t show_popup(const Parent *parent_component, PosGetter pos,
cbindgen_private::PopupClosePolicy close_policy,
cbindgen_private::ItemRc parent_item) const
{
auto popup = Component::create(parent_component);
cbindgen_private::Point p = pos(popup);
auto popup_dyn = popup.into_dyn();
cbindgen_private::slint_windowrc_show_popup(&inner, &popup_dyn, p, close_policy,
&parent_item);
return cbindgen_private::slint_windowrc_show_popup(&inner, &popup_dyn, p, close_policy,
&parent_item);
}
void close_popup() const { cbindgen_private::slint_windowrc_close_popup(&inner); }
void close_popup(uint32_t popup_id) const
{
if (popup_id > 0) {
cbindgen_private::slint_windowrc_close_popup(&inner, popup_id);
}
}
template<std::invocable<RenderingState, GraphicsAPI> F>
std::optional<SetRenderingNotifierError> set_rendering_notifier(F callback) const