mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:38:13 +00:00
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. :^)
This commit is contained in:
parent
fb09b6a8ce
commit
028c011760
46 changed files with 1035 additions and 1039 deletions
|
@ -104,43 +104,43 @@ static RefPtr<GUI::Widget> build_gwidget(VBWidgetType type, GUI::Widget* parent)
|
|||
case VBWidgetType::GGroupBox:
|
||||
return parent->add<GUI::GroupBox>("groupbox_1");
|
||||
case VBWidgetType::GLabel: {
|
||||
auto label = parent->add<GUI::Label>();
|
||||
label->set_fill_with_background_color(true);
|
||||
label->set_text("label_1");
|
||||
auto& label = parent->add<GUI::Label>();
|
||||
label.set_fill_with_background_color(true);
|
||||
label.set_text("label_1");
|
||||
return label;
|
||||
}
|
||||
case VBWidgetType::GButton: {
|
||||
auto button = parent->add<GUI::Button>();
|
||||
button->set_text("button_1");
|
||||
auto& button = parent->add<GUI::Button>();
|
||||
button.set_text("button_1");
|
||||
return button;
|
||||
}
|
||||
case VBWidgetType::GSpinBox: {
|
||||
auto box = parent->add<GUI::SpinBox>();
|
||||
box->set_range(0, 100);
|
||||
box->set_value(0);
|
||||
auto& box = parent->add<GUI::SpinBox>();
|
||||
box.set_range(0, 100);
|
||||
box.set_value(0);
|
||||
return box;
|
||||
}
|
||||
case VBWidgetType::GTextEditor: {
|
||||
auto editor = parent->add<GUI::TextEditor>();
|
||||
editor->set_ruler_visible(false);
|
||||
auto& editor = parent->add<GUI::TextEditor>();
|
||||
editor.set_ruler_visible(false);
|
||||
return editor;
|
||||
}
|
||||
case VBWidgetType::GProgressBar: {
|
||||
auto bar = parent->add<GUI::ProgressBar>();
|
||||
bar->set_format(GUI::ProgressBar::Format::NoText);
|
||||
bar->set_range(0, 100);
|
||||
bar->set_value(50);
|
||||
auto& bar = parent->add<GUI::ProgressBar>();
|
||||
bar.set_format(GUI::ProgressBar::Format::NoText);
|
||||
bar.set_range(0, 100);
|
||||
bar.set_value(50);
|
||||
return bar;
|
||||
}
|
||||
case VBWidgetType::GSlider: {
|
||||
auto slider = parent->add<GUI::HorizontalSlider>();
|
||||
slider->set_range(0, 100);
|
||||
slider->set_value(50);
|
||||
auto& slider = parent->add<GUI::HorizontalSlider>();
|
||||
slider.set_range(0, 100);
|
||||
slider.set_value(50);
|
||||
return slider;
|
||||
}
|
||||
case VBWidgetType::GCheckBox: {
|
||||
auto box = parent->add<GUI::CheckBox>();
|
||||
box->set_text("checkbox_1");
|
||||
auto& box = parent->add<GUI::CheckBox>();
|
||||
box.set_text("checkbox_1");
|
||||
return box;
|
||||
}
|
||||
case VBWidgetType::GRadioButton:
|
||||
|
|
|
@ -111,84 +111,84 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
widget.layout()->set_spacing(0);
|
||||
|
||||
auto label_button = widget.add<GUI::Button>();
|
||||
label_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
label_button->set_tooltip("GLabel");
|
||||
label_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/label.png"));
|
||||
label_button->on_click = [] {
|
||||
auto& label_button = widget.add<GUI::Button>();
|
||||
label_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
label_button.set_tooltip("GLabel");
|
||||
label_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/label.png"));
|
||||
label_button.on_click = [] {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GLabel);
|
||||
};
|
||||
|
||||
auto button_button = widget.add<GUI::Button>();
|
||||
button_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
button_button->set_tooltip("GButton");
|
||||
button_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
||||
button_button->on_click = [] {
|
||||
auto& button_button = widget.add<GUI::Button>();
|
||||
button_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
button_button.set_tooltip("GButton");
|
||||
button_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
||||
button_button.on_click = [] {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GButton);
|
||||
};
|
||||
auto spinbox_button = widget.add<GUI::Button>();
|
||||
spinbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
spinbox_button->set_tooltip("GSpinBox");
|
||||
spinbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
|
||||
spinbox_button->on_click = [] {
|
||||
auto& spinbox_button = widget.add<GUI::Button>();
|
||||
spinbox_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
spinbox_button.set_tooltip("GSpinBox");
|
||||
spinbox_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
|
||||
spinbox_button.on_click = [] {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GSpinBox);
|
||||
};
|
||||
auto editor_button = widget.add<GUI::Button>();
|
||||
editor_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
editor_button->set_tooltip("GTextEditor");
|
||||
editor_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
|
||||
editor_button->on_click = [] {
|
||||
auto& editor_button = widget.add<GUI::Button>();
|
||||
editor_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
editor_button.set_tooltip("GTextEditor");
|
||||
editor_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
|
||||
editor_button.on_click = [] {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GTextEditor);
|
||||
};
|
||||
auto progress_bar_button = widget.add<GUI::Button>();
|
||||
progress_bar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
progress_bar_button->set_tooltip("GProgressBar");
|
||||
progress_bar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
|
||||
progress_bar_button->on_click = [] {
|
||||
auto& progress_bar_button = widget.add<GUI::Button>();
|
||||
progress_bar_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
progress_bar_button.set_tooltip("GProgressBar");
|
||||
progress_bar_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
|
||||
progress_bar_button.on_click = [] {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GProgressBar);
|
||||
};
|
||||
auto slider_button = widget.add<GUI::Button>();
|
||||
slider_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
slider_button->set_tooltip("GSlider");
|
||||
slider_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
|
||||
slider_button->on_click = [] {
|
||||
auto& slider_button = widget.add<GUI::Button>();
|
||||
slider_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
slider_button.set_tooltip("GSlider");
|
||||
slider_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
|
||||
slider_button.on_click = [] {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GSlider);
|
||||
};
|
||||
auto checkbox_button = widget.add<GUI::Button>();
|
||||
checkbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
checkbox_button->set_tooltip("GCheckBox");
|
||||
checkbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
||||
checkbox_button->on_click = [] {
|
||||
auto& checkbox_button = widget.add<GUI::Button>();
|
||||
checkbox_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
checkbox_button.set_tooltip("GCheckBox");
|
||||
checkbox_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
||||
checkbox_button.on_click = [] {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GCheckBox);
|
||||
};
|
||||
auto radiobutton_button = widget.add<GUI::Button>();
|
||||
radiobutton_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
radiobutton_button->set_tooltip("GRadioButton");
|
||||
radiobutton_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/filled-radio-circle.png"));
|
||||
radiobutton_button->on_click = [] {
|
||||
auto& radiobutton_button = widget.add<GUI::Button>();
|
||||
radiobutton_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
radiobutton_button.set_tooltip("GRadioButton");
|
||||
radiobutton_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/filled-radio-circle.png"));
|
||||
radiobutton_button.on_click = [] {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GRadioButton);
|
||||
};
|
||||
auto scrollbar_button = widget.add<GUI::Button>();
|
||||
scrollbar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
scrollbar_button->set_tooltip("GScrollBar");
|
||||
scrollbar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
|
||||
scrollbar_button->on_click = [] {
|
||||
auto& scrollbar_button = widget.add<GUI::Button>();
|
||||
scrollbar_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
scrollbar_button.set_tooltip("GScrollBar");
|
||||
scrollbar_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
|
||||
scrollbar_button.on_click = [] {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GScrollBar);
|
||||
};
|
||||
auto groupbox_button = widget.add<GUI::Button>();
|
||||
groupbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
groupbox_button->set_tooltip("GGroupBox");
|
||||
groupbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));
|
||||
groupbox_button->on_click = [] {
|
||||
auto& groupbox_button = widget.add<GUI::Button>();
|
||||
groupbox_button.set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
groupbox_button.set_tooltip("GGroupBox");
|
||||
groupbox_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));
|
||||
groupbox_button.on_click = [] {
|
||||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GGroupBox);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue