diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-04 09:46:23 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-04 14:26:16 +0100 |
commit | 0f3e57a6fb037f6a8133e8ec2be8f0889ff9bc19 (patch) | |
tree | 3fc1f6f91d7e00783792e98bd23f226e591d99a3 /Demos/WidgetGallery | |
parent | 4697195645a4c66930761c85685f5752dc777bba (diff) | |
download | serenity-0f3e57a6fb037f6a8133e8ec2be8f0889ff9bc19.zip |
LibGUI: Use GUI::Window::set_main_widget<WidgetType>() in clients
Diffstat (limited to 'Demos/WidgetGallery')
-rw-r--r-- | Demos/WidgetGallery/main.cpp | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp index d7936e437f..2da3b765f8 100644 --- a/Demos/WidgetGallery/main.cpp +++ b/Demos/WidgetGallery/main.cpp @@ -48,51 +48,50 @@ int main(int argc, char** argv) window->set_rect(100, 100, 320, 620); window->set_title("Widget Gallery"); - auto main_widget = GUI::Widget::construct(); - window->set_main_widget(main_widget); - main_widget->set_fill_with_background_color(true); - main_widget->set_layout<GUI::VerticalBoxLayout>(); - main_widget->layout()->set_margins({ 4, 4, 4, 4 }); + auto& main_widget = window->set_main_widget<GUI::Widget>(); + main_widget.set_fill_with_background_color(true); + main_widget.set_layout<GUI::VerticalBoxLayout>(); + main_widget.layout()->set_margins({ 4, 4, 4, 4 }); - auto checkbox1 = main_widget->add<GUI::CheckBox>("GCheckBox 1"); + auto checkbox1 = main_widget.add<GUI::CheckBox>("GCheckBox 1"); (void)checkbox1; - auto checkbox2 = main_widget->add<GUI::CheckBox>("GCheckBox 2"); + auto checkbox2 = main_widget.add<GUI::CheckBox>("GCheckBox 2"); checkbox2->set_enabled(false); - auto radio1 = main_widget->add<GUI::RadioButton>("GRadioButton 1"); + auto radio1 = main_widget.add<GUI::RadioButton>("GRadioButton 1"); (void)radio1; - auto radio2 = main_widget->add<GUI::RadioButton>("GRadioButton 2"); + auto radio2 = main_widget.add<GUI::RadioButton>("GRadioButton 2"); radio2->set_enabled(false); - auto button1 = main_widget->add<GUI::Button>("GButton 1"); + auto button1 = main_widget.add<GUI::Button>("GButton 1"); (void)button1; - auto button2 = main_widget->add<GUI::Button>("GButton 2"); + auto button2 = main_widget.add<GUI::Button>("GButton 2"); button2->set_enabled(false); - auto progress1 = main_widget->add<GUI::ProgressBar>(); + auto progress1 = main_widget.add<GUI::ProgressBar>(); auto timer = progress1->add<Core::Timer>(100, [&] { progress1->set_value(progress1->value() + 1); if (progress1->value() == progress1->max()) progress1->set_value(progress1->min()); }); - auto label1 = main_widget->add<GUI::Label>("GLabel 1"); + auto label1 = main_widget.add<GUI::Label>("GLabel 1"); (void)label1; - auto label2 = main_widget->add<GUI::Label>("GLabel 2"); + auto label2 = main_widget.add<GUI::Label>("GLabel 2"); label2->set_enabled(false); - auto textbox1 = main_widget->add<GUI::TextBox>(); + auto textbox1 = main_widget.add<GUI::TextBox>(); textbox1->set_text("GTextBox 1"); - auto textbox2 = main_widget->add<GUI::TextBox>(); + auto textbox2 = main_widget.add<GUI::TextBox>(); textbox2->set_text("GTextBox 2"); textbox2->set_enabled(false); - auto spinbox1 = main_widget->add<GUI::SpinBox>(); + auto spinbox1 = main_widget.add<GUI::SpinBox>(); (void)spinbox1; - auto spinbox2 = main_widget->add<GUI::SpinBox>(); + auto spinbox2 = main_widget.add<GUI::SpinBox>(); spinbox2->set_enabled(false); - auto vertical_slider_container = main_widget->add<GUI::Widget>(); + auto vertical_slider_container = main_widget.add<GUI::Widget>(); vertical_slider_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); vertical_slider_container->set_preferred_size(0, 100); vertical_slider_container->set_layout<GUI::HorizontalBoxLayout>(); @@ -104,21 +103,21 @@ int main(int argc, char** argv) vslider3->set_max(5); vslider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); - auto slider1 = main_widget->add<GUI::HorizontalSlider>(); + auto slider1 = main_widget.add<GUI::HorizontalSlider>(); (void)slider1; - auto slider2 = main_widget->add<GUI::HorizontalSlider>(); + auto slider2 = main_widget.add<GUI::HorizontalSlider>(); slider2->set_enabled(false); - auto slider3 = main_widget->add<GUI::HorizontalSlider>(); + auto slider3 = main_widget.add<GUI::HorizontalSlider>(); slider3->set_max(5); slider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); - auto scrollbar1 = main_widget->add<GUI::ScrollBar>(Orientation::Horizontal); + auto scrollbar1 = main_widget.add<GUI::ScrollBar>(Orientation::Horizontal); scrollbar1->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); scrollbar1->set_preferred_size(0, 16); scrollbar1->set_min(0); scrollbar1->set_max(100); scrollbar1->set_value(50); - auto scrollbar2 = main_widget->add<GUI::ScrollBar>(Orientation::Horizontal); + auto scrollbar2 = main_widget.add<GUI::ScrollBar>(Orientation::Horizontal); scrollbar2->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); scrollbar2->set_preferred_size(0, 16); scrollbar2->set_enabled(false); |