summaryrefslogtreecommitdiff
path: root/Applications/Piano
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-23 12:23:48 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-23 12:27:53 +0100
commit6c5100b644d6f1f9581ae69943be0e5072e5b420 (patch)
tree9ea295a061cb15f16a5a4d38ad549ec1ec95c996 /Applications/Piano
parentbbc02af0903a3515ac3cd8fed058d9f7b52128cb (diff)
downloadserenity-6c5100b644d6f1f9581ae69943be0e5072e5b420.zip
LibGUI: Add helper for constructing new TabWidget tabs
This patch adds the following convenience helper: auto tab_widget = GUI::TabWidget::construct(); auto my_widget = tab_widget->add_tab<GUI::Widget>("My tab", ...); The above is equivalent to: auto tab_widget = GUI::TabWidget::construct(); auto my_widget = GUI::Widget::construct(...); tab_widget->add_widget("My tab", my_widget);
Diffstat (limited to 'Applications/Piano')
-rw-r--r--Applications/Piano/MainWidget.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/Applications/Piano/MainWidget.cpp b/Applications/Piano/MainWidget.cpp
index c70747d4c4..d8eab8d8ad 100644
--- a/Applications/Piano/MainWidget.cpp
+++ b/Applications/Piano/MainWidget.cpp
@@ -47,15 +47,13 @@ MainWidget::MainWidget(AudioEngine& audio_engine)
m_wave_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
m_wave_widget->set_preferred_size(0, 100);
- m_roll_widget = RollWidget::construct(audio_engine);
+ m_tab_widget = add<GUI::TabWidget>();
+ m_roll_widget = m_tab_widget->add_tab<RollWidget>("Piano Roll", audio_engine);
+
m_roll_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
m_roll_widget->set_preferred_size(0, 300);
- m_sampler_widget = SamplerWidget::construct(audio_engine);
-
- m_tab_widget = add<GUI::TabWidget>();
- m_tab_widget->add_widget("Piano Roll", m_roll_widget);
- m_tab_widget->add_widget("Sampler", m_sampler_widget);
+ m_tab_widget->add_tab<SamplerWidget>("Sampler", audio_engine);
m_keys_and_knobs_container = add<GUI::Widget>();
m_keys_and_knobs_container->set_layout(make<GUI::HorizontalBoxLayout>());