Переглянути джерело

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.
Sam Atkins 2 роки тому
батько
коміт
ab6ef53247

+ 6 - 0
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();
+}
+
 }

+ 2 - 0
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();