1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:17:35 +00:00

LibGUI: Make GUI::TabWidget tab creation APIs take String

Ultimately we'd like the caller to provide a String if possible (instead
of a StringView) as we're going to end up storing it.
This commit is contained in:
Andreas Kling 2021-11-27 17:30:46 +01:00
parent 8a11e986e5
commit 8359975ff3
2 changed files with 10 additions and 10 deletions

View file

@ -36,24 +36,24 @@ 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&);
ErrorOr<void> try_add_widget(String, Widget&);
void add_widget(StringView, Widget&);
void add_widget(String, Widget&);
void remove_widget(Widget&);
template<class T, class... Args>
ErrorOr<NonnullRefPtr<T>> try_add_tab(StringView title, Args&&... args)
ErrorOr<NonnullRefPtr<T>> try_add_tab(String title, Args&&... args)
{
auto t = TRY(T::try_create(forward<Args>(args)...));
TRY(try_add_widget(title, *t));
TRY(try_add_widget(move(title), *t));
return *t;
}
template<class T, class... Args>
T& add_tab(StringView title, Args&&... args)
T& add_tab(String title, Args&&... args)
{
auto t = T::construct(forward<Args>(args)...);
add_widget(title, *t);
add_widget(move(title), *t);
return *t;
}