mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 20:16:02 +00:00
LibGUI: Add GUI::Widget::try_set_layout<T>(...)
This is a fallible variant of set_layout<T>(...) that returns ErrorOr.
This commit is contained in:
parent
bc79be362d
commit
6b79745aa4
Notes:
sideshowbarker
2024-07-18 00:44:36 +09:00
Author: https://github.com/awesomekling
Commit: 6b79745aa4
1 changed files with 8 additions and 0 deletions
|
@ -61,6 +61,14 @@ public:
|
|||
const Layout* layout() const { return m_layout.ptr(); }
|
||||
void set_layout(NonnullRefPtr<Layout>);
|
||||
|
||||
template<class T, class... Args>
|
||||
ErrorOr<NonnullRefPtr<T>> try_set_layout(Args&&... args)
|
||||
{
|
||||
auto layout = TRY(T::try_create(forward<Args>(args)...));
|
||||
set_layout(*layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
inline T& set_layout(Args&&... args)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue