From ab6ef53247ec363e61b28f4afc994edac39dc866 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 16 Feb 2023 16:52:56 +0000 Subject: [PATCH] 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. --- Userland/Libraries/LibGUI/Widget.cpp | 6 ++++++ Userland/Libraries/LibGUI/Widget.h | 2 ++ 2 files changed, 8 insertions(+) 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 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 load_from_gml_ast(NonnullRefPtr ast, UnregisteredChildHandler); + ErrorOr add_spacer(); + protected: Widget();