mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +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
|
@ -125,6 +125,14 @@ public:
|
|||
const Widget* main_widget() const { return m_main_widget; }
|
||||
void set_main_widget(Widget*);
|
||||
|
||||
template<class T, class... Args>
|
||||
inline T& set_main_widget(Args&&... args)
|
||||
{
|
||||
auto widget = T::construct(forward<Args>(args)...);
|
||||
set_main_widget(widget.ptr());
|
||||
return *widget;
|
||||
}
|
||||
|
||||
Widget* focused_widget() { return m_focused_widget; }
|
||||
const Widget* focused_widget() const { return m_focused_widget; }
|
||||
void set_focused_widget(Widget*);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue