diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-02-16 16:52:56 +0000 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2023-02-18 16:56:56 +0000 |
commit | ab6ef53247ec363e61b28f4afc994edac39dc866 (patch) | |
tree | 659edff4c2645ea9075cb20243e1c99aed6b18db /Userland/Libraries/LibGUI | |
parent | 6ceb185865e242462c4f4ad310ec0c0a928c2f31 (diff) | |
download | serenity-ab6ef53247ec363e61b28f4afc994edac39dc866.zip |
LibGUI: Add Widget::add_spacer() wrapper
This just calls Layout::try_add_spacer(), but saves you having to access
the Widget's Layout directly.
We verify that the Widget has a Layout, since it would be a programming
error if we tried to do so without one.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/Widget.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Widget.h | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Widget.cpp b/Userland/Libraries/LibGUI/Widget.cpp index 0b0f5c6e37..ce16af49ce 100644 --- a/Userland/Libraries/LibGUI/Widget.cpp +++ b/Userland/Libraries/LibGUI/Widget.cpp @@ -1266,4 +1266,10 @@ bool Widget::is_visible_for_timer_purposes() const return is_visible() && Object::is_visible_for_timer_purposes(); } +ErrorOr<void> Widget::add_spacer() +{ + VERIFY(layout()); + return layout()->try_add_spacer(); +} + } diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h index 8e91e3d504..bbd0a5a826 100644 --- a/Userland/Libraries/LibGUI/Widget.h +++ b/Userland/Libraries/LibGUI/Widget.h @@ -366,6 +366,8 @@ public: // In order for others to be able to call this, it needs to be public. virtual ErrorOr<void> load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, UnregisteredChildHandler); + ErrorOr<void> add_spacer(); + protected: Widget(); |