mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:17:35 +00:00
LibGUI: Add GUI::TabWidget::try_add_tab<T>(...)
This is a fallible variant of add_tab<T>(...) that returns ErrorOr.
This commit is contained in:
parent
dc47fce2d9
commit
47b6339025
2 changed files with 17 additions and 1 deletions
|
@ -36,9 +36,19 @@ public:
|
|||
GUI::Margins const& container_margins() const { return m_container_margins; }
|
||||
void set_container_margins(GUI::Margins const&);
|
||||
|
||||
ErrorOr<void> try_add_widget(StringView, Widget&);
|
||||
|
||||
void add_widget(StringView, Widget&);
|
||||
void remove_widget(Widget&);
|
||||
|
||||
template<class T, class... Args>
|
||||
ErrorOr<NonnullRefPtr<T>> try_add_tab(StringView title, Args&&... args)
|
||||
{
|
||||
auto t = TRY(T::try_create(forward<Args>(args)...));
|
||||
TRY(try_add_widget(title, *t));
|
||||
return *t;
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
T& add_tab(StringView title, Args&&... args)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue