mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +00:00
LibGUI: Some more convenience functions for constructing widgets
This patch adds two new API's: - WidgetType& GUI::Window::set_main_widget<WidgetType>(); This creates a new main widget for a window, assigns it, and returns it to you as a WidgetType&. - LayoutType& GUI::Widget::set_layout<LayoutType>(); Same basic idea, creates a new layout, assigns it, and returns it to you as a LayoutType&.
This commit is contained in:
parent
0cafbbf09c
commit
03e0ddce52
10 changed files with 66 additions and 60 deletions
|
@ -98,6 +98,13 @@ public:
|
|||
const Layout* layout() const { return m_layout.ptr(); }
|
||||
void set_layout(OwnPtr<Layout>&&);
|
||||
|
||||
template<typename T>
|
||||
T& set_layout()
|
||||
{
|
||||
set_layout(make<T>());
|
||||
return static_cast<T&>(*layout());
|
||||
}
|
||||
|
||||
SizePolicy horizontal_size_policy() const { return m_horizontal_size_policy; }
|
||||
SizePolicy vertical_size_policy() const { return m_vertical_size_policy; }
|
||||
SizePolicy size_policy(Orientation orientation) { return orientation == Orientation::Horizontal ? m_horizontal_size_policy : m_vertical_size_policy; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue