1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:57:44 +00:00

LibGUI: Remove parent parameter to GUI::Widget constructor

This commit is contained in:
Andreas Kling 2020-02-23 12:07:13 +01:00
parent 4ce28c32d1
commit c5d913970a
114 changed files with 207 additions and 313 deletions

View file

@ -90,7 +90,7 @@ int main(int argc, char** argv)
dbg() << "UI_" << name << "::UI_" << name << "()";
dbg() << "{";
dbg() << " main_widget = GUI::Widget::construct(nullptr);";
dbg() << " main_widget = GUI::Widget::construct();";
dbg() << " main_widget->set_fill_with_background_color(true);";
widgets.as_array().for_each([&](auto& value) {
@ -98,7 +98,7 @@ int main(int argc, char** argv)
const JsonObject& widget_object = value.as_object();
auto name = widget_object.get("name").to_string();
auto class_name = widget_object.get("class").to_string();
dbg() << " " << name << " = " << class_name << "::construct(main_widget);";
dbg() << " " << name << " = main_widget->add<" << class_name << ">();";
widget_object.for_each_member([&](auto& property_name, const JsonValue& property_value) {
if (property_name == "class")

View file

@ -286,7 +286,8 @@ int main(int argc, char** argv)
auto icon_path = String::format("/res/icons/widgets/G%s.png", reg.class_name().characters());
auto action = GUI::Action::create(reg.class_name(), Gfx::Bitmap::load_from_file(icon_path), [&reg](auto&) {
g_form_editor_widget->set_tool(make<WidgetTool>(*g_form_editor_widget, reg));
auto widget = reg.construct(&g_form_editor_widget->form_widget());
auto widget = reg.construct();
g_form_editor_widget->form_widget().add_child(widget);
widget->set_relative_rect(30, 30, 30, 30);
g_form_editor_widget->model().update();
});

View file

@ -28,9 +28,8 @@
#include "Profile.h"
#include <LibGUI/Painter.h>
ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile, GUI::Widget* parent)
: GUI::Frame(parent)
, m_profile(profile)
ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile)
: m_profile(profile)
{
set_background_color(Color::White);
set_fill_with_background_color(true);

View file

@ -39,7 +39,7 @@ private:
virtual void mousemove_event(GUI::MouseEvent&) override;
virtual void mouseup_event(GUI::MouseEvent&) override;
ProfileTimelineWidget(Profile&, GUI::Widget* parent);
explicit ProfileTimelineWidget(Profile&);
u64 timestamp_at_x(int x) const;

View file

@ -62,9 +62,9 @@ int main(int argc, char** argv)
main_widget->set_fill_with_background_color(true);
main_widget->set_layout(make<GUI::VerticalBoxLayout>());
auto timeline_widget = ProfileTimelineWidget::construct(*profile, main_widget);
auto timeline_widget = main_widget->add<ProfileTimelineWidget>(*profile);
auto tree_view = GUI::TreeView::construct(main_widget);
auto tree_view = main_widget->add<GUI::TreeView>();
tree_view->set_headers_visible(true);
tree_view->set_size_columns_to_fit_content(true);
tree_view->set_model(profile->model());

View file

@ -44,9 +44,8 @@ VBForm* VBForm::current()
return s_current;
}
VBForm::VBForm(const String& name, GUI::Widget* parent)
: GUI::Widget(parent)
, m_name(name)
VBForm::VBForm(const String& name)
: m_name(name)
{
s_current = this;
set_fill_with_background_color(true);

View file

@ -33,8 +33,8 @@
class VBForm : public GUI::Widget {
C_OBJECT(VBForm)
friend class VBWidget;
public:
explicit VBForm(const String& name, GUI::Widget* parent = nullptr);
virtual ~VBForm() override;
static VBForm* current();
@ -66,6 +66,8 @@ protected:
virtual void keydown_event(GUI::KeyEvent&) override;
private:
explicit VBForm(const String& name);
void grabber_mousedown_event(GUI::MouseEvent&, Direction grabber);
void set_single_selected_widget(VBWidget*);
void add_to_selection(VBWidget&);

View file

@ -59,7 +59,7 @@ public:
virtual RefPtr<GUI::Widget> create_widget() override
{
auto combo = GUI::ComboBox::construct(nullptr);
auto combo = GUI::ComboBox::construct();
combo->set_only_allow_values_from_model(true);
combo->set_model(adopt(*new BoolValuesModel));
combo->on_return_pressed = [this] { commit(); };
@ -87,7 +87,7 @@ VBPropertiesWindow::VBPropertiesWindow()
widget->layout()->set_margins({ 2, 2, 2, 2 });
set_main_widget(widget);
m_table_view = GUI::TableView::construct(widget);
m_table_view = widget->add<GUI::TableView>();
m_table_view->set_headers_visible(false);
m_table_view->set_editable(true);

View file

@ -112,7 +112,7 @@ RefPtr<GUI::Window> make_toolbox_window()
widget->layout()->set_spacing(0);
window->set_main_widget(widget);
auto label_button = GUI::Button::construct(widget);
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"));
@ -121,7 +121,7 @@ RefPtr<GUI::Window> make_toolbox_window()
form->insert_widget(VBWidgetType::GLabel);
};
auto button_button = GUI::Button::construct(widget);
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"));
@ -129,7 +129,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GButton);
};
auto spinbox_button = GUI::Button::construct(widget);
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"));
@ -137,7 +137,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GSpinBox);
};
auto editor_button = GUI::Button::construct(widget);
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"));
@ -145,7 +145,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GTextEditor);
};
auto progress_bar_button = GUI::Button::construct(widget);
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"));
@ -153,7 +153,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GProgressBar);
};
auto slider_button = GUI::Button::construct(widget);
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"));
@ -161,7 +161,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GSlider);
};
auto checkbox_button = GUI::Button::construct(widget);
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"));
@ -169,7 +169,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GCheckBox);
};
auto radiobutton_button = GUI::Button::construct(widget);
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"));
@ -177,7 +177,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GRadioButton);
};
auto scrollbar_button = GUI::Button::construct(widget);
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"));
@ -185,7 +185,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GScrollBar);
};
auto groupbox_button = GUI::Button::construct(widget);
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"));