diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-05 09:21:46 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-05 09:22:43 +0100 |
commit | 849fdc1c0b2be599932447c3751dbc303d634ae1 (patch) | |
tree | 930c8afbce853bdf080f153e7e5cbd30cfa17c10 /Libraries/LibGUI/Widget.h | |
parent | ecc39678f59e7b40be20a491770ffac19d1a25a4 (diff) | |
download | serenity-849fdc1c0b2be599932447c3751dbc303d634ae1.zip |
LibGUI: Make Layout a Core::Object and add basic serialization
This allows you to view layouts (as data) in Inspector.
Diffstat (limited to 'Libraries/LibGUI/Widget.h')
-rw-r--r-- | Libraries/LibGUI/Widget.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Libraries/LibGUI/Widget.h b/Libraries/LibGUI/Widget.h index 7e37f5a32e..b0e4b5e3cd 100644 --- a/Libraries/LibGUI/Widget.h +++ b/Libraries/LibGUI/Widget.h @@ -96,13 +96,14 @@ public: Layout* layout() { return m_layout.ptr(); } const Layout* layout() const { return m_layout.ptr(); } - void set_layout(OwnPtr<Layout>&&); + void set_layout(NonnullRefPtr<Layout>); - template<typename T> - T& set_layout() + template<class T, class... Args> + inline T& set_layout(Args&&... args) { - set_layout(make<T>()); - return static_cast<T&>(*layout()); + auto layout = T::construct(forward<Args>(args)...); + set_layout(*layout); + return layout; } SizePolicy horizontal_size_policy() const { return m_horizontal_size_policy; } @@ -304,7 +305,7 @@ private: void focus_next_widget(); Window* m_window { nullptr }; - OwnPtr<Layout> m_layout; + RefPtr<Layout> m_layout; Gfx::Rect m_relative_rect; Gfx::ColorRole m_background_role; |