diff options
author | Andreas Kling <kling@serenityos.org> | 2020-03-04 19:07:55 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-04 21:04:06 +0100 |
commit | 028c011760b5b665fc2a72bb3c11fd3a6ca60d2c (patch) | |
tree | a961293992de78ebac5c3ffec864179d661dcc09 /Demos/WidgetGallery | |
parent | fb09b6a8cec02cc473b3fed326d99055d80a60ba (diff) | |
download | serenity-028c011760b5b665fc2a72bb3c11fd3a6ca60d2c.zip |
LibCore: Make Core::Object::add<ChildType> return a ChildType&
Since the returned object is now owned by the callee object, we can
simply vend a ChildType&. This allows us to use "." instead of "->"
at the call site, which is quite nice. :^)
Diffstat (limited to 'Demos/WidgetGallery')
-rw-r--r-- | Demos/WidgetGallery/main.cpp | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp index 2da3b765f8..f5c13579b2 100644 --- a/Demos/WidgetGallery/main.cpp +++ b/Demos/WidgetGallery/main.cpp @@ -53,74 +53,74 @@ int main(int argc, char** argv) 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"); - checkbox2->set_enabled(false); + 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"); - radio2->set_enabled(false); + 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"); - button2->set_enabled(false); - - 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& button2 = main_widget.add<GUI::Button>("GButton 2"); + button2.set_enabled(false); + + auto& progress1 = main_widget.add<GUI::ProgressBar>(); + 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"); - label2->set_enabled(false); + auto& label2 = main_widget.add<GUI::Label>("GLabel 2"); + label2.set_enabled(false); - auto textbox1 = main_widget.add<GUI::TextBox>(); - textbox1->set_text("GTextBox 1"); - auto textbox2 = main_widget.add<GUI::TextBox>(); - textbox2->set_text("GTextBox 2"); - textbox2->set_enabled(false); + auto& textbox1 = main_widget.add<GUI::TextBox>(); + textbox1.set_text("GTextBox 1"); + 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>(); - spinbox2->set_enabled(false); - - 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>(); - auto vslider1 = vertical_slider_container->add<GUI::VerticalSlider>(); + auto& spinbox2 = main_widget.add<GUI::SpinBox>(); + spinbox2.set_enabled(false); + + 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>(); + auto& vslider1 = vertical_slider_container.add<GUI::VerticalSlider>(); (void)vslider1; - auto vslider2 = vertical_slider_container->add<GUI::VerticalSlider>(); - vslider2->set_enabled(false); - auto vslider3 = vertical_slider_container->add<GUI::VerticalSlider>(); - vslider3->set_max(5); - vslider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); + auto& vslider2 = vertical_slider_container.add<GUI::VerticalSlider>(); + vslider2.set_enabled(false); + auto& vslider3 = vertical_slider_container.add<GUI::VerticalSlider>(); + 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>(); - slider2->set_enabled(false); - 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); - 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); - scrollbar2->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); - scrollbar2->set_preferred_size(0, 16); - scrollbar2->set_enabled(false); + auto& slider2 = main_widget.add<GUI::HorizontalSlider>(); + slider2.set_enabled(false); + 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); + 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); + scrollbar2.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); + scrollbar2.set_preferred_size(0, 16); + scrollbar2.set_enabled(false); window->show(); |