diff options
87 files changed, 403 insertions, 438 deletions
diff --git a/Applications/About/main.cpp b/Applications/About/main.cpp index b4803209ac..6c646dfc69 100644 --- a/Applications/About/main.cpp +++ b/Applications/About/main.cpp @@ -69,12 +69,12 @@ int main(int argc, char** argv) widget->layout()->set_margins({ 0, 8, 0, 8 }); widget->layout()->set_spacing(8); - auto icon_label = GUI::Label::construct(widget); + auto icon_label = widget->add<GUI::Label>(); icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/serenity.png")); icon_label->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); icon_label->set_preferred_size(icon_label->icon()->size()); - auto label = GUI::Label::construct(widget); + auto label = widget->add<GUI::Label>(); label->set_font(Gfx::Font::default_bold_font()); label->set_text("SerenityOS"); label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); @@ -84,22 +84,22 @@ int main(int argc, char** argv) int rc = uname(&uts); ASSERT(rc == 0); - auto version_label = GUI::Label::construct(widget); + auto version_label = widget->add<GUI::Label>(); version_label->set_text(String::format("Version %s", uts.release)); version_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); version_label->set_preferred_size(0, 11); - auto git_info_label = GUI::Label::construct(widget); + auto git_info_label = widget->add<GUI::Label>(); git_info_label->set_text(String::format("Built on %s@%s", GIT_BRANCH, GIT_COMMIT)); git_info_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); git_info_label->set_preferred_size(0, 11); - auto git_changes_label = GUI::Label::construct(widget); + auto git_changes_label = widget->add<GUI::Label>(); git_changes_label->set_text(String::format("Changes: %s", GIT_CHANGES)); git_changes_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); git_changes_label->set_preferred_size(0, 11); - auto quit_button = GUI::Button::construct(widget); + auto quit_button = widget->add<GUI::Button>(); quit_button->set_text("Okay"); quit_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); quit_button->set_preferred_size(100, 20); diff --git a/Applications/Browser/InspectorWidget.cpp b/Applications/Browser/InspectorWidget.cpp index e9658bae1a..70cd9bc3e9 100644 --- a/Applications/Browser/InspectorWidget.cpp +++ b/Applications/Browser/InspectorWidget.cpp @@ -39,8 +39,8 @@ InspectorWidget::InspectorWidget(GUI::Widget* parent) : GUI::Widget(parent) { set_layout(make<GUI::VerticalBoxLayout>()); - auto splitter = GUI::VerticalSplitter::construct(this); - m_dom_tree_view = GUI::TreeView::construct(splitter); + auto splitter = add<GUI::VerticalSplitter>(); + m_dom_tree_view = splitter->add<GUI::TreeView>(); m_dom_tree_view->on_selection = [this](auto& index) { auto* node = static_cast<Node*>(index.internal_data()); node->document().set_inspected_node(node); @@ -55,13 +55,13 @@ InspectorWidget::InspectorWidget(GUI::Widget* parent) m_computed_style_table_view->set_model(nullptr); } }; - m_style_table_view = GUI::TableView::construct(nullptr); + m_style_table_view = GUI::TableView::construct(); m_style_table_view->set_size_columns_to_fit_content(true); - m_computed_style_table_view = GUI::TableView::construct(nullptr); + m_computed_style_table_view = GUI::TableView::construct(); m_computed_style_table_view->set_size_columns_to_fit_content(true); - auto tabwidget = GUI::TabWidget::construct(splitter); + auto tabwidget = splitter->add<GUI::TabWidget>(); tabwidget->add_widget("Styles", m_style_table_view); tabwidget->add_widget("Computed", m_computed_style_table_view); } diff --git a/Applications/Browser/main.cpp b/Applications/Browser/main.cpp index 5f34397ba5..d7554eed85 100644 --- a/Applications/Browser/main.cpp +++ b/Applications/Browser/main.cpp @@ -80,8 +80,8 @@ int main(int argc, char** argv) widget->set_layout(make<GUI::VerticalBoxLayout>()); widget->layout()->set_spacing(0); - auto toolbar = GUI::ToolBar::construct(widget); - auto html_widget = HtmlView::construct(widget); + auto toolbar = widget->add<GUI::ToolBar>(); + auto html_widget = widget->add<HtmlView>(); History<URL> history; @@ -121,7 +121,7 @@ int main(int argc, char** argv) html_widget->reload(); })); - auto location_box = GUI::TextBox::construct(toolbar); + auto location_box = toolbar->add<GUI::TextBox>(); location_box->on_return_pressed = [&] { html_widget->load(location_box->text()); @@ -151,7 +151,7 @@ int main(int argc, char** argv) location_box->set_focus(true); }); - auto statusbar = GUI::StatusBar::construct(widget); + auto statusbar = widget->add<GUI::StatusBar>(); html_widget->on_link_hover = [&](auto& href) { statusbar->set_text(href); diff --git a/Applications/Calculator/CalculatorWidget.cpp b/Applications/Calculator/CalculatorWidget.cpp index d986ee0eab..1adf7b9518 100644 --- a/Applications/Calculator/CalculatorWidget.cpp +++ b/Applications/Calculator/CalculatorWidget.cpp @@ -30,16 +30,15 @@ #include <LibGUI/Label.h> #include <LibGUI/TextBox.h> -CalculatorWidget::CalculatorWidget(GUI::Widget* parent) - : GUI::Widget(parent) +CalculatorWidget::CalculatorWidget() { set_fill_with_background_color(true); - m_entry = GUI::TextBox::construct(this); + m_entry = add<GUI::TextBox>(); m_entry->set_relative_rect(5, 5, 244, 26); m_entry->set_text_alignment(Gfx::TextAlignment::CenterRight); - m_label = GUI::Label::construct(this); + m_label = add<GUI::Label>(); m_label->set_relative_rect(12, 42, 27, 27); m_label->set_foreground_color(Color::NamedColor::Red); m_label->set_frame_shadow(Gfx::FrameShadow::Sunken); @@ -49,7 +48,7 @@ CalculatorWidget::CalculatorWidget(GUI::Widget* parent) update_display(); for (int i = 0; i < 10; i++) { - m_digit_button[i] = GUI::Button::construct(this); + m_digit_button[i] = add<GUI::Button>(); auto& button = *m_digit_button[i]; int p = i ? i + 2 : 0; int x = 55 + (p % 3) * 39; @@ -59,31 +58,31 @@ CalculatorWidget::CalculatorWidget(GUI::Widget* parent) add_button(button, i); } - m_mem_add_button = GUI::Button::construct(this); + m_mem_add_button = add<GUI::Button>(); m_mem_add_button->move_to(9, 177); m_mem_add_button->set_foreground_color(Color::NamedColor::Red); m_mem_add_button->set_text("M+"); add_button(*m_mem_add_button, Calculator::Operation::MemAdd); - m_mem_save_button = GUI::Button::construct(this); + m_mem_save_button = add<GUI::Button>(); m_mem_save_button->move_to(9, 144); m_mem_save_button->set_foreground_color(Color::NamedColor::Red); m_mem_save_button->set_text("MS"); add_button(*m_mem_save_button, Calculator::Operation::MemSave); - m_mem_recall_button = GUI::Button::construct(this); + m_mem_recall_button = add<GUI::Button>(); m_mem_recall_button->move_to(9, 111); m_mem_recall_button->set_foreground_color(Color::NamedColor::Red); m_mem_recall_button->set_text("MR"); add_button(*m_mem_recall_button, Calculator::Operation::MemRecall); - m_mem_clear_button = GUI::Button::construct(this); + m_mem_clear_button = add<GUI::Button>(); m_mem_clear_button->move_to(9, 78); m_mem_clear_button->set_foreground_color(Color::NamedColor::Red); m_mem_clear_button->set_text("MC"); add_button(*m_mem_clear_button, Calculator::Operation::MemClear); - m_clear_button = GUI::Button::construct(this); + m_clear_button = add<GUI::Button>(); m_clear_button->set_foreground_color(Color::NamedColor::Red); m_clear_button->set_text("C"); m_clear_button->on_click = [this](GUI::Button&) { @@ -94,7 +93,7 @@ CalculatorWidget::CalculatorWidget(GUI::Widget* parent) add_button(*m_clear_button); m_clear_button->set_relative_rect(187, 40, 60, 28); - m_clear_error_button = GUI::Button::construct(this); + m_clear_error_button = add<GUI::Button>(); m_clear_error_button->set_foreground_color(Color::NamedColor::Red); m_clear_error_button->set_text("CE"); m_clear_error_button->on_click = [this](GUI::Button&) { @@ -104,7 +103,7 @@ CalculatorWidget::CalculatorWidget(GUI::Widget* parent) add_button(*m_clear_error_button); m_clear_error_button->set_relative_rect(124, 40, 59, 28); - m_backspace_button = GUI::Button::construct(this); + m_backspace_button = add<GUI::Button>(); m_backspace_button->set_foreground_color(Color::NamedColor::Red); m_backspace_button->set_text("Backspace"); m_backspace_button->on_click = [this](GUI::Button&) { @@ -114,7 +113,7 @@ CalculatorWidget::CalculatorWidget(GUI::Widget* parent) add_button(*m_backspace_button); m_backspace_button->set_relative_rect(55, 40, 65, 28); - m_decimal_point_button = GUI::Button::construct(this); + m_decimal_point_button = add<GUI::Button>(); m_decimal_point_button->move_to(133, 177); m_decimal_point_button->set_foreground_color(Color::NamedColor::Blue); m_decimal_point_button->set_text("."); @@ -124,55 +123,55 @@ CalculatorWidget::CalculatorWidget(GUI::Widget* parent) }; add_button(*m_decimal_point_button); - m_sign_button = GUI::Button::construct(this); + m_sign_button = add<GUI::Button>(); m_sign_button->move_to(94, 177); m_sign_button->set_foreground_color(Color::NamedColor::Blue); m_sign_button->set_text("+/-"); add_button(*m_sign_button, Calculator::Operation::ToggleSign); - m_add_button = GUI::Button::construct(this); + m_add_button = add<GUI::Button>(); m_add_button->move_to(172, 177); m_add_button->set_foreground_color(Color::NamedColor::Red); m_add_button->set_text("+"); add_button(*m_add_button, Calculator::Operation::Add); - m_subtract_button = GUI::Button::construct(this); + m_subtract_button = add<GUI::Button>(); m_subtract_button->move_to(172, 144); m_subtract_button->set_foreground_color(Color::NamedColor::Red); m_subtract_button->set_text("-"); add_button(*m_subtract_button, Calculator::Operation::Subtract); - m_multiply_button = GUI::Button::construct(this); + m_multiply_button = add<GUI::Button>(); m_multiply_button->move_to(172, 111); m_multiply_button->set_foreground_color(Color::NamedColor::Red); m_multiply_button->set_text("*"); add_button(*m_multiply_button, Calculator::Operation::Multiply); - m_divide_button = GUI::Button::construct(this); + m_divide_button = add<GUI::Button>(); m_divide_button->move_to(172, 78); m_divide_button->set_foreground_color(Color::NamedColor::Red); m_divide_button->set_text("/"); add_button(*m_divide_button, Calculator::Operation::Divide); - m_sqrt_button = GUI::Button::construct(this); + m_sqrt_button = add<GUI::Button>(); m_sqrt_button->move_to(211, 78); m_sqrt_button->set_foreground_color(Color::NamedColor::Blue); m_sqrt_button->set_text("sqrt"); add_button(*m_sqrt_button, Calculator::Operation::Sqrt); - m_inverse_button = GUI::Button::construct(this); + m_inverse_button = add<GUI::Button>(); m_inverse_button->move_to(211, 144); m_inverse_button->set_foreground_color(Color::NamedColor::Blue); m_inverse_button->set_text("1/x"); add_button(*m_inverse_button, Calculator::Operation::Inverse); - m_percent_button = GUI::Button::construct(this); + m_percent_button = add<GUI::Button>(); m_percent_button->move_to(211, 111); m_percent_button->set_foreground_color(Color::NamedColor::Blue); m_percent_button->set_text("%"); add_button(*m_percent_button, Calculator::Operation::Percent); - m_equals_button = GUI::Button::construct(this); + m_equals_button = add<GUI::Button>(); m_equals_button->move_to(211, 177); m_equals_button->set_foreground_color(Color::NamedColor::Red); m_equals_button->set_text("="); diff --git a/Applications/Calculator/CalculatorWidget.h b/Applications/Calculator/CalculatorWidget.h index 099448632b..711725b542 100644 --- a/Applications/Calculator/CalculatorWidget.h +++ b/Applications/Calculator/CalculatorWidget.h @@ -37,7 +37,7 @@ public: virtual ~CalculatorWidget() override; private: - explicit CalculatorWidget(GUI::Widget*); + CalculatorWidget(); void add_button(GUI::Button&, Calculator::Operation); void add_button(GUI::Button&, int); void add_button(GUI::Button&); diff --git a/Applications/Calculator/main.cpp b/Applications/Calculator/main.cpp index 111a5318c3..6b166c5e25 100644 --- a/Applications/Calculator/main.cpp +++ b/Applications/Calculator/main.cpp @@ -60,7 +60,7 @@ int main(int argc, char** argv) window->set_resizable(false); window->set_rect({ 300, 200, 254, 213 }); - auto calc_widget = CalculatorWidget::construct(nullptr); + auto calc_widget = CalculatorWidget::construct(); window->set_main_widget(calc_widget); window->show(); diff --git a/Applications/ChanViewer/main.cpp b/Applications/ChanViewer/main.cpp index 5531747e5d..1f874fc2b7 100644 --- a/Applications/ChanViewer/main.cpp +++ b/Applications/ChanViewer/main.cpp @@ -62,17 +62,17 @@ int main(int argc, char** argv) widget->set_fill_with_background_color(true); widget->set_layout(make<GUI::VerticalBoxLayout>()); - auto board_combo = GUI::ComboBox::construct(widget); + auto board_combo = widget->add<GUI::ComboBox>(); board_combo->set_only_allow_values_from_model(true); board_combo->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); board_combo->set_preferred_size(0, 20); board_combo->set_model(BoardListModel::create()); - auto catalog_view = GUI::TableView::construct(widget); + auto catalog_view = widget->add<GUI::TableView>(); catalog_view->set_model(ThreadCatalogModel::create()); auto& catalog_model = *static_cast<ThreadCatalogModel*>(catalog_view->model()); - auto statusbar = GUI::StatusBar::construct(widget); + auto statusbar = widget->add<GUI::StatusBar>(); board_combo->on_change = [&] (auto&, const GUI::ModelIndex& index) { auto selected_board = board_combo->model()->data(index, GUI::Model::Role::Custom); diff --git a/Applications/DisplayProperties/DisplayProperties.cpp b/Applications/DisplayProperties/DisplayProperties.cpp index 53e3aef994..1760dfd47f 100644 --- a/Applications/DisplayProperties/DisplayProperties.cpp +++ b/Applications/DisplayProperties/DisplayProperties.cpp @@ -122,19 +122,19 @@ void DisplayPropertiesWidget::create_wallpaper_list() void DisplayPropertiesWidget::create_frame() { - auto tab_widget = GUI::TabWidget::construct(m_root_widget); + auto tab_widget = m_root_widget->add<GUI::TabWidget>(); // First, let's create the "Background" tab - auto background_splitter = GUI::VerticalSplitter::construct(nullptr); + auto background_splitter = GUI::VerticalSplitter::construct(); tab_widget->add_widget("Wallpaper", background_splitter); - auto background_content = GUI::Widget::construct(background_splitter.ptr()); + auto background_content = background_splitter->add<GUI::Widget>(); background_content->set_layout(make<GUI::VerticalBoxLayout>()); background_content->layout()->set_margins({ 4, 4, 4, 4 }); - m_wallpaper_preview = GUI::Label::construct(background_splitter); + m_wallpaper_preview = background_splitter->add<GUI::Label>(); - auto wallpaper_list = GUI::ListView::construct(background_content); + auto wallpaper_list = background_content->add<GUI::ListView>(); wallpaper_list->set_background_color(Color::White); wallpaper_list->set_model(*ItemListModel<AK::String>::create(m_wallpapers)); @@ -155,14 +155,14 @@ void DisplayPropertiesWidget::create_frame() }; // Let's add the settings tab - auto settings_splitter = GUI::VerticalSplitter::construct(nullptr); + auto settings_splitter = GUI::VerticalSplitter::construct(); tab_widget->add_widget("Settings", settings_splitter); - auto settings_content = GUI::Widget::construct(settings_splitter.ptr()); + auto settings_content = settings_splitter->add<GUI::Widget>(); settings_content->set_layout(make<GUI::VerticalBoxLayout>()); settings_content->layout()->set_margins({ 4, 4, 4, 4 }); - auto resolution_list = GUI::ListView::construct(settings_content); + auto resolution_list = settings_content->add<GUI::ListView>(); resolution_list->set_background_color(Color::White); resolution_list->set_model(*ItemListModel<Gfx::Size>::create(m_resolutions)); @@ -180,13 +180,13 @@ void DisplayPropertiesWidget::create_frame() settings_content->layout()->add_spacer(); // Add the apply and cancel buttons - auto bottom_widget = GUI::Widget::construct(m_root_widget.ptr()); + auto bottom_widget = m_root_widget->add<GUI::Widget>(); bottom_widget->set_layout(make<GUI::HorizontalBoxLayout>()); bottom_widget->layout()->add_spacer(); bottom_widget->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed); bottom_widget->set_preferred_size(1, 22); - auto apply_button = GUI::Button::construct(bottom_widget); + auto apply_button = bottom_widget->add<GUI::Button>(); apply_button->set_text("Apply"); apply_button->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed); apply_button->set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); @@ -195,7 +195,7 @@ void DisplayPropertiesWidget::create_frame() send_settings_to_window_server(tab_widget->active_tab_index()); }; - auto ok_button = GUI::Button::construct(bottom_widget); + auto ok_button = bottom_widget->add<GUI::Button>(); ok_button->set_text("OK"); ok_button->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed); ok_button->set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); @@ -205,7 +205,7 @@ void DisplayPropertiesWidget::create_frame() GUI::Application::the().quit(); }; - auto cancel_button = GUI::Button::construct(bottom_widget); + auto cancel_button = bottom_widget->add<GUI::Button>(); cancel_button->set_text("Cancel"); cancel_button->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed); cancel_button->set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp index c70fd8e215..fb2c6b998e 100644 --- a/Applications/FileManager/DirectoryView.cpp +++ b/Applications/FileManager/DirectoryView.cpp @@ -118,18 +118,17 @@ void DirectoryView::handle_activation(const GUI::ModelIndex& index) } }; -DirectoryView::DirectoryView(GUI::Widget* parent) - : GUI::StackWidget(parent) - , m_model(GUI::FileSystemModel::create()) +DirectoryView::DirectoryView() + : m_model(GUI::FileSystemModel::create()) { set_active_widget(nullptr); - m_item_view = GUI::ItemView::construct(this); + m_item_view = add<GUI::ItemView>(); m_item_view->set_model(model()); - m_columns_view = GUI::ColumnsView::construct(this); + m_columns_view = add<GUI::ColumnsView>(); m_columns_view->set_model(model()); - m_table_view = GUI::TableView::construct(this); + m_table_view = add<GUI::TableView>(); m_table_view->set_model(GUI::SortingProxyModel::create(m_model)); m_table_view->model()->set_key_column_and_sort_order(GUI::FileSystemModel::Column::Name, GUI::SortOrder::Ascending); diff --git a/Applications/FileManager/DirectoryView.h b/Applications/FileManager/DirectoryView.h index 55c31a4084..5992b977f0 100644 --- a/Applications/FileManager/DirectoryView.h +++ b/Applications/FileManager/DirectoryView.h @@ -90,7 +90,7 @@ public: GUI::FileSystemModel& model() { return *m_model; } private: - explicit DirectoryView(GUI::Widget* parent); + DirectoryView(); const GUI::FileSystemModel& model() const { return *m_model; } void handle_activation(const GUI::ModelIndex&); diff --git a/Applications/FileManager/PropertiesDialog.cpp b/Applications/FileManager/PropertiesDialog.cpp index 83bda32aea..082a819422 100644 --- a/Applications/FileManager/PropertiesDialog.cpp +++ b/Applications/FileManager/PropertiesDialog.cpp @@ -52,9 +52,9 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo set_rect({ 0, 0, 360, 420 }); set_resizable(false); - auto tab_widget = GUI::TabWidget::construct(main_widget); + auto tab_widget = main_widget->add<GUI::TabWidget>(); - auto general_tab = GUI::Widget::construct(tab_widget.ptr()); + auto general_tab = tab_widget->add<GUI::Widget>(); general_tab->set_layout(make<GUI::VerticalBoxLayout>()); general_tab->layout()->set_margins({ 12, 8, 12, 8 }); general_tab->layout()->set_spacing(10); @@ -62,19 +62,19 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo general_tab->layout()->add_spacer(); - auto file_container = GUI::Widget::construct(general_tab.ptr()); + auto file_container = general_tab->add<GUI::Widget>(); file_container->set_layout(make<GUI::HorizontalBoxLayout>()); file_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); file_container->layout()->set_spacing(20); file_container->set_preferred_size(0, 34); - m_icon = GUI::Label::construct(file_container); + m_icon = file_container->add<GUI::Label>(); m_icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); m_icon->set_preferred_size(32, 32); m_name = file_path.basename(); - m_name_box = GUI::TextBox::construct(file_container); + m_name_box = file_container->add<GUI::TextBox>(); m_name_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_name_box->set_preferred_size({ 0, 22 }); m_name_box->set_text(m_name); @@ -132,7 +132,7 @@ PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, boo general_tab->layout()->add_spacer(); - auto button_widget = GUI::Widget::construct(main_widget.ptr()); + auto button_widget = main_widget->add<GUI::Widget>(); button_widget->set_layout(make<GUI::HorizontalBoxLayout>()); button_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); button_widget->set_preferred_size(0, 24); @@ -212,24 +212,24 @@ bool PropertiesDialog::apply_changes() void PropertiesDialog::make_permission_checkboxes(NonnullRefPtr<GUI::Widget>& parent, PermissionMasks masks, String label_string, mode_t mode) { - auto widget = GUI::Widget::construct(parent.ptr()); + auto widget = parent->add<GUI::Widget>(); widget->set_layout(make<GUI::HorizontalBoxLayout>()); widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); widget->set_preferred_size(0, 16); widget->layout()->set_spacing(10); - auto label = GUI::Label::construct(label_string, widget); + auto label = widget->add<GUI::Label>(label_string); label->set_text_alignment(Gfx::TextAlignment::CenterLeft); - auto box_read = GUI::CheckBox::construct("Read", widget); + auto box_read = widget->add<GUI::CheckBox>("Read"); box_read->set_checked(mode & masks.read); box_read->on_checked = [&, masks](bool checked) { permission_changed(masks.read, checked); }; - auto box_write = GUI::CheckBox::construct("Write", widget); + auto box_write = widget->add<GUI::CheckBox>("Write"); box_write->set_checked(mode & masks.write); box_write->on_checked = [&, masks](bool checked) { permission_changed(masks.write, checked); }; - auto box_execute = GUI::CheckBox::construct("Execute", widget); + auto box_execute = widget->add<GUI::CheckBox>("Execute"); box_execute->set_checked(mode & masks.execute); box_execute->on_checked = [&, masks](bool checked) { permission_changed(masks.execute, checked); }; } @@ -241,17 +241,17 @@ void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair> property_labels.ensure_capacity(pairs.size()); for (auto pair : pairs) { - auto label_container = GUI::Widget::construct(parent.ptr()); + auto label_container = parent->add<GUI::Widget>(); label_container->set_layout(make<GUI::HorizontalBoxLayout>()); label_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); label_container->set_preferred_size(0, 14); label_container->layout()->set_spacing(12); - auto label_property = GUI::Label::construct(pair.property, label_container); + auto label_property = label_container->add<GUI::Label>(pair.property); label_property->set_text_alignment(Gfx::TextAlignment::CenterLeft); label_property->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); - GUI::Label::construct(pair.value, label_container)->set_text_alignment(Gfx::TextAlignment::CenterLeft); + label_container->add<GUI::Label>(pair.value)->set_text_alignment(Gfx::TextAlignment::CenterLeft); max_width = max(max_width, label_property->font().width(pair.property)); property_labels.append(label_property); @@ -263,7 +263,7 @@ void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair> NonnullRefPtr<GUI::Button> PropertiesDialog::make_button(String text, NonnullRefPtr<GUI::Widget>& parent) { - auto button = GUI::Button::construct(text, parent.ptr()); + auto button = parent->add<GUI::Button>(text); button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); button->set_preferred_size(70, 22); return button; @@ -273,7 +273,7 @@ void PropertiesDialog::make_divider(NonnullRefPtr<GUI::Widget>& parent) { parent->layout()->add_spacer(); - auto divider = GUI::Frame::construct(parent.ptr()); + auto divider = parent->add<GUI::Frame>(); divider->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); divider->set_preferred_size({ 0, 2 }); divider->set_frame_shape(Gfx::FrameShape::HorizontalLine); diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index b2ad4e3cd7..f47c33150d 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -96,18 +96,18 @@ int main(int argc, char** argv) widget->set_layout(make<GUI::VerticalBoxLayout>()); widget->layout()->set_spacing(0); - auto main_toolbar = GUI::ToolBar::construct(widget); - auto location_toolbar = GUI::ToolBar::construct(widget); + auto main_toolbar = widget->add<GUI::ToolBar>(); + auto location_toolbar = widget->add<GUI::ToolBar>(); location_toolbar->layout()->set_margins({ 6, 3, 6, 3 }); location_toolbar->set_preferred_size(0, 25); - auto location_label = GUI::Label::construct("Location: ", location_toolbar); + auto location_label = location_toolbar->add<GUI::Label>("Location: "); location_label->size_to_fit(); - auto location_textbox = GUI::TextEditor::construct(GUI::TextEditor::SingleLine, location_toolbar); + auto location_textbox = location_toolbar->add<GUI::TextBox>(); - auto splitter = GUI::HorizontalSplitter::construct(widget); - auto tree_view = GUI::TreeView::construct(splitter); + auto splitter = widget->add<GUI::HorizontalSplitter>(); + auto tree_view = splitter->add<GUI::TreeView>(); auto directories_model = GUI::FileSystemModel::create("/", GUI::FileSystemModel::Mode::DirectoriesOnly); tree_view->set_model(directories_model); tree_view->set_column_hidden(GUI::FileSystemModel::Column::Icon, true); @@ -120,11 +120,11 @@ int main(int argc, char** argv) tree_view->set_column_hidden(GUI::FileSystemModel::Column::SymlinkTarget, true); tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); tree_view->set_preferred_size(150, 0); - auto directory_view = DirectoryView::construct(splitter); + auto directory_view = splitter->add<DirectoryView>(); - auto statusbar = GUI::StatusBar::construct(widget); + auto statusbar = widget->add<GUI::StatusBar>(); - auto progressbar = GUI::ProgressBar::construct(statusbar); + auto progressbar = statusbar->add<GUI::ProgressBar>(); progressbar->set_caption("Generating thumbnails: "); progressbar->set_format(GUI::ProgressBar::Format::ValueSlashMax); progressbar->set_visible(false); @@ -171,7 +171,7 @@ int main(int argc, char** argv) }); auto mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) { - auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window); + auto input_box = window->add<GUI::InputBox>("Enter name:", "New directory"); if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { auto new_dir_path = canonicalized_path( String::format("%s/%s", @@ -325,9 +325,9 @@ int main(int argc, char** argv) RefPtr<PropertiesDialog> properties; if (selected.is_empty()) { - properties = PropertiesDialog::construct(model, path, true, window); + properties = window->add<PropertiesDialog>(model, path, true); } else { - properties = PropertiesDialog::construct(model, selected.first(), false, window); + properties = window->add<PropertiesDialog>(model, selected.first(), false); } properties->exec(); diff --git a/Applications/FontEditor/FontEditor.cpp b/Applications/FontEditor/FontEditor.cpp index 92e2fce624..1dfa4f2c0a 100644 --- a/Applications/FontEditor/FontEditor.cpp +++ b/Applications/FontEditor/FontEditor.cpp @@ -50,10 +50,10 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite else m_path = path; - m_glyph_map_widget = GlyphMapWidget::construct(*m_edited_font, this); + m_glyph_map_widget = add<GlyphMapWidget>(*m_edited_font); m_glyph_map_widget->move_to({ 90, 5 }); - m_glyph_editor_widget = GlyphEditorWidget::construct(*m_edited_font, this); + m_glyph_editor_widget = add<GlyphEditorWidget>(*m_edited_font); m_glyph_editor_widget->move_to({ 5, 5 }); m_ui = make<UI_FontEditorBottom>(); diff --git a/Applications/FontEditor/GlyphEditorWidget.cpp b/Applications/FontEditor/GlyphEditorWidget.cpp index 58bcc15618..1d0c350a9e 100644 --- a/Applications/FontEditor/GlyphEditorWidget.cpp +++ b/Applications/FontEditor/GlyphEditorWidget.cpp @@ -29,9 +29,8 @@ #include <LibGfx/Font.h> #include <LibGfx/Palette.h> -GlyphEditorWidget::GlyphEditorWidget(Gfx::Font& mutable_font, GUI::Widget* parent) - : GUI::Frame(parent) - , m_font(mutable_font) +GlyphEditorWidget::GlyphEditorWidget(Gfx::Font& mutable_font) + : m_font(mutable_font) { set_frame_thickness(2); set_frame_shadow(Gfx::FrameShadow::Sunken); diff --git a/Applications/FontEditor/GlyphEditorWidget.h b/Applications/FontEditor/GlyphEditorWidget.h index 5476482872..df6cfbfa1a 100644 --- a/Applications/FontEditor/GlyphEditorWidget.h +++ b/Applications/FontEditor/GlyphEditorWidget.h @@ -44,7 +44,7 @@ public: Function<void(u8)> on_glyph_altered; private: - GlyphEditorWidget(Gfx::Font&, GUI::Widget* parent); + GlyphEditorWidget(Gfx::Font&); virtual void paint_event(GUI::PaintEvent&) override; virtual void mousedown_event(GUI::MouseEvent&) override; virtual void mousemove_event(GUI::MouseEvent&) override; diff --git a/Applications/FontEditor/GlyphMapWidget.cpp b/Applications/FontEditor/GlyphMapWidget.cpp index bd0329c39e..f057b46bb7 100644 --- a/Applications/FontEditor/GlyphMapWidget.cpp +++ b/Applications/FontEditor/GlyphMapWidget.cpp @@ -29,9 +29,8 @@ #include <LibGfx/Font.h> #include <LibGfx/Palette.h> -GlyphMapWidget::GlyphMapWidget(Gfx::Font& mutable_font, GUI::Widget* parent) - : GUI::Frame(parent) - , m_font(mutable_font) +GlyphMapWidget::GlyphMapWidget(Gfx::Font& mutable_font) + : m_font(mutable_font) { set_frame_thickness(2); set_frame_shape(Gfx::FrameShape::Container); diff --git a/Applications/FontEditor/GlyphMapWidget.h b/Applications/FontEditor/GlyphMapWidget.h index 4598585b63..e9a9866ff5 100644 --- a/Applications/FontEditor/GlyphMapWidget.h +++ b/Applications/FontEditor/GlyphMapWidget.h @@ -51,7 +51,7 @@ public: Function<void(u8)> on_glyph_selected; private: - GlyphMapWidget(Gfx::Font&, GUI::Widget* parent); + explicit GlyphMapWidget(Gfx::Font&); virtual void paint_event(GUI::PaintEvent&) override; virtual void mousedown_event(GUI::MouseEvent&) override; diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp index 45baa6c1d1..2af401b9c9 100644 --- a/Applications/Help/main.cpp +++ b/Applications/Help/main.cpp @@ -82,18 +82,18 @@ int main(int argc, char* argv[]) widget->set_layout(make<GUI::VerticalBoxLayout>()); widget->layout()->set_spacing(0); - auto toolbar = GUI::ToolBar::construct(widget); + auto toolbar = widget->add<GUI::ToolBar>(); - auto splitter = GUI::HorizontalSplitter::construct(widget); + auto splitter = widget->add<GUI::HorizontalSplitter>(); auto model = ManualModel::create(); - auto tree_view = GUI::TreeView::construct(splitter); + auto tree_view = splitter->add<GUI::TreeView>(); tree_view->set_model(model); tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); tree_view->set_preferred_size(200, 500); - auto html_view = HtmlView::construct(splitter); + auto html_view = splitter->add<HtmlView>(); History history; diff --git a/Applications/IRCClient/IRCAppWindow.cpp b/Applications/IRCClient/IRCAppWindow.cpp index 80f9d8967c..0662fb0670 100644 --- a/Applications/IRCClient/IRCAppWindow.cpp +++ b/Applications/IRCClient/IRCAppWindow.cpp @@ -94,7 +94,7 @@ void IRCAppWindow::setup_client() }; if (m_client->hostname().is_empty()) { - auto input_box = GUI::InputBox::construct("Enter server:", "Connect to server", this); + auto input_box = add<GUI::InputBox>("Enter server:", "Connect to server"); auto result = input_box->exec(); if (result == GUI::InputBox::ExecCancel) ::exit(0); @@ -109,7 +109,7 @@ void IRCAppWindow::setup_client() void IRCAppWindow::setup_actions() { m_join_action = GUI::Action::create("Join channel", { Mod_Ctrl, Key_J }, Gfx::Bitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) { - auto input_box = GUI::InputBox::construct("Enter channel name:", "Join channel", this); + auto input_box = add<GUI::InputBox>("Enter channel name:", "Join channel"); if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) m_client->handle_join_action(input_box->text_value()); }); @@ -185,7 +185,7 @@ void IRCAppWindow::setup_widgets() widget->set_layout(make<GUI::VerticalBoxLayout>()); widget->layout()->set_spacing(0); - auto toolbar = GUI::ToolBar::construct(widget); + auto toolbar = widget->add<GUI::ToolBar>(); toolbar->set_has_frame(false); toolbar->add_action(*m_change_nick_action); toolbar->add_separator(); @@ -196,13 +196,13 @@ void IRCAppWindow::setup_widgets() toolbar->add_action(*m_open_query_action); toolbar->add_action(*m_close_query_action); - auto outer_container = GUI::Widget::construct(widget.ptr()); + auto outer_container = widget->add<GUI::Widget>(); outer_container->set_layout(make<GUI::VerticalBoxLayout>()); outer_container->layout()->set_margins({ 2, 0, 2, 2 }); - auto horizontal_container = GUI::HorizontalSplitter::construct(outer_container); + auto horizontal_container = outer_container->add<GUI::HorizontalSplitter>(); - m_window_list = GUI::TableView::construct(horizontal_container); + m_window_list = horizontal_container->add<GUI::TableView>(); m_window_list->set_headers_visible(false); m_window_list->set_alternating_row_colors(false); m_window_list->set_size_columns_to_fit_content(true); @@ -214,7 +214,7 @@ void IRCAppWindow::setup_widgets() set_active_window(m_client->window_at(index.row())); }; - m_container = GUI::StackWidget::construct(horizontal_container); + m_container = horizontal_container->add<GUI::StackWidget>(); m_container->on_active_widget_change = [this](auto*) { update_part_action(); }; diff --git a/Applications/IRCClient/IRCWindow.cpp b/Applications/IRCClient/IRCWindow.cpp index 835ef1f039..83ba78148a 100644 --- a/Applications/IRCClient/IRCWindow.cpp +++ b/Applications/IRCClient/IRCWindow.cpp @@ -45,12 +45,12 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na set_layout(make<GUI::VerticalBoxLayout>()); // Make a container for the log buffer view + (optional) member list. - auto container = GUI::HorizontalSplitter::construct(this); + auto container = add<GUI::HorizontalSplitter>(); - m_html_view = HtmlView::construct(container); + m_html_view = container->add<HtmlView>(); if (m_type == Channel) { - auto member_view = GUI::TableView::construct(container); + auto member_view = container->add<GUI::TableView>(); member_view->set_headers_visible(false); member_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); member_view->set_preferred_size(100, 0); @@ -59,7 +59,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na member_view->set_activates_on_selection(true); } - m_text_editor = GUI::TextEditor::construct(GUI::TextEditor::SingleLine, this); + m_text_editor = add<GUI::TextBox>(); m_text_editor->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_text_editor->set_preferred_size(0, 19); m_text_editor->on_return_pressed = [this] { diff --git a/Applications/PaintBrush/PaintableWidget.cpp b/Applications/PaintBrush/PaintableWidget.cpp index 2fe9b26f8f..164f129220 100644 --- a/Applications/PaintBrush/PaintableWidget.cpp +++ b/Applications/PaintBrush/PaintableWidget.cpp @@ -37,8 +37,7 @@ PaintableWidget& PaintableWidget::the() return *s_the; } -PaintableWidget::PaintableWidget(GUI::Widget* parent) - : GUI::Widget(parent) +PaintableWidget::PaintableWidget() { ASSERT(!s_the); s_the = this; diff --git a/Applications/PaintBrush/PaintableWidget.h b/Applications/PaintBrush/PaintableWidget.h index 6676ac5bb8..361eb86923 100644 --- a/Applications/PaintBrush/PaintableWidget.h +++ b/Applications/PaintBrush/PaintableWidget.h @@ -34,7 +34,6 @@ class PaintableWidget final : public GUI::Widget { public: static PaintableWidget& the(); - explicit PaintableWidget(GUI::Widget* parent); virtual ~PaintableWidget() override; Color primary_color() const { return m_primary_color; } @@ -58,6 +57,8 @@ public: Function<void(Color)> on_secondary_color_change; private: + PaintableWidget(); + virtual bool accepts_focus() const override { return true; } virtual void paint_event(GUI::PaintEvent&) override; virtual void second_paint_event(GUI::PaintEvent&) override; diff --git a/Applications/PaintBrush/PaletteWidget.cpp b/Applications/PaintBrush/PaletteWidget.cpp index a178bc2041..e7394c10fd 100644 --- a/Applications/PaintBrush/PaletteWidget.cpp +++ b/Applications/PaintBrush/PaletteWidget.cpp @@ -33,9 +33,8 @@ class ColorWidget : public GUI::Frame { C_OBJECT(ColorWidget) public: - explicit ColorWidget(Color color, PaletteWidget& palette_widget, GUI::Widget* parent) - : GUI::Frame(parent) - , m_palette_widget(palette_widget) + explicit ColorWidget(Color color, PaletteWidget& palette_widget) + : m_palette_widget(palette_widget) , m_color(color) { set_frame_thickness(2); @@ -72,9 +71,8 @@ private: Color m_color; }; -PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GUI::Widget* parent) - : GUI::Frame(parent) - , m_paintable_widget(paintable_widget) +PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget) + : m_paintable_widget(paintable_widget) { set_frame_shape(Gfx::FrameShape::Panel); set_frame_shadow(Gfx::FrameShadow::Raised); @@ -84,7 +82,7 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GUI::Widget* par set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); set_preferred_size(0, 34); - m_secondary_color_widget = GUI::Frame::construct(this); + m_secondary_color_widget = add<GUI::Frame>(); m_secondary_color_widget->set_frame_thickness(2); m_secondary_color_widget->set_frame_shape(Gfx::FrameShape::Container); m_secondary_color_widget->set_frame_shadow(Gfx::FrameShadow::Sunken); @@ -92,7 +90,7 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GUI::Widget* par m_secondary_color_widget->set_fill_with_background_color(true); set_secondary_color(paintable_widget.secondary_color()); - m_primary_color_widget = GUI::Frame::construct(this); + m_primary_color_widget = add<GUI::Frame>(); m_primary_color_widget->set_frame_thickness(2); m_primary_color_widget->set_frame_shape(Gfx::FrameShape::Container); m_primary_color_widget->set_frame_shadow(Gfx::FrameShadow::Sunken); @@ -110,21 +108,21 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GUI::Widget* par set_secondary_color(color); }; - auto color_container = GUI::Widget::construct(this); + auto color_container = add<GUI::Widget>(); color_container->set_relative_rect(m_secondary_color_widget->relative_rect().right() + 2, 2, 500, 32); color_container->set_layout(make<GUI::VerticalBoxLayout>()); color_container->layout()->set_spacing(1); - auto top_color_container = GUI::Widget::construct(color_container.ptr()); + auto top_color_container = color_container->add<GUI::Widget>(); top_color_container->set_layout(make<GUI::HorizontalBoxLayout>()); top_color_container->layout()->set_spacing(1); - auto bottom_color_container = GUI::Widget::construct(color_container.ptr()); + auto bottom_color_container = color_container->add<GUI::Widget>(); bottom_color_container->set_layout(make<GUI::HorizontalBoxLayout>()); bottom_color_container->layout()->set_spacing(1); auto add_color_widget = [&](GUI::Widget* container, Color color) { - auto color_widget = ColorWidget::construct(color, *this, container); + auto color_widget = container->add<ColorWidget>(color, *this); color_widget->set_fill_with_background_color(true); auto pal = color_widget->palette(); pal.set_color(ColorRole::Background, color); diff --git a/Applications/PaintBrush/PaletteWidget.h b/Applications/PaintBrush/PaletteWidget.h index 897a227010..0fbabcd78c 100644 --- a/Applications/PaintBrush/PaletteWidget.h +++ b/Applications/PaintBrush/PaletteWidget.h @@ -33,7 +33,7 @@ class PaintableWidget; class PaletteWidget final : public GUI::Frame { C_OBJECT(PaletteWidget) public: - explicit PaletteWidget(PaintableWidget&, GUI::Widget* parent); + explicit PaletteWidget(PaintableWidget&); virtual ~PaletteWidget() override; void set_primary_color(Color); diff --git a/Applications/PaintBrush/ToolboxWidget.cpp b/Applications/PaintBrush/ToolboxWidget.cpp index 4085311933..7c60e6cbad 100644 --- a/Applications/PaintBrush/ToolboxWidget.cpp +++ b/Applications/PaintBrush/ToolboxWidget.cpp @@ -40,9 +40,8 @@ class ToolButton final : public GUI::Button { C_OBJECT(ToolButton) public: - ToolButton(const String& name, GUI::Widget* parent, OwnPtr<Tool>&& tool) - : GUI::Button(parent) - , m_tool(move(tool)) + ToolButton(const String& name, OwnPtr<Tool>&& tool) + : m_tool(move(tool)) { set_tooltip(name); } @@ -60,8 +59,7 @@ private: OwnPtr<Tool> m_tool; }; -ToolboxWidget::ToolboxWidget(GUI::Widget* parent) - : GUI::Frame(parent) +ToolboxWidget::ToolboxWidget() { set_fill_with_background_color(true); @@ -76,7 +74,7 @@ ToolboxWidget::ToolboxWidget(GUI::Widget* parent) layout()->set_margins({ 4, 4, 4, 4 }); auto add_tool = [&](const StringView& name, const StringView& icon_name, OwnPtr<Tool>&& tool) { - auto button = ToolButton::construct(name, this, move(tool)); + auto button = add<ToolButton>(name, move(tool)); button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); button->set_preferred_size(0, 32); button->set_checkable(true); diff --git a/Applications/PaintBrush/ToolboxWidget.h b/Applications/PaintBrush/ToolboxWidget.h index 7553144da1..7c15a6f596 100644 --- a/Applications/PaintBrush/ToolboxWidget.h +++ b/Applications/PaintBrush/ToolboxWidget.h @@ -31,6 +31,6 @@ class ToolboxWidget final : public GUI::Frame { C_OBJECT(ToolboxWidget) public: - explicit ToolboxWidget(GUI::Widget* parent); + explicit ToolboxWidget(); virtual ~ToolboxWidget() override; }; diff --git a/Applications/PaintBrush/main.cpp b/Applications/PaintBrush/main.cpp index a4f6680df1..bb6e42b876 100644 --- a/Applications/PaintBrush/main.cpp +++ b/Applications/PaintBrush/main.cpp @@ -63,15 +63,15 @@ int main(int argc, char** argv) horizontal_container->set_layout(make<GUI::HorizontalBoxLayout>()); horizontal_container->layout()->set_spacing(0); - new ToolboxWidget(horizontal_container); + horizontal_container->add<ToolboxWidget>(); - auto vertical_container = GUI::Widget::construct(horizontal_container.ptr()); + auto vertical_container = horizontal_container->add<GUI::Widget>(); vertical_container->set_layout(make<GUI::VerticalBoxLayout>()); vertical_container->layout()->set_spacing(0); - auto paintable_widget = PaintableWidget::construct(vertical_container); + auto paintable_widget = vertical_container->add<PaintableWidget>(); paintable_widget->set_focus(true); - PaletteWidget::construct(*paintable_widget, vertical_container); + vertical_container->add<PaletteWidget>(*paintable_widget); window->show(); diff --git a/Applications/Piano/KeysWidget.cpp b/Applications/Piano/KeysWidget.cpp index c048c6eb15..9fd8779d5a 100644 --- a/Applications/Piano/KeysWidget.cpp +++ b/Applications/Piano/KeysWidget.cpp @@ -29,9 +29,8 @@ #include "AudioEngine.h" #include <LibGUI/Painter.h> -KeysWidget::KeysWidget(GUI::Widget* parent, AudioEngine& audio_engine) - : GUI::Frame(parent) - , m_audio_engine(audio_engine) +KeysWidget::KeysWidget(AudioEngine& audio_engine) + : m_audio_engine(audio_engine) { set_frame_thickness(2); set_frame_shadow(Gfx::FrameShadow::Sunken); diff --git a/Applications/Piano/KeysWidget.h b/Applications/Piano/KeysWidget.h index 2676bffe85..ee46e2b1a2 100644 --- a/Applications/Piano/KeysWidget.h +++ b/Applications/Piano/KeysWidget.h @@ -43,7 +43,7 @@ public: void set_key(int key, Switch); private: - KeysWidget(GUI::Widget* parent, AudioEngine&); + explicit KeysWidget(AudioEngine&); virtual void paint_event(GUI::PaintEvent&) override; virtual void mousedown_event(GUI::MouseEvent&) override; diff --git a/Applications/Piano/KnobsWidget.cpp b/Applications/Piano/KnobsWidget.cpp index f817b58db3..c272ff80e8 100644 --- a/Applications/Piano/KnobsWidget.cpp +++ b/Applications/Piano/KnobsWidget.cpp @@ -32,9 +32,8 @@ #include <LibGUI/Label.h> #include <LibGUI/Slider.h> -KnobsWidget::KnobsWidget(GUI::Widget* parent, AudioEngine& audio_engine, MainWidget& main_widget) - : GUI::Frame(parent) - , m_audio_engine(audio_engine) +KnobsWidget::KnobsWidget(AudioEngine& audio_engine, MainWidget& main_widget) + : m_audio_engine(audio_engine) , m_main_widget(main_widget) { set_frame_thickness(2); @@ -43,38 +42,38 @@ KnobsWidget::KnobsWidget(GUI::Widget* parent, AudioEngine& audio_engine, MainWid set_layout(make<GUI::VerticalBoxLayout>()); set_fill_with_background_color(true); - m_labels_container = GUI::Widget::construct(this); + m_labels_container = add<GUI::Widget>(); m_labels_container->set_layout(make<GUI::HorizontalBoxLayout>()); m_labels_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_labels_container->set_preferred_size(0, 20); - m_octave_label = GUI::Label::construct("Octave", m_labels_container); - m_wave_label = GUI::Label::construct("Wave", m_labels_container); - m_attack_label = GUI::Label::construct("Attack", m_labels_container); - m_decay_label = GUI::Label::construct("Decay", m_labels_container); - m_sustain_label = GUI::Label::construct("Sustain", m_labels_container); - m_release_label = GUI::Label::construct("Release", m_labels_container); - m_delay_label = GUI::Label::construct("Delay", m_labels_container); + m_octave_label = m_labels_container->add<GUI::Label>("Octave"); + m_wave_label = m_labels_container->add<GUI::Label>("Wave"); + m_attack_label = m_labels_container->add<GUI::Label>("Attack"); + m_decay_label = m_labels_container->add<GUI::Label>("Decay"); + m_sustain_label = m_labels_container->add<GUI::Label>("Sustain"); + m_release_label = m_labels_container->add<GUI::Label>("Release"); + m_delay_label = m_labels_container->add<GUI::Label>("Delay"); - m_values_container = GUI::Widget::construct(this); + m_values_container = add<GUI::Widget>(); m_values_container->set_layout(make<GUI::HorizontalBoxLayout>()); m_values_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_values_container->set_preferred_size(0, 10); - m_octave_value = GUI::Label::construct(String::number(m_audio_engine.octave()), m_values_container); - m_wave_value = GUI::Label::construct(wave_strings[m_audio_engine.wave()], m_values_container); - m_attack_value = GUI::Label::construct(String::number(m_audio_engine.attack()), m_values_container); - m_decay_value = GUI::Label::construct(String::number(m_audio_engine.decay()), m_values_container); - m_sustain_value = GUI::Label::construct(String::number(m_audio_engine.sustain()), m_values_container); - m_release_value = GUI::Label::construct(String::number(m_audio_engine.release()), m_values_container); - m_delay_value = GUI::Label::construct(String::number(m_audio_engine.delay() / m_audio_engine.tick()), m_values_container); + m_octave_value = m_values_container->add<GUI::Label>(String::number(m_audio_engine.octave())); + m_wave_value = m_values_container->add<GUI::Label>(wave_strings[m_audio_engine.wave()]); + m_attack_value = m_values_container->add<GUI::Label>(String::number(m_audio_engine.attack())); + m_decay_value = m_values_container->add<GUI::Label>(String::number(m_audio_engine.decay())); + m_sustain_value = m_values_container->add<GUI::Label>(String::number(m_audio_engine.sustain())); + m_release_value = m_values_container->add<GUI::Label>(String::number(m_audio_engine.release())); + m_delay_value = m_values_container->add<GUI::Label>(String::number(m_audio_engine.delay() / m_audio_engine.tick())); - m_knobs_container = GUI::Widget::construct(this); + m_knobs_container = add<GUI::Widget>(); m_knobs_container->set_layout(make<GUI::HorizontalBoxLayout>()); // FIXME: Implement vertical flipping in GSlider, not here. - m_octave_knob = GUI::VerticalSlider::construct(m_knobs_container); + m_octave_knob = m_knobs_container->add<GUI::VerticalSlider>(); m_octave_knob->set_tooltip("Z: octave down, X: octave up"); m_octave_knob->set_range(octave_min - 1, octave_max - 1); m_octave_knob->set_value((octave_max - 1) - (m_audio_engine.octave() - 1)); @@ -86,7 +85,7 @@ KnobsWidget::KnobsWidget(GUI::Widget* parent, AudioEngine& audio_engine, MainWid m_octave_value->set_text(String::number(new_octave)); }; - m_wave_knob = GUI::VerticalSlider::construct(m_knobs_container); + m_wave_knob = m_knobs_container->add<GUI::VerticalSlider>(); m_wave_knob->set_tooltip("C: cycle through waveforms"); m_wave_knob->set_range(0, last_wave); m_wave_knob->set_value(last_wave - m_audio_engine.wave()); @@ -98,7 +97,7 @@ KnobsWidget::KnobsWidget(GUI::Widget* parent, AudioEngine& audio_engine, MainWid }; constexpr int max_attack = 1000; - m_attack_knob = GUI::VerticalSlider::construct(m_knobs_container); + m_attack_knob = m_knobs_container->add<GUI::VerticalSlider>(); m_attack_knob->set_range(0, max_attack); m_attack_knob->set_value(max_attack - m_audio_engine.attack()); m_attack_knob->set_step(100); @@ -110,7 +109,7 @@ KnobsWidget::KnobsWidget(GUI::Widget* parent, AudioEngine& audio_engine, MainWid }; constexpr int max_decay = 1000; - m_decay_knob = GUI::VerticalSlider::construct(m_knobs_container); + m_decay_knob = m_knobs_container->add<GUI::VerticalSlider>(); m_decay_knob->set_range(0, max_decay); m_decay_knob->set_value(max_decay - m_audio_engine.decay()); m_decay_knob->set_step(100); @@ -122,7 +121,7 @@ KnobsWidget::KnobsWidget(GUI::Widget* parent, AudioEngine& audio_engine, MainWid }; constexpr int max_sustain = 1000; - m_sustain_knob = GUI::VerticalSlider::construct(m_knobs_container); + m_sustain_knob = m_knobs_container->add<GUI::VerticalSlider>(); m_sustain_knob->set_range(0, max_sustain); m_sustain_knob->set_value(max_sustain - m_audio_engine.sustain()); m_sustain_knob->set_step(100); @@ -134,7 +133,7 @@ KnobsWidget::KnobsWidget(GUI::Widget* parent, AudioEngine& audio_engine, MainWid }; constexpr int max_release = 1000; - m_release_knob = GUI::VerticalSlider::construct(m_knobs_container); + m_release_knob = m_knobs_container->add<GUI::VerticalSlider>(); m_release_knob->set_range(0, max_release); m_release_knob->set_value(max_release - m_audio_engine.release()); m_release_knob->set_step(100); @@ -146,7 +145,7 @@ KnobsWidget::KnobsWidget(GUI::Widget* parent, AudioEngine& audio_engine, MainWid }; constexpr int max_delay = 8; - m_delay_knob = GUI::VerticalSlider::construct(m_knobs_container); + m_delay_knob = m_knobs_container->add<GUI::VerticalSlider>(); m_delay_knob->set_range(0, max_delay); m_delay_knob->set_value(max_delay - (m_audio_engine.delay() / m_audio_engine.tick())); m_delay_knob->on_value_changed = [this](int value) { diff --git a/Applications/Piano/KnobsWidget.h b/Applications/Piano/KnobsWidget.h index 853039fed5..315141144e 100644 --- a/Applications/Piano/KnobsWidget.h +++ b/Applications/Piano/KnobsWidget.h @@ -40,7 +40,7 @@ public: void update_knobs(); private: - KnobsWidget(GUI::Widget* parent, AudioEngine&, MainWidget&); + KnobsWidget(AudioEngine&, MainWidget&); AudioEngine& m_audio_engine; MainWidget& m_main_widget; diff --git a/Applications/Piano/MainWidget.cpp b/Applications/Piano/MainWidget.cpp index a119769f78..c70747d4c4 100644 --- a/Applications/Piano/MainWidget.cpp +++ b/Applications/Piano/MainWidget.cpp @@ -43,30 +43,30 @@ MainWidget::MainWidget(AudioEngine& audio_engine) layout()->set_margins({ 2, 2, 2, 2 }); set_fill_with_background_color(true); - m_wave_widget = WaveWidget::construct(this, audio_engine); + m_wave_widget = add<WaveWidget>(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(nullptr, audio_engine); + m_roll_widget = RollWidget::construct(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(nullptr, audio_engine); + m_sampler_widget = SamplerWidget::construct(audio_engine); - m_tab_widget = GUI::TabWidget::construct(this); + 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_keys_and_knobs_container = GUI::Widget::construct(this); + m_keys_and_knobs_container = add<GUI::Widget>(); m_keys_and_knobs_container->set_layout(make<GUI::HorizontalBoxLayout>()); m_keys_and_knobs_container->layout()->set_spacing(2); m_keys_and_knobs_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_keys_and_knobs_container->set_preferred_size(0, 100); m_keys_and_knobs_container->set_fill_with_background_color(true); - m_keys_widget = KeysWidget::construct(m_keys_and_knobs_container, audio_engine); + m_keys_widget = m_keys_and_knobs_container->add<KeysWidget>(audio_engine); - m_knobs_widget = KnobsWidget::construct(m_keys_and_knobs_container, audio_engine, *this); + m_knobs_widget = m_keys_and_knobs_container->add<KnobsWidget>(audio_engine, *this); m_knobs_widget->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_knobs_widget->set_preferred_size(350, 0); } diff --git a/Applications/Piano/RollWidget.cpp b/Applications/Piano/RollWidget.cpp index 6eb72573c6..8efb6dd671 100644 --- a/Applications/Piano/RollWidget.cpp +++ b/Applications/Piano/RollWidget.cpp @@ -33,9 +33,8 @@ constexpr int note_height = 20; constexpr int roll_height = note_count * note_height; -RollWidget::RollWidget(GUI::Widget* parent, AudioEngine& audio_engine) - : ScrollableWidget(parent) - , m_audio_engine(audio_engine) +RollWidget::RollWidget(AudioEngine& audio_engine) + : m_audio_engine(audio_engine) { set_frame_thickness(2); set_frame_shadow(Gfx::FrameShadow::Sunken); diff --git a/Applications/Piano/RollWidget.h b/Applications/Piano/RollWidget.h index 980ed70b76..e83597931a 100644 --- a/Applications/Piano/RollWidget.h +++ b/Applications/Piano/RollWidget.h @@ -38,7 +38,7 @@ public: virtual ~RollWidget() override; private: - RollWidget(GUI::Widget* parent, AudioEngine&); + explicit RollWidget(AudioEngine&); virtual void paint_event(GUI::PaintEvent&) override; virtual void mousedown_event(GUI::MouseEvent& event) override; diff --git a/Applications/Piano/SamplerWidget.cpp b/Applications/Piano/SamplerWidget.cpp index ce9d1f7f9c..ea227659b9 100644 --- a/Applications/Piano/SamplerWidget.cpp +++ b/Applications/Piano/SamplerWidget.cpp @@ -33,9 +33,8 @@ #include <LibGUI/MessageBox.h> #include <LibGUI/Painter.h> -WaveEditor::WaveEditor(GUI::Widget* parent, AudioEngine& audio_engine) - : GUI::Frame(parent) - , m_audio_engine(audio_engine) +WaveEditor::WaveEditor(AudioEngine& audio_engine) + : m_audio_engine(audio_engine) { set_frame_thickness(2); set_frame_shadow(Gfx::FrameShadow::Sunken); @@ -92,9 +91,8 @@ void WaveEditor::paint_event(GUI::PaintEvent& event) } } -SamplerWidget::SamplerWidget(GUI::Widget* parent, AudioEngine& audio_engine) - : GUI::Frame(parent) - , m_audio_engine(audio_engine) +SamplerWidget::SamplerWidget(AudioEngine& audio_engine) + : m_audio_engine(audio_engine) { set_frame_thickness(2); set_frame_shadow(Gfx::FrameShadow::Sunken); @@ -104,13 +102,13 @@ SamplerWidget::SamplerWidget(GUI::Widget* parent, AudioEngine& audio_engine) layout()->set_spacing(10); set_fill_with_background_color(true); - m_open_button_and_recorded_sample_name_container = GUI::Widget::construct(this); + m_open_button_and_recorded_sample_name_container = add<GUI::Widget>(); m_open_button_and_recorded_sample_name_container->set_layout(make<GUI::HorizontalBoxLayout>()); m_open_button_and_recorded_sample_name_container->layout()->set_spacing(10); m_open_button_and_recorded_sample_name_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_open_button_and_recorded_sample_name_container->set_preferred_size(0, 24); - m_open_button = GUI::Button::construct(m_open_button_and_recorded_sample_name_container); + m_open_button = m_open_button_and_recorded_sample_name_container->add<GUI::Button>(); m_open_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); m_open_button->set_preferred_size(24, 24); m_open_button->set_focusable(false); @@ -128,10 +126,10 @@ SamplerWidget::SamplerWidget(GUI::Widget* parent, AudioEngine& audio_engine) m_wave_editor->update(); }; - m_recorded_sample_name = GUI::Label::construct("No sample loaded", m_open_button_and_recorded_sample_name_container); + m_recorded_sample_name = m_open_button_and_recorded_sample_name_container->add<GUI::Label>("No sample loaded"); m_recorded_sample_name->set_text_alignment(Gfx::TextAlignment::CenterLeft); - m_wave_editor = WaveEditor::construct(this, m_audio_engine); + m_wave_editor = add<WaveEditor>(m_audio_engine); m_wave_editor->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_wave_editor->set_preferred_size(0, 100); } diff --git a/Applications/Piano/SamplerWidget.h b/Applications/Piano/SamplerWidget.h index 1db504dbd2..11c4ec90db 100644 --- a/Applications/Piano/SamplerWidget.h +++ b/Applications/Piano/SamplerWidget.h @@ -36,7 +36,7 @@ public: virtual ~WaveEditor() override; private: - WaveEditor(GUI::Widget* parent, AudioEngine&); + explicit WaveEditor(AudioEngine&); virtual void paint_event(GUI::PaintEvent&) override; @@ -51,7 +51,7 @@ public: virtual ~SamplerWidget() override; private: - SamplerWidget(GUI::Widget* parent, AudioEngine&); + explicit SamplerWidget(AudioEngine&); AudioEngine& m_audio_engine; diff --git a/Applications/Piano/WaveWidget.cpp b/Applications/Piano/WaveWidget.cpp index 1d592b60d2..434f51cf4d 100644 --- a/Applications/Piano/WaveWidget.cpp +++ b/Applications/Piano/WaveWidget.cpp @@ -30,9 +30,8 @@ #include <LibGUI/Painter.h> #include <limits> -WaveWidget::WaveWidget(GUI::Widget* parent, AudioEngine& audio_engine) - : GUI::Frame(parent) - , m_audio_engine(audio_engine) +WaveWidget::WaveWidget(AudioEngine& audio_engine) + : m_audio_engine(audio_engine) { set_frame_thickness(2); set_frame_shadow(Gfx::FrameShadow::Sunken); diff --git a/Applications/Piano/WaveWidget.h b/Applications/Piano/WaveWidget.h index 0ead14fed9..41475eaa11 100644 --- a/Applications/Piano/WaveWidget.h +++ b/Applications/Piano/WaveWidget.h @@ -37,7 +37,7 @@ public: virtual ~WaveWidget() override; private: - WaveWidget(GUI::Widget* parent, AudioEngine&); + explicit WaveWidget(AudioEngine&); virtual void paint_event(GUI::PaintEvent&) override; diff --git a/Applications/SoundPlayer/SampleWidget.cpp b/Applications/SoundPlayer/SampleWidget.cpp index aab15facba..1346c218a3 100644 --- a/Applications/SoundPlayer/SampleWidget.cpp +++ b/Applications/SoundPlayer/SampleWidget.cpp @@ -29,8 +29,7 @@ #include <LibGUI/Painter.h> #include <LibM/math.h> -SampleWidget::SampleWidget(GUI::Widget* parent) - : GUI::Frame(parent) +SampleWidget::SampleWidget() { set_frame_shape(Gfx::FrameShape::Container); set_frame_shadow(Gfx::FrameShadow::Sunken); diff --git a/Applications/SoundPlayer/SampleWidget.h b/Applications/SoundPlayer/SampleWidget.h index 2c8a2be8ec..04aeb34ba1 100644 --- a/Applications/SoundPlayer/SampleWidget.h +++ b/Applications/SoundPlayer/SampleWidget.h @@ -39,7 +39,7 @@ public: void set_buffer(Audio::Buffer*); private: - explicit SampleWidget(GUI::Widget* parent); + SampleWidget(); virtual void paint_event(GUI::PaintEvent&) override; RefPtr<Audio::Buffer> m_buffer; diff --git a/Applications/SoundPlayer/SoundPlayerWidget.cpp b/Applications/SoundPlayer/SoundPlayerWidget.cpp index 32ac6b1507..b3625e2e23 100644 --- a/Applications/SoundPlayer/SoundPlayerWidget.cpp +++ b/Applications/SoundPlayer/SoundPlayerWidget.cpp @@ -41,36 +41,36 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C set_layout(make<GUI::VerticalBoxLayout>()); layout()->set_margins({ 2, 2, 2, 2 }); - auto status_widget = GUI::Widget::construct(this); + auto status_widget = add<GUI::Widget>(); status_widget->set_fill_with_background_color(true); status_widget->set_layout(make<GUI::HorizontalBoxLayout>()); - m_elapsed = GUI::Label::construct(status_widget); + m_elapsed = status_widget->add<GUI::Label>(); m_elapsed->set_frame_shape(Gfx::FrameShape::Container); m_elapsed->set_frame_shadow(Gfx::FrameShadow::Sunken); m_elapsed->set_frame_thickness(2); m_elapsed->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_elapsed->set_preferred_size(80, 0); - auto sample_widget_container = GUI::Widget::construct(status_widget.ptr()); + auto sample_widget_container = status_widget->add<GUI::Widget>(); sample_widget_container->set_layout(make<GUI::HorizontalBoxLayout>()); sample_widget_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); - m_sample_widget = SampleWidget::construct(sample_widget_container); + m_sample_widget = sample_widget_container->add<SampleWidget>(); - m_remaining = GUI::Label::construct(status_widget); + m_remaining = status_widget->add<GUI::Label>(); m_remaining->set_frame_shape(Gfx::FrameShape::Container); m_remaining->set_frame_shadow(Gfx::FrameShadow::Sunken); m_remaining->set_frame_thickness(2); m_remaining->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_remaining->set_preferred_size(80, 0); - m_slider = Slider::construct(Orientation::Horizontal, this); + m_slider = add<Slider>(Orientation::Horizontal); m_slider->set_min(0); m_slider->set_enabled(false); m_slider->on_knob_released = [&](int value) { m_manager.seek(denormalize_rate(value)); }; - auto control_widget = GUI::Widget::construct(this); + auto control_widget = add<GUI::Widget>(); control_widget->set_fill_with_background_color(true); control_widget->set_layout(make<GUI::HorizontalBoxLayout>()); control_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); @@ -78,19 +78,19 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C control_widget->layout()->set_margins({ 10, 2, 10, 2 }); control_widget->layout()->set_spacing(10); - m_play = GUI::Button::construct(control_widget); + m_play = control_widget->add<GUI::Button>(); m_play->set_icon(*m_pause_icon); m_play->set_enabled(false); m_play->on_click = [this](GUI::Button& button) { button.set_icon(m_manager.toggle_pause() ? *m_play_icon : *m_pause_icon); }; - m_stop = GUI::Button::construct(control_widget); + m_stop = control_widget->add<GUI::Button>(); m_stop->set_enabled(false); m_stop->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/stop.png")); m_stop->on_click = [&](GUI::Button&) { m_manager.stop(); }; - m_status = GUI::Label::construct(this); + m_status = add<GUI::Label>(); m_status->set_frame_shape(Gfx::FrameShape::Box); m_status->set_frame_shadow(Gfx::FrameShadow::Raised); m_status->set_frame_thickness(4); diff --git a/Applications/SoundPlayer/SoundPlayerWidget.h b/Applications/SoundPlayer/SoundPlayerWidget.h index ef50e1fc20..44fb0dd8b4 100644 --- a/Applications/SoundPlayer/SoundPlayerWidget.h +++ b/Applications/SoundPlayer/SoundPlayerWidget.h @@ -62,8 +62,8 @@ private: } protected: - Slider(Orientation orientation, GUI::Widget* parent) - : GUI::Slider(orientation, parent) + Slider(Orientation orientation) + : GUI::Slider(orientation) { } diff --git a/Applications/SystemMonitor/GraphWidget.cpp b/Applications/SystemMonitor/GraphWidget.cpp index 70d6175b7e..0a82a17b66 100644 --- a/Applications/SystemMonitor/GraphWidget.cpp +++ b/Applications/SystemMonitor/GraphWidget.cpp @@ -28,8 +28,7 @@ #include <LibGUI/Painter.h> #include <LibGfx/Font.h> -GraphWidget::GraphWidget(GUI::Widget* parent) - : GUI::Frame(parent) +GraphWidget::GraphWidget() { set_frame_thickness(2); set_frame_shape(Gfx::FrameShape::Container); diff --git a/Applications/SystemMonitor/GraphWidget.h b/Applications/SystemMonitor/GraphWidget.h index 731d1b0c88..ab98ecf52e 100644 --- a/Applications/SystemMonitor/GraphWidget.h +++ b/Applications/SystemMonitor/GraphWidget.h @@ -41,7 +41,7 @@ public: Function<String(int value, int max)> text_formatter; private: - explicit GraphWidget(GUI::Widget* parent); + explicit GraphWidget(); virtual void paint_event(GUI::PaintEvent&) override; diff --git a/Applications/SystemMonitor/MemoryStatsWidget.cpp b/Applications/SystemMonitor/MemoryStatsWidget.cpp index fae50431bb..83d3b56814 100644 --- a/Applications/SystemMonitor/MemoryStatsWidget.cpp +++ b/Applications/SystemMonitor/MemoryStatsWidget.cpp @@ -43,9 +43,8 @@ MemoryStatsWidget* MemoryStatsWidget::the() return s_the; } -MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GUI::Widget* parent) - : GUI::Widget(parent) - , m_graph(graph) +MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph) + : m_graph(graph) { ASSERT(!s_the); s_the = this; @@ -58,14 +57,14 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GUI::Widget* parent) layout()->set_spacing(3); auto build_widgets_for_label = [this](const String& description) -> RefPtr<GUI::Label> { - auto container = GUI::Widget::construct(this); + auto container = add<GUI::Widget>(); container->set_layout(make<GUI::HorizontalBoxLayout>()); container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); container->set_preferred_size(275, 12); - auto description_label = GUI::Label::construct(description, container); + auto description_label = container->add<GUI::Label>(description); description_label->set_font(Gfx::Font::default_bold_font()); description_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); - auto label = GUI::Label::construct(container); + auto label = container->add<GUI::Label>(); label->set_text_alignment(Gfx::TextAlignment::CenterRight); return label; }; diff --git a/Applications/SystemMonitor/MemoryStatsWidget.h b/Applications/SystemMonitor/MemoryStatsWidget.h index 5ad2c984c1..f2d8c2c36a 100644 --- a/Applications/SystemMonitor/MemoryStatsWidget.h +++ b/Applications/SystemMonitor/MemoryStatsWidget.h @@ -40,7 +40,7 @@ public: void refresh(); private: - MemoryStatsWidget(GraphWidget& graph, GUI::Widget* parent); + MemoryStatsWidget(GraphWidget& graph); GraphWidget& m_graph; RefPtr<GUI::Label> m_user_physical_pages_label; diff --git a/Applications/SystemMonitor/NetworkStatisticsWidget.cpp b/Applications/SystemMonitor/NetworkStatisticsWidget.cpp index 6f51834554..591d10a5b5 100644 --- a/Applications/SystemMonitor/NetworkStatisticsWidget.cpp +++ b/Applications/SystemMonitor/NetworkStatisticsWidget.cpp @@ -38,13 +38,13 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GUI::Widget* parent) layout()->set_margins({ 4, 4, 4, 4 }); set_fill_with_background_color(true); - auto adapters_group_box = GUI::GroupBox::construct("Adapters", this); + auto adapters_group_box = add<GUI::GroupBox>("Adapters"); adapters_group_box->set_layout(make<GUI::VerticalBoxLayout>()); adapters_group_box->layout()->set_margins({ 6, 16, 6, 6 }); adapters_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); adapters_group_box->set_preferred_size(0, 120); - m_adapter_table_view = GUI::TableView::construct(adapters_group_box); + m_adapter_table_view = adapters_group_box->add<GUI::TableView>(); m_adapter_table_view->set_size_columns_to_fit_content(true); Vector<GUI::JsonArrayModel::FieldSpec> net_adapters_fields; @@ -58,13 +58,13 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GUI::Widget* parent) net_adapters_fields.empend("bytes_out", "Bytes Out", Gfx::TextAlignment::CenterRight); m_adapter_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields))); - auto sockets_group_box = GUI::GroupBox::construct("Sockets", this); + auto sockets_group_box = add<GUI::GroupBox>("Sockets"); sockets_group_box->set_layout(make<GUI::VerticalBoxLayout>()); sockets_group_box->layout()->set_margins({ 6, 16, 6, 6 }); sockets_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); sockets_group_box->set_preferred_size(0, 0); - m_socket_table_view = GUI::TableView::construct(sockets_group_box); + m_socket_table_view = sockets_group_box->add<GUI::TableView>(); m_socket_table_view->set_size_columns_to_fit_content(true); Vector<GUI::JsonArrayModel::FieldSpec> net_tcp_fields; @@ -81,11 +81,10 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GUI::Widget* parent) net_tcp_fields.empend("bytes_out", "Bytes Out", Gfx::TextAlignment::CenterRight); m_socket_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/tcp", move(net_tcp_fields))); - m_update_timer = Core::Timer::construct( + m_update_timer = add<Core::Timer>( 1000, [this] { update_models(); - }, - this); + }); update_models(); }; diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp index b8f507e079..9f5e5c3346 100644 --- a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp +++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp @@ -36,7 +36,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget(GUI::Widget* parent) { set_layout(make<GUI::VerticalBoxLayout>()); layout()->set_margins({ 4, 4, 4, 4 }); - m_table_view = GUI::TableView::construct(this); + m_table_view = add<GUI::TableView>(); m_table_view->set_size_columns_to_fit_content(true); Vector<GUI::JsonArrayModel::FieldSpec> pid_vm_fields; pid_vm_fields.empend("Address", Gfx::TextAlignment::CenterLeft, [](auto& object) { @@ -73,7 +73,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget(GUI::Widget* parent) m_json_model = GUI::JsonArrayModel::create({}, move(pid_vm_fields)); m_table_view->set_model(GUI::SortingProxyModel::create(*m_json_model)); m_table_view->model()->set_key_column_and_sort_order(0, GUI::SortOrder::Ascending); - m_timer = Core::Timer::construct(1000, [this] { refresh(); }, this); + m_timer = add<Core::Timer>(1000, [this] { refresh(); }); } ProcessMemoryMapWidget::~ProcessMemoryMapWidget() diff --git a/Applications/SystemMonitor/ProcessStacksWidget.cpp b/Applications/SystemMonitor/ProcessStacksWidget.cpp index cfa3fe5aa9..fdbcae184c 100644 --- a/Applications/SystemMonitor/ProcessStacksWidget.cpp +++ b/Applications/SystemMonitor/ProcessStacksWidget.cpp @@ -35,10 +35,10 @@ ProcessStacksWidget::ProcessStacksWidget(GUI::Widget* parent) { set_layout(make<GUI::VerticalBoxLayout>()); layout()->set_margins({ 4, 4, 4, 4 }); - m_stacks_editor = GUI::TextEditor::construct(GUI::TextEditor::Type::MultiLine, this); + m_stacks_editor = add<GUI::TextEditor>(); m_stacks_editor->set_readonly(true); - m_timer = Core::Timer::construct(1000, [this] { refresh(); }, this); + m_timer = add<Core::Timer>(1000, [this] { refresh(); }); } ProcessStacksWidget::~ProcessStacksWidget() diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 7101cb4418..3b85ef0e10 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -121,12 +121,12 @@ int main(int argc, char** argv) keeper->set_fill_with_background_color(true); keeper->layout()->set_margins({ 4, 4, 4, 4 }); - auto tabwidget = GUI::TabWidget::construct(keeper); + auto tabwidget = keeper->add<GUI::TabWidget>(); auto process_container_splitter = GUI::VerticalSplitter::construct(nullptr); tabwidget->add_widget("Processes", process_container_splitter); - auto process_table_container = GUI::Widget::construct(process_container_splitter.ptr()); + auto process_table_container = process_container_splitter->add<GUI::Widget>(); tabwidget->add_widget("Graphs", build_graphs_tab()); @@ -143,17 +143,16 @@ int main(int argc, char** argv) process_table_container->layout()->set_margins({ 4, 0, 4, 0 }); process_table_container->layout()->set_spacing(0); - auto toolbar = GUI::ToolBar::construct(process_table_container); + auto toolbar = process_table_container->add<GUI::ToolBar>(); toolbar->set_has_frame(false); - auto process_table_view = ProcessTableView::construct(process_table_container); + auto process_table_view = process_table_container->add<ProcessTableView>(); - auto refresh_timer = Core::Timer::construct( + auto refresh_timer = window->add<Core::Timer>( 1000, [&] { process_table_view->refresh(); if (auto* memory_stats_widget = MemoryStatsWidget::the()) memory_stats_widget->refresh(); - }, - window); + }); auto kill_action = GUI::Action::create("Kill process", { Mod_Ctrl, Key_K }, Gfx::Bitmap::load_from_file("/res/icons/kill16.png"), [process_table_view](const GUI::Action&) { pid_t pid = process_table_view->selected_pid(); @@ -231,7 +230,7 @@ int main(int argc, char** argv) app.set_menubar(move(menubar)); - auto process_tab_widget = GUI::TabWidget::construct(process_container_splitter); + auto process_tab_widget = process_container_splitter->add<GUI::TabWidget>(); auto memory_map_widget = ProcessMemoryMapWidget::construct(nullptr); process_tab_widget->add_widget("Memory map", memory_map_widget); @@ -281,10 +280,10 @@ RefPtr<GUI::Widget> build_file_systems_tab() { auto fs_widget = GUI::LazyWidget::construct(); - fs_widget->on_first_show = [](auto& self) { + fs_widget->on_first_show = [](GUI::LazyWidget& self) { self.set_layout(make<GUI::VerticalBoxLayout>()); self.layout()->set_margins({ 4, 4, 4, 4 }); - auto fs_table_view = GUI::TableView::construct(&self); + auto fs_table_view = self.add<GUI::TableView>(); fs_table_view->set_size_columns_to_fit_content(true); Vector<GUI::JsonArrayModel::FieldSpec> df_fields; @@ -374,10 +373,10 @@ RefPtr<GUI::Widget> build_pci_devices_tab() { auto pci_widget = GUI::LazyWidget::construct(); - pci_widget->on_first_show = [](auto& self) { + pci_widget->on_first_show = [](GUI::LazyWidget& self) { self.set_layout(make<GUI::VerticalBoxLayout>()); self.layout()->set_margins({ 4, 4, 4, 4 }); - auto pci_table_view = GUI::TableView::construct(&self); + auto pci_table_view = self.add<GUI::TableView>(); pci_table_view->set_size_columns_to_fit_content(true); auto db = PCIDB::Database::open(); @@ -432,11 +431,11 @@ RefPtr<GUI::Widget> build_devices_tab() { auto devices_widget = GUI::LazyWidget::construct(); - devices_widget->on_first_show = [](auto& self) { + devices_widget->on_first_show = [](GUI::LazyWidget& self) { self.set_layout(make<GUI::VerticalBoxLayout>()); self.layout()->set_margins({ 4, 4, 4, 4 }); - auto devices_table_view = GUI::TableView::construct(&self); + auto devices_table_view = self.add<GUI::TableView>(); devices_table_view->set_size_columns_to_fit_content(true); devices_table_view->set_model(GUI::SortingProxyModel::create(DevicesModel::create())); devices_table_view->model()->update(); @@ -449,18 +448,18 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab() { auto graphs_container = GUI::LazyWidget::construct(); - graphs_container->on_first_show = [](auto& self) { + graphs_container->on_first_show = [](GUI::LazyWidget& self) { self.set_fill_with_background_color(true); self.set_background_role(ColorRole::Button); self.set_layout(make<GUI::VerticalBoxLayout>()); self.layout()->set_margins({ 4, 4, 4, 4 }); - auto cpu_graph_group_box = GUI::GroupBox::construct("CPU usage", &self); + auto cpu_graph_group_box = self.add<GUI::GroupBox>("CPU usage"); cpu_graph_group_box->set_layout(make<GUI::VerticalBoxLayout>()); cpu_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 }); cpu_graph_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); cpu_graph_group_box->set_preferred_size(0, 120); - auto cpu_graph = GraphWidget::construct(cpu_graph_group_box); + auto cpu_graph = cpu_graph_group_box->add<GraphWidget>(); cpu_graph->set_max(100); cpu_graph->set_text_color(Color::Green); cpu_graph->set_graph_color(Color::from_rgb(0x00bb00)); @@ -472,19 +471,19 @@ NonnullRefPtr<GUI::Widget> build_graphs_tab() graph->add_value(cpu_percent); }; - auto memory_graph_group_box = GUI::GroupBox::construct("Memory usage", &self); + auto memory_graph_group_box = self.add<GUI::GroupBox>("Memory usage"); memory_graph_group_box->set_layout(make<GUI::VerticalBoxLayout>()); memory_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 }); memory_graph_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); memory_graph_group_box->set_preferred_size(0, 120); - auto memory_graph = GraphWidget::construct(memory_graph_group_box); + auto memory_graph = memory_graph_group_box->add<GraphWidget>(); memory_graph->set_text_color(Color::Cyan); memory_graph->set_graph_color(Color::from_rgb(0x00bbbb)); memory_graph->text_formatter = [](int value, int max) { return String::format("%d / %d KB", value, max); }; - auto memory_stats_widget = MemoryStatsWidget::construct(*memory_graph, &self); + auto memory_stats_widget = self.add<MemoryStatsWidget>(*memory_graph); }; return graphs_container; } diff --git a/Applications/Taskbar/TaskbarButton.cpp b/Applications/Taskbar/TaskbarButton.cpp index e5d7c1fbbd..68e0441211 100644 --- a/Applications/Taskbar/TaskbarButton.cpp +++ b/Applications/Taskbar/TaskbarButton.cpp @@ -28,9 +28,8 @@ #include <LibGUI/Action.h> #include <LibGUI/WindowServerConnection.h> -TaskbarButton::TaskbarButton(const WindowIdentifier& identifier, GUI::Widget* parent) - : GUI::Button(parent) - , m_identifier(identifier) +TaskbarButton::TaskbarButton(const WindowIdentifier& identifier) + : m_identifier(identifier) { } diff --git a/Applications/Taskbar/TaskbarButton.h b/Applications/Taskbar/TaskbarButton.h index 9f2dc2f13d..d8852cfcc1 100644 --- a/Applications/Taskbar/TaskbarButton.h +++ b/Applications/Taskbar/TaskbarButton.h @@ -32,10 +32,11 @@ class TaskbarButton final : public GUI::Button { C_OBJECT(TaskbarButton) public: - TaskbarButton(const WindowIdentifier&, GUI::Widget* parent); virtual ~TaskbarButton() override; private: + explicit TaskbarButton(const WindowIdentifier&); + virtual void context_menu_event(GUI::ContextMenuEvent&) override; virtual void resize_event(GUI::ResizeEvent&) override; diff --git a/Applications/Taskbar/TaskbarWindow.cpp b/Applications/Taskbar/TaskbarWindow.cpp index 3bfd500e88..56266a2a51 100644 --- a/Applications/Taskbar/TaskbarWindow.cpp +++ b/Applications/Taskbar/TaskbarWindow.cpp @@ -69,7 +69,7 @@ TaskbarWindow::~TaskbarWindow() void TaskbarWindow::create_quick_launch_bar() { - auto quick_launch_bar = GUI::Frame::construct(main_widget()); + auto quick_launch_bar = main_widget()->add<GUI::Frame>(); quick_launch_bar->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); quick_launch_bar->set_layout(make<GUI::HorizontalBoxLayout>()); quick_launch_bar->layout()->set_spacing(3); @@ -93,7 +93,7 @@ void TaskbarWindow::create_quick_launch_bar() auto app_executable = af->read_entry("App", "Executable"); auto app_icon_path = af->read_entry("Icons", "16x16"); - auto button = GUI::Button::construct(quick_launch_bar); + auto button = quick_launch_bar->add<GUI::Button>(); button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); button->set_preferred_size(22, 22); button->set_button_style(Gfx::ButtonStyle::CoolBar); @@ -129,7 +129,7 @@ void TaskbarWindow::on_screen_rect_change(const Gfx::Rect& rect) NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier& identifier) { - auto button = TaskbarButton::construct(identifier, main_widget()); + auto button = main_widget()->add<TaskbarButton>(identifier); button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); button->set_preferred_size(140, 22); button->set_checkable(true); diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp index 8241e8070c..b20830c994 100644 --- a/Applications/Terminal/main.cpp +++ b/Applications/Terminal/main.cpp @@ -140,26 +140,26 @@ RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal) settings->set_layout(make<GUI::VerticalBoxLayout>()); settings->layout()->set_margins({ 4, 4, 4, 4 }); - auto radio_container = GUI::GroupBox::construct("Bell Mode", settings); + auto radio_container = settings->add<GUI::GroupBox>("Bell Mode"); radio_container->set_layout(make<GUI::VerticalBoxLayout>()); radio_container->layout()->set_margins({ 6, 16, 6, 6 }); radio_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); radio_container->set_preferred_size(100, 70); - auto sysbell_radio = GUI::RadioButton::construct("Use (Audible) System Bell", radio_container); - auto visbell_radio = GUI::RadioButton::construct("Use (Visual) Terminal Bell", radio_container); + auto sysbell_radio = radio_container->add<GUI::RadioButton>("Use (Audible) System Bell"); + auto visbell_radio = radio_container->add<GUI::RadioButton>("Use (Visual) Terminal Bell"); sysbell_radio->set_checked(terminal.should_beep()); visbell_radio->set_checked(!terminal.should_beep()); sysbell_radio->on_checked = [&terminal](const bool checked) { terminal.set_should_beep(checked); }; - auto slider_container = GUI::GroupBox::construct("Background Opacity", settings); + auto slider_container = settings->add<GUI::GroupBox>("Background Opacity"); slider_container->set_layout(make<GUI::VerticalBoxLayout>()); slider_container->layout()->set_margins({ 6, 16, 6, 6 }); slider_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); slider_container->set_preferred_size(100, 50); - auto slider = GUI::HorizontalSlider::construct(slider_container); + auto slider = slider_container->add<GUI::HorizontalSlider>(); slider->on_value_changed = [&terminal](int value) { terminal.set_opacity(value); diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index 4115152208..cbaa45af93 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -51,8 +51,8 @@ TextEditorWidget::TextEditorWidget() set_layout(make<GUI::VerticalBoxLayout>()); layout()->set_spacing(0); - auto toolbar = GUI::ToolBar::construct(this); - m_editor = GUI::TextEditor::construct(GUI::TextEditor::MultiLine, this); + auto toolbar = add<GUI::ToolBar>(); + m_editor = add<GUI::TextEditor>(); m_editor->set_ruler_visible(true); m_editor->set_automatic_indentation_enabled(true); m_editor->set_line_wrapping_enabled(true); @@ -70,7 +70,7 @@ TextEditorWidget::TextEditorWidget() update_title(); }; - m_find_replace_widget = GUI::Widget::construct(this); + m_find_replace_widget = add<GUI::Widget>(); m_find_replace_widget->set_fill_with_background_color(true); m_find_replace_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_find_replace_widget->set_preferred_size(0, 48); @@ -78,22 +78,22 @@ TextEditorWidget::TextEditorWidget() m_find_replace_widget->layout()->set_margins({ 2, 2, 2, 4 }); m_find_replace_widget->set_visible(false); - m_find_widget = GUI::Widget::construct(m_find_replace_widget); + m_find_widget = m_find_replace_widget->add<GUI::Widget>(); m_find_widget->set_fill_with_background_color(true); m_find_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_find_widget->set_preferred_size(0, 22); m_find_widget->set_layout(make<GUI::HorizontalBoxLayout>()); m_find_widget->set_visible(false); - m_replace_widget = GUI::Widget::construct(m_find_replace_widget); + m_replace_widget = m_find_replace_widget->add<GUI::Widget>(); m_replace_widget->set_fill_with_background_color(true); m_replace_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_replace_widget->set_preferred_size(0, 22); m_replace_widget->set_layout(make<GUI::HorizontalBoxLayout>()); m_replace_widget->set_visible(false); - m_find_textbox = GUI::TextBox::construct(m_find_widget); - m_replace_textbox = GUI::TextBox::construct(m_replace_widget); + m_find_textbox = m_find_widget->add<GUI::TextBox>(); + m_replace_textbox = m_replace_widget->add<GUI::TextBox>(); m_find_next_action = GUI::Action::create("Find next", { Mod_Ctrl, Key_G }, [&](auto&) { auto needle = m_find_textbox->text(); @@ -202,12 +202,12 @@ TextEditorWidget::TextEditorWidget() } }); - m_find_previous_button = GUI::Button::construct("Find previous", m_find_widget); + m_find_previous_button = m_find_widget->add<GUI::Button>("Find previous"); m_find_previous_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_find_previous_button->set_preferred_size(150, 0); m_find_previous_button->set_action(*m_find_previous_action); - m_find_next_button = GUI::Button::construct("Find next", m_find_widget); + m_find_next_button = m_find_widget->add<GUI::Button>("Find next"); m_find_next_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_find_next_button->set_preferred_size(150, 0); m_find_next_button->set_action(*m_find_next_action); @@ -221,17 +221,17 @@ TextEditorWidget::TextEditorWidget() m_editor->set_focus(true); }; - m_replace_previous_button = GUI::Button::construct("Replace previous", m_replace_widget); + m_replace_previous_button = m_replace_widget->add<GUI::Button>("Replace previous"); m_replace_previous_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_replace_previous_button->set_preferred_size(100, 0); m_replace_previous_button->set_action(*m_replace_previous_action); - m_replace_next_button = GUI::Button::construct("Replace next", m_replace_widget); + m_replace_next_button = m_replace_widget->add<GUI::Button>("Replace next"); m_replace_next_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_replace_next_button->set_preferred_size(100, 0); m_replace_next_button->set_action(*m_replace_next_action); - m_replace_all_button = GUI::Button::construct("Replace all", m_replace_widget); + m_replace_all_button = m_replace_widget->add<GUI::Button>("Replace all"); m_replace_all_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_replace_all_button->set_preferred_size(100, 0); m_replace_all_button->set_action(*m_replace_all_action); @@ -262,7 +262,7 @@ TextEditorWidget::TextEditorWidget() m_editor->add_custom_context_menu_action(*m_find_next_action); m_editor->add_custom_context_menu_action(*m_find_previous_action); - m_statusbar = GUI::StatusBar::construct(this); + m_statusbar = add<GUI::StatusBar>(); m_editor->on_cursor_change = [this] { StringBuilder builder; @@ -272,7 +272,7 @@ TextEditorWidget::TextEditorWidget() m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) { if (m_document_dirty) { - auto save_document_first_result = GUI::MessageBox::construct("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel, window())->exec(); + auto save_document_first_result = GUI::MessageBox::show("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes) m_save_action->activate(); if (save_document_first_result == GUI::Dialog::ExecResult::ExecCancel) @@ -292,7 +292,7 @@ TextEditorWidget::TextEditorWidget() return; if (m_document_dirty) { - auto save_document_first_result = GUI::MessageBox::construct("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel, window())->exec(); + auto save_document_first_result = GUI::MessageBox::show("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel, window()); if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes) m_save_action->activate(); if (save_document_first_result == GUI::Dialog::ExecResult::ExecCancel) diff --git a/Applications/Welcome/main.cpp b/Applications/Welcome/main.cpp index 1954e27179..ea25ab057d 100644 --- a/Applications/Welcome/main.cpp +++ b/Applications/Welcome/main.cpp @@ -173,7 +173,7 @@ int main(int argc, char** argv) // header // - auto header = GUI::Label::construct(background.ptr()); + auto header = background->add<GUI::Label>(); header->set_font(Gfx::Font::load_from_file("/res/fonts/PebbletonBold11.font")); header->set_text("Welcome to SerenityOS!"); header->set_text_alignment(Gfx::TextAlignment::CenterLeft); @@ -184,44 +184,44 @@ int main(int argc, char** argv) // main section // - auto main_section = GUI::Widget::construct(background.ptr()); + auto main_section = background->add<GUI::Widget>(); main_section->set_layout(make<GUI::HorizontalBoxLayout>()); main_section->layout()->set_margins({ 0, 0, 0, 0 }); main_section->layout()->set_spacing(8); main_section->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); - auto menu = GUI::Widget::construct(main_section.ptr()); + auto menu = main_section->add<GUI::Widget>(); menu->set_layout(make<GUI::VerticalBoxLayout>()); menu->layout()->set_margins({ 0, 0, 0, 0 }); menu->layout()->set_spacing(4); menu->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); menu->set_preferred_size(100, 0); - auto stack = GUI::StackWidget::construct(main_section); + auto stack = main_section->add<GUI::StackWidget>(); stack->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); bool first = true; for (auto& page : pages) { - auto content = GUI::Widget::construct(stack.ptr()); + auto content = stack->add<GUI::Widget>(); content->set_layout(make<GUI::VerticalBoxLayout>()); content->layout()->set_margins({ 0, 0, 0, 0 }); content->layout()->set_spacing(8); content->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); - auto title_box = GUI::Widget::construct(content.ptr()); + auto title_box = content->add<GUI::Widget>(); title_box->set_layout(make<GUI::HorizontalBoxLayout>()); title_box->layout()->set_spacing(4); title_box->set_preferred_size(0, 16); title_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); if (!page.icon.is_empty()) { - auto icon = GUI::Label::construct(title_box); + auto icon = title_box->add<GUI::Label>(); icon->set_icon(Gfx::Bitmap::load_from_file(page.icon)); icon->set_preferred_size(16, 16); icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); } - auto content_title = GUI::Label::construct(title_box); + auto content_title = title_box->add<GUI::Label>(); content_title->set_font(Gfx::Font::default_bold_font()); content_title->set_text(page.title); content_title->set_text_alignment(Gfx::TextAlignment::CenterLeft); @@ -229,7 +229,7 @@ int main(int argc, char** argv) content_title->set_preferred_size(0, 10); for (auto& paragraph : page.content) { - auto content_text = TextWidget::construct(content); + auto content_text = content->add<TextWidget>(); content_text->set_font(Gfx::Font::default_font()); content_text->set_text(paragraph); content_text->set_text_alignment(Gfx::TextAlignment::TopLeft); @@ -237,7 +237,7 @@ int main(int argc, char** argv) content_text->wrap_and_set_height(); } - auto menu_option = UnuncheckableButton::construct(menu); + auto menu_option = menu->add<UnuncheckableButton>(); menu_option->set_font(Gfx::Font::default_font()); menu_option->set_text(page.menu_name); menu_option->set_text_alignment(Gfx::TextAlignment::CenterLeft); diff --git a/Demos/Fire/Fire.cpp b/Demos/Fire/Fire.cpp index 42f15bd368..67872f0505 100644 --- a/Demos/Fire/Fire.cpp +++ b/Demos/Fire/Fire.cpp @@ -96,7 +96,7 @@ public: void set_stat_label(RefPtr<GUI::Label> l) { stats = l; }; private: - explicit Fire(GUI::Widget* parent = nullptr); + Fire(); RefPtr<Gfx::Bitmap> bitmap; RefPtr<GUI::Label> stats; @@ -112,8 +112,7 @@ private: int phase; }; -Fire::Fire(GUI::Widget* parent) - : GUI::Widget(parent) +Fire::Fire() { bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::Indexed8, { 320, 200 }); @@ -250,7 +249,7 @@ int main(int argc, char** argv) auto fire = Fire::construct(); window->set_main_widget(fire); - auto time = GUI::Label::construct(fire); + auto time = fire->add<GUI::Label>(); time->set_relative_rect({ 0, 4, 40, 10 }); time->move_by({ window->width() - time->width(), 0 }); time->set_foreground_color(Color::from_rgb(0x444444)); diff --git a/Demos/HelloWorld/main.cpp b/Demos/HelloWorld/main.cpp index f576d03f3c..1abcd55738 100644 --- a/Demos/HelloWorld/main.cpp +++ b/Demos/HelloWorld/main.cpp @@ -46,10 +46,10 @@ int main(int argc, char** argv) main_widget->set_layout(make<GUI::VerticalBoxLayout>()); main_widget->layout()->set_margins({ 4, 4, 4, 4 }); - auto label = GUI::Label::construct(main_widget); + auto label = main_widget->add<GUI::Label>(); label->set_text("Hello\nWorld!"); - auto button = GUI::Button::construct(main_widget); + auto button = main_widget->add<GUI::Button>(); button->set_text("Good-bye"); button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); button->set_preferred_size(0, 20); diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp index eb16bc3369..047601e17e 100644 --- a/Demos/WidgetGallery/main.cpp +++ b/Demos/WidgetGallery/main.cpp @@ -54,71 +54,71 @@ int main(int argc, char** argv) main_widget->set_layout(make<GUI::VerticalBoxLayout>()); main_widget->layout()->set_margins({ 4, 4, 4, 4 }); - auto checkbox1 = GUI::CheckBox::construct("GCheckBox 1", main_widget); + auto checkbox1 = main_widget->add<GUI::CheckBox>("GCheckBox 1"); (void)checkbox1; - auto checkbox2 = GUI::CheckBox::construct("GCheckBox 2", main_widget); + auto checkbox2 = main_widget->add<GUI::CheckBox>("GCheckBox 2"); checkbox2->set_enabled(false); - auto radio1 = GUI::RadioButton::construct("GRadioButton 1", main_widget); + auto radio1 = main_widget->add<GUI::RadioButton>("GRadioButton 1"); (void)radio1; - auto radio2 = GUI::RadioButton::construct("GRadioButton 2", main_widget); + auto radio2 = main_widget->add<GUI::RadioButton>("GRadioButton 2"); radio2->set_enabled(false); - auto button1 = GUI::Button::construct("GButton 1", main_widget); + auto button1 = main_widget->add<GUI::Button>("GButton 1"); (void)button1; - auto button2 = GUI::Button::construct("GButton 2", main_widget); + auto button2 = main_widget->add<GUI::Button>("GButton 2"); button2->set_enabled(false); - auto progress1 = GUI::ProgressBar::construct(main_widget); - auto timer = Core::Timer::construct(100, [&] { + 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 = GUI::Label::construct("GLabel 1", main_widget); + auto label1 = main_widget->add<GUI::Label>("GLabel 1"); (void)label1; - auto label2 = GUI::Label::construct("GLabel 2", main_widget); + auto label2 = main_widget->add<GUI::Label>("GLabel 2"); label2->set_enabled(false); - auto textbox1 = GUI::TextBox::construct(main_widget); + auto textbox1 = main_widget->add<GUI::TextBox>(); textbox1->set_text("GTextBox 1"); - auto textbox2 = GUI::TextBox::construct(main_widget); + auto textbox2 = main_widget->add<GUI::TextBox>(); textbox2->set_text("GTextBox 2"); textbox2->set_enabled(false); - auto spinbox1 = GUI::SpinBox::construct(main_widget); + auto spinbox1 = main_widget->add<GUI::SpinBox>(); (void)spinbox1; - auto spinbox2 = GUI::SpinBox::construct(main_widget); + auto spinbox2 = main_widget->add<GUI::SpinBox>(); spinbox2->set_enabled(false); - auto vertical_slider_container = GUI::Widget::construct(main_widget.ptr()); + 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(make<GUI::HorizontalBoxLayout>()); - auto vslider1 = GUI::VerticalSlider::construct(vertical_slider_container); + auto vslider1 = vertical_slider_container->add<GUI::VerticalSlider>(); (void)vslider1; - auto vslider2 = GUI::VerticalSlider::construct(vertical_slider_container); + auto vslider2 = vertical_slider_container->add<GUI::VerticalSlider>(); vslider2->set_enabled(false); - auto vslider3 = GUI::VerticalSlider::construct(vertical_slider_container); + auto vslider3 = vertical_slider_container->add<GUI::VerticalSlider>(); vslider3->set_max(5); vslider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); - auto slider1 = GUI::HorizontalSlider::construct(main_widget); + auto slider1 = main_widget->add<GUI::HorizontalSlider>(); (void)slider1; - auto slider2 = GUI::HorizontalSlider::construct(main_widget); + auto slider2 = main_widget->add<GUI::HorizontalSlider>(); slider2->set_enabled(false); - auto slider3 = GUI::HorizontalSlider::construct(main_widget); + auto slider3 = main_widget->add<GUI::HorizontalSlider>(); slider3->set_max(5); slider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); - auto scrollbar1 = GUI::ScrollBar::construct(Orientation::Horizontal, main_widget); + 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 = GUI::ScrollBar::construct(Orientation::Horizontal, main_widget); + 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); diff --git a/DevTools/HackStudio/Editor.cpp b/DevTools/HackStudio/Editor.cpp index 8cdbe83f15..d8f6a900dc 100644 --- a/DevTools/HackStudio/Editor.cpp +++ b/DevTools/HackStudio/Editor.cpp @@ -43,14 +43,13 @@ //#define EDITOR_DEBUG -Editor::Editor(GUI::Widget* parent) - : TextEditor(GUI::TextEditor::MultiLine, parent) +Editor::Editor() { m_documentation_tooltip_window = GUI::Window::construct(); m_documentation_tooltip_window->set_rect(0, 0, 500, 400); m_documentation_tooltip_window->set_window_type(GUI::WindowType::Tooltip); - m_documentation_html_view = HtmlView::construct(nullptr); + m_documentation_html_view = HtmlView::construct(); m_documentation_tooltip_window->set_main_widget(m_documentation_html_view); } diff --git a/DevTools/HackStudio/Editor.h b/DevTools/HackStudio/Editor.h index 5bb087ed6f..cd1fa0693e 100644 --- a/DevTools/HackStudio/Editor.h +++ b/DevTools/HackStudio/Editor.h @@ -49,7 +49,7 @@ private: void show_documentation_tooltip_if_available(const String&, const Gfx::Point& screen_location); - explicit Editor(GUI::Widget* parent); + explicit Editor(); RefPtr<GUI::Window> m_documentation_tooltip_window; RefPtr<HtmlView> m_documentation_html_view; diff --git a/DevTools/HackStudio/EditorWrapper.cpp b/DevTools/HackStudio/EditorWrapper.cpp index 9cc1a63d81..2cedd1e32d 100644 --- a/DevTools/HackStudio/EditorWrapper.cpp +++ b/DevTools/HackStudio/EditorWrapper.cpp @@ -34,29 +34,28 @@ extern RefPtr<EditorWrapper> g_current_editor_wrapper; -EditorWrapper::EditorWrapper(GUI::Widget* parent) - : GUI::Widget(parent) +EditorWrapper::EditorWrapper() { set_layout(make<GUI::VerticalBoxLayout>()); - auto label_wrapper = GUI::Widget::construct(this); + auto label_wrapper = add<GUI::Widget>(); label_wrapper->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); label_wrapper->set_preferred_size(0, 14); label_wrapper->set_fill_with_background_color(true); label_wrapper->set_layout(make<GUI::HorizontalBoxLayout>()); label_wrapper->layout()->set_margins({ 2, 0, 2, 0 }); - m_filename_label = GUI::Label::construct("(Untitled)", label_wrapper); + m_filename_label = label_wrapper->add<GUI::Label>("(Untitled)"); m_filename_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); m_filename_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_filename_label->set_preferred_size(0, 14); - m_cursor_label = GUI::Label::construct("(Cursor)", label_wrapper); + m_cursor_label = label_wrapper->add<GUI::Label>("(Cursor)"); m_cursor_label->set_text_alignment(Gfx::TextAlignment::CenterRight); m_cursor_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_cursor_label->set_preferred_size(0, 14); - m_editor = Editor::construct(this); + m_editor = add<Editor>(); m_editor->set_ruler_visible(true); m_editor->set_line_wrapping_enabled(true); m_editor->set_automatic_indentation_enabled(true); diff --git a/DevTools/HackStudio/EditorWrapper.h b/DevTools/HackStudio/EditorWrapper.h index c7ea938f30..0aaccf4cec 100644 --- a/DevTools/HackStudio/EditorWrapper.h +++ b/DevTools/HackStudio/EditorWrapper.h @@ -43,7 +43,7 @@ public: void set_editor_has_focus(Badge<Editor>, bool); private: - explicit EditorWrapper(GUI::Widget* parent = nullptr); + explicit EditorWrapper(); RefPtr<GUI::Label> m_filename_label; RefPtr<GUI::Label> m_cursor_label; diff --git a/DevTools/HackStudio/FindInFilesWidget.cpp b/DevTools/HackStudio/FindInFilesWidget.cpp index 9ba9454796..ad6a0209dc 100644 --- a/DevTools/HackStudio/FindInFilesWidget.cpp +++ b/DevTools/HackStudio/FindInFilesWidget.cpp @@ -127,18 +127,17 @@ static RefPtr<SearchResultsModel> find_in_files(const StringView& text) return adopt(*new SearchResultsModel(move(matches))); } -FindInFilesWidget::FindInFilesWidget(GUI::Widget* parent) - : GUI::Widget(parent) +FindInFilesWidget::FindInFilesWidget() { set_layout(make<GUI::VerticalBoxLayout>()); - m_textbox = GUI::TextBox::construct(this); + m_textbox = add<GUI::TextBox>(); m_textbox->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_textbox->set_preferred_size(0, 20); - m_button = GUI::Button::construct("Find in files", this); + m_button = add<GUI::Button>("Find in files"); m_button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_button->set_preferred_size(0, 20); - m_result_view = GUI::TableView::construct(this); + m_result_view = add<GUI::TableView>(); m_result_view->set_size_columns_to_fit_content(true); m_result_view->on_activation = [](auto& index) { diff --git a/DevTools/HackStudio/FindInFilesWidget.h b/DevTools/HackStudio/FindInFilesWidget.h index bcf0a73c78..3996da169a 100644 --- a/DevTools/HackStudio/FindInFilesWidget.h +++ b/DevTools/HackStudio/FindInFilesWidget.h @@ -36,7 +36,7 @@ public: void focus_textbox_and_select_all(); private: - explicit FindInFilesWidget(GUI::Widget* parent); + explicit FindInFilesWidget(); RefPtr<GUI::TextBox> m_textbox; RefPtr<GUI::Button> m_button; diff --git a/DevTools/HackStudio/FormEditorWidget.cpp b/DevTools/HackStudio/FormEditorWidget.cpp index f4faa9147b..24c778e549 100644 --- a/DevTools/HackStudio/FormEditorWidget.cpp +++ b/DevTools/HackStudio/FormEditorWidget.cpp @@ -30,9 +30,8 @@ #include "WidgetTreeModel.h" #include <LibGUI/Painter.h> -FormEditorWidget::FormEditorWidget(GUI::Widget* parent) - : ScrollableWidget(parent) - , m_tool(make<CursorTool>(*this)) +FormEditorWidget::FormEditorWidget() + : m_tool(make<CursorTool>(*this)) { set_fill_with_background_color(true); set_background_color(Color::MidGray); @@ -41,7 +40,7 @@ FormEditorWidget::FormEditorWidget(GUI::Widget* parent) set_frame_shadow(Gfx::FrameShadow::Sunken); set_frame_thickness(2); - m_form_widget = FormWidget::construct(*this); + m_form_widget = add<FormWidget>(); m_widget_tree_model = WidgetTreeModel::create(*m_form_widget); } diff --git a/DevTools/HackStudio/FormEditorWidget.h b/DevTools/HackStudio/FormEditorWidget.h index 69200b66cf..acb4c4bd69 100644 --- a/DevTools/HackStudio/FormEditorWidget.h +++ b/DevTools/HackStudio/FormEditorWidget.h @@ -124,7 +124,7 @@ public: private: virtual void paint_event(GUI::PaintEvent&) override; - explicit FormEditorWidget(GUI::Widget* parent); + FormEditorWidget(); RefPtr<FormWidget> m_form_widget; RefPtr<WidgetTreeModel> m_widget_tree_model; diff --git a/DevTools/HackStudio/FormWidget.cpp b/DevTools/HackStudio/FormWidget.cpp index 993c1153ae..3b60306c6a 100644 --- a/DevTools/HackStudio/FormWidget.cpp +++ b/DevTools/HackStudio/FormWidget.cpp @@ -29,8 +29,7 @@ #include "Tool.h" #include <LibGUI/Painter.h> -FormWidget::FormWidget(FormEditorWidget& parent) - : GUI::Widget(&parent) +FormWidget::FormWidget() { set_fill_with_background_color(true); set_relative_rect(5, 5, 400, 300); diff --git a/DevTools/HackStudio/FormWidget.h b/DevTools/HackStudio/FormWidget.h index c1cee4e34e..94ff45db80 100644 --- a/DevTools/HackStudio/FormWidget.h +++ b/DevTools/HackStudio/FormWidget.h @@ -53,7 +53,7 @@ private: virtual void mousemove_event(GUI::MouseEvent&) override; virtual void keydown_event(GUI::KeyEvent&) override; - explicit FormWidget(FormEditorWidget& parent); + FormWidget(); int m_grid_size { 5 }; }; diff --git a/DevTools/HackStudio/Locator.cpp b/DevTools/HackStudio/Locator.cpp index 609cc57b66..9724d41347 100644 --- a/DevTools/HackStudio/Locator.cpp +++ b/DevTools/HackStudio/Locator.cpp @@ -92,14 +92,10 @@ public: } private: - LocatorTextBox(GUI::Widget* parent) - : GUI::TextBox(parent) - { - } + LocatorTextBox() {} }; -Locator::Locator(GUI::Widget* parent) - : GUI::Widget(parent) +Locator::Locator() { if (!s_cplusplus_icon) { s_file_icon = Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"); @@ -110,7 +106,7 @@ Locator::Locator(GUI::Widget* parent) set_layout(make<GUI::VerticalBoxLayout>()); set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); set_preferred_size(0, 20); - m_textbox = LocatorTextBox::construct(this); + m_textbox = add<LocatorTextBox>(); m_textbox->on_change = [this] { update_suggestions(); }; @@ -154,7 +150,7 @@ Locator::Locator(GUI::Widget* parent) m_popup_window->set_window_type(GUI::WindowType::Tooltip); m_popup_window->set_rect(0, 0, 500, 200); - m_suggestion_view = GUI::TableView::construct(nullptr); + m_suggestion_view = GUI::TableView::construct(); m_suggestion_view->set_size_columns_to_fit_content(true); m_suggestion_view->set_headers_visible(false); m_popup_window->set_main_widget(m_suggestion_view); diff --git a/DevTools/HackStudio/Locator.h b/DevTools/HackStudio/Locator.h index 4b0307babb..28033b0fce 100644 --- a/DevTools/HackStudio/Locator.h +++ b/DevTools/HackStudio/Locator.h @@ -42,7 +42,7 @@ private: void update_suggestions(); void open_suggestion(const GUI::ModelIndex&); - explicit Locator(GUI::Widget* parent); + Locator(); RefPtr<LocatorTextBox> m_textbox; RefPtr<GUI::Window> m_popup_window; diff --git a/DevTools/HackStudio/ProcessStateWidget.cpp b/DevTools/HackStudio/ProcessStateWidget.cpp index e724a66fb2..3fdf3db0da 100644 --- a/DevTools/HackStudio/ProcessStateWidget.cpp +++ b/DevTools/HackStudio/ProcessStateWidget.cpp @@ -32,8 +32,7 @@ #include <LibGfx/Font.h> #include <unistd.h> -ProcessStateWidget::ProcessStateWidget(GUI::Widget* parent) - : GUI::Widget(parent) +ProcessStateWidget::ProcessStateWidget() { set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); set_preferred_size(0, 20); @@ -41,24 +40,24 @@ ProcessStateWidget::ProcessStateWidget(GUI::Widget* parent) set_layout(make<GUI::HorizontalBoxLayout>()); - auto pid_label_label = GUI::Label::construct("Process:", this); + auto pid_label_label = add<GUI::Label>("Process:"); pid_label_label->set_font(Gfx::Font::default_bold_font()); - m_pid_label = GUI::Label::construct("", this); + m_pid_label = add<GUI::Label>(""); - auto state_label_label = GUI::Label::construct("State:", this); + auto state_label_label = add<GUI::Label>("State:"); state_label_label->set_font(Gfx::Font::default_bold_font()); - m_state_label = GUI::Label::construct("", this); + m_state_label = add<GUI::Label>(""); // FIXME: This should show CPU% instead. - auto cpu_label_label = GUI::Label::construct("Times scheduled:", this); + auto cpu_label_label = add<GUI::Label>("Times scheduled:"); cpu_label_label->set_font(Gfx::Font::default_bold_font()); - m_cpu_label = GUI::Label::construct("", this); + m_cpu_label = add<GUI::Label>(""); - auto memory_label_label = GUI::Label::construct("Memory (resident):", this); + auto memory_label_label = add<GUI::Label>("Memory (resident):"); memory_label_label->set_font(Gfx::Font::default_bold_font()); - m_memory_label = GUI::Label::construct("", this); + m_memory_label = add<GUI::Label>(""); - m_timer = Core::Timer::construct(500, [this] { + m_timer = add<Core::Timer>(500, [this] { refresh(); }); } diff --git a/DevTools/HackStudio/ProcessStateWidget.h b/DevTools/HackStudio/ProcessStateWidget.h index 22f10c573a..a4bc4f9d16 100644 --- a/DevTools/HackStudio/ProcessStateWidget.h +++ b/DevTools/HackStudio/ProcessStateWidget.h @@ -36,7 +36,7 @@ public: void set_tty_fd(int); private: - explicit ProcessStateWidget(GUI::Widget* parent); + explicit ProcessStateWidget(); void refresh(); diff --git a/DevTools/HackStudio/TerminalWrapper.cpp b/DevTools/HackStudio/TerminalWrapper.cpp index 28c220e886..3f18359e53 100644 --- a/DevTools/HackStudio/TerminalWrapper.cpp +++ b/DevTools/HackStudio/TerminalWrapper.cpp @@ -166,16 +166,13 @@ void TerminalWrapper::kill_running_command() (void)killpg(m_pid, SIGTERM); } -TerminalWrapper::TerminalWrapper(GUI::Widget* parent) - : GUI::Widget(parent) +TerminalWrapper::TerminalWrapper() { set_layout(make<GUI::VerticalBoxLayout>()); RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Terminal"); - m_terminal_widget = TerminalWidget::construct(-1, false, config); - add_child(*m_terminal_widget); - - m_process_state_widget = ProcessStateWidget::construct(this); + m_terminal_widget = add<TerminalWidget>(-1, false, config); + m_process_state_widget = add<ProcessStateWidget>(); } TerminalWrapper::~TerminalWrapper() diff --git a/DevTools/HackStudio/TerminalWrapper.h b/DevTools/HackStudio/TerminalWrapper.h index 96934c8754..85ac9e1402 100644 --- a/DevTools/HackStudio/TerminalWrapper.h +++ b/DevTools/HackStudio/TerminalWrapper.h @@ -42,7 +42,7 @@ public: Function<void()> on_command_exit; private: - explicit TerminalWrapper(GUI::Widget* parent); + explicit TerminalWrapper(); RefPtr<ProcessStateWidget> m_process_state_widget; RefPtr<TerminalWidget> m_terminal_widget; diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index fd856bca5d..2159812549 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -80,7 +80,7 @@ static RefPtr<GUI::TabWidget> s_action_tab_widget; void add_new_editor(GUI::Widget& parent) { - auto wrapper = EditorWrapper::construct(nullptr); + auto wrapper = EditorWrapper::construct(); if (s_action_tab_widget) { parent.insert_child_before(wrapper, *s_action_tab_widget); } else { @@ -165,7 +165,7 @@ int main(int argc, char** argv) g_project = Project::load_from_file("little.files"); ASSERT(g_project); - auto toolbar = GUI::ToolBar::construct(widget); + auto toolbar = widget->add<GUI::ToolBar>(); auto selected_file_names = [&] { Vector<String> files; @@ -176,7 +176,7 @@ int main(int argc, char** argv) }; auto new_action = GUI::Action::create("Add new file to project...", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) { - auto input_box = GUI::InputBox::construct("Enter name of new file:", "Add new file to project", g_window); + auto input_box = g_window->add<GUI::InputBox>("Enter name of new file:", "Add new file to project"); if (input_box->exec() == GUI::InputBox::ExecCancel) return; auto filename = input_box->text_value(); @@ -247,8 +247,8 @@ int main(int argc, char** argv) project_tree_view_context_menu->add_action(add_existing_file_action); project_tree_view_context_menu->add_action(delete_action); - auto outer_splitter = GUI::HorizontalSplitter::construct(widget); - g_project_tree_view = GUI::TreeView::construct(outer_splitter); + auto outer_splitter = widget->add<GUI::HorizontalSplitter>(); + g_project_tree_view = outer_splitter->add<GUI::TreeView>(); g_project_tree_view->set_model(g_project->model()); g_project_tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); g_project_tree_view->set_preferred_size(140, 0); @@ -263,11 +263,11 @@ int main(int argc, char** argv) delete_action->set_enabled(!g_project_tree_view->selection().is_empty()); }; - g_right_hand_stack = GUI::StackWidget::construct(outer_splitter); + g_right_hand_stack = outer_splitter->add<GUI::StackWidget>(); - g_form_inner_container = GUI::Widget::construct(g_right_hand_stack); + g_form_inner_container = g_right_hand_stack->add<GUI::Widget>(); g_form_inner_container->set_layout(make<GUI::HorizontalBoxLayout>()); - auto form_widgets_toolbar = GUI::ToolBar::construct(Orientation::Vertical, 26, g_form_inner_container); + auto form_widgets_toolbar = g_form_inner_container->add<GUI::ToolBar>(Orientation::Vertical, 26); form_widgets_toolbar->set_preferred_size(38, 0); GUI::ActionGroup tool_actions; @@ -296,19 +296,19 @@ int main(int argc, char** argv) form_widgets_toolbar->add_action(move(action)); }); - auto form_editor_inner_splitter = GUI::HorizontalSplitter::construct(g_form_inner_container); + auto form_editor_inner_splitter = g_form_inner_container->add<GUI::HorizontalSplitter>(); - g_form_editor_widget = FormEditorWidget::construct(form_editor_inner_splitter); + g_form_editor_widget = form_editor_inner_splitter->add<FormEditorWidget>(); - auto form_editing_pane_container = GUI::VerticalSplitter::construct(form_editor_inner_splitter); + auto form_editing_pane_container = form_editor_inner_splitter->add<GUI::VerticalSplitter>(); form_editing_pane_container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); form_editing_pane_container->set_preferred_size(190, 0); form_editing_pane_container->set_layout(make<GUI::VerticalBoxLayout>()); auto add_properties_pane = [&](auto& text, auto pane_widget) { - auto wrapper = GUI::Widget::construct(form_editing_pane_container.ptr()); + auto wrapper = form_editing_pane_container->add<GUI::Widget>(); wrapper->set_layout(make<GUI::VerticalBoxLayout>()); - auto label = GUI::Label::construct(text, wrapper); + auto label = wrapper->add<GUI::Label>(text); label->set_fill_with_background_color(true); label->set_text_alignment(Gfx::TextAlignment::CenterLeft); label->set_font(Gfx::Font::default_bold_font()); @@ -317,7 +317,7 @@ int main(int argc, char** argv) wrapper->add_child(pane_widget); }; - auto form_widget_tree_view = GUI::TreeView::construct(nullptr); + auto form_widget_tree_view = GUI::TreeView::construct(); form_widget_tree_view->set_model(g_form_editor_widget->model()); form_widget_tree_view->on_selection_change = [&] { g_form_editor_widget->selection().disable_hooks(); @@ -343,9 +343,9 @@ int main(int argc, char** argv) }; add_properties_pane("Form widget tree:", form_widget_tree_view); - add_properties_pane("Widget properties:", GUI::TableView::construct(nullptr)); + add_properties_pane("Widget properties:", GUI::TableView::construct()); - g_text_inner_splitter = GUI::VerticalSplitter::construct(g_right_hand_stack); + g_text_inner_splitter = g_right_hand_stack->add<GUI::VerticalSplitter>(); g_text_inner_splitter->layout()->set_margins({ 0, 3, 0, 0 }); add_new_editor(*g_text_inner_splitter); @@ -420,7 +420,7 @@ int main(int argc, char** argv) open_file(filename); }; - s_action_tab_widget = GUI::TabWidget::construct(g_text_inner_splitter); + s_action_tab_widget = g_text_inner_splitter->add<GUI::TabWidget>(); s_action_tab_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); s_action_tab_widget->set_preferred_size(0, 24); @@ -444,13 +444,13 @@ int main(int argc, char** argv) update_actions(); }); - auto find_in_files_widget = FindInFilesWidget::construct(nullptr); + auto find_in_files_widget = FindInFilesWidget::construct(); s_action_tab_widget->add_widget("Find in files", find_in_files_widget); - auto terminal_wrapper = TerminalWrapper::construct(nullptr); + auto terminal_wrapper = TerminalWrapper::construct(); s_action_tab_widget->add_widget("Console", terminal_wrapper); - auto locator = Locator::construct(widget); + auto locator = widget->add<Locator>(); auto open_locator_action = GUI::Action::create("Open Locator...", { Mod_Ctrl, Key_K }, [&](auto&) { locator->open(); diff --git a/DevTools/VisualBuilder/VBWidgetRegistry.cpp b/DevTools/VisualBuilder/VBWidgetRegistry.cpp index bf176bbcf1..edb5812064 100644 --- a/DevTools/VisualBuilder/VBWidgetRegistry.cpp +++ b/DevTools/VisualBuilder/VBWidgetRegistry.cpp @@ -98,53 +98,53 @@ static RefPtr<GUI::Widget> build_gwidget(VBWidgetType type, GUI::Widget* parent) { switch (type) { case VBWidgetType::GWidget: - return GUI::Widget::construct(parent); + return parent->add<GUI::Widget>(); case VBWidgetType::GScrollBar: - return GUI::ScrollBar::construct(Orientation::Vertical, parent); + return parent->add<GUI::ScrollBar>(Orientation::Vertical); case VBWidgetType::GGroupBox: - return GUI::GroupBox::construct("groupbox_1", parent); + return parent->add<GUI::GroupBox>("groupbox_1"); case VBWidgetType::GLabel: { - auto label = GUI::Label::construct(parent); + 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 = GUI::Button::construct(parent); + auto button = parent->add<GUI::Button>(); button->set_text("button_1"); return button; } case VBWidgetType::GSpinBox: { - auto box = GUI::SpinBox::construct(parent); + auto box = parent->add<GUI::SpinBox>(); box->set_range(0, 100); box->set_value(0); return box; } case VBWidgetType::GTextEditor: { - auto editor = GUI::TextEditor::construct(GUI::TextEditor::Type::MultiLine, parent); + auto editor = parent->add<GUI::TextEditor>(); editor->set_ruler_visible(false); return editor; } case VBWidgetType::GProgressBar: { - auto bar = GUI::ProgressBar::construct(parent); + 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 = GUI::HorizontalSlider::construct(parent); + auto slider = parent->add<GUI::HorizontalSlider>(); slider->set_range(0, 100); slider->set_value(50); return slider; } case VBWidgetType::GCheckBox: { - auto box = GUI::CheckBox::construct(parent); + auto box = parent->add<GUI::CheckBox>(); box->set_text("checkbox_1"); return box; } case VBWidgetType::GRadioButton: - return GUI::RadioButton::construct("radio_1", parent); + return parent->add<GUI::RadioButton>("radio_1"); default: ASSERT_NOT_REACHED(); return nullptr; diff --git a/Games/Minesweeper/Field.cpp b/Games/Minesweeper/Field.cpp index e4d2e88af1..e521dde58c 100644 --- a/Games/Minesweeper/Field.cpp +++ b/Games/Minesweeper/Field.cpp @@ -28,10 +28,10 @@ #include <AK/HashTable.h> #include <AK/Queue.h> #include <LibCore/ConfigFile.h> -#include <LibGfx/Palette.h> #include <LibGUI/Button.h> #include <LibGUI/Label.h> #include <LibGUI/Painter.h> +#include <LibGfx/Palette.h> #include <time.h> #include <unistd.h> @@ -72,8 +72,7 @@ public: virtual void mousedown_event(GUI::MouseEvent& event) override { if (event.button() == GUI::MouseButton::Right || event.button() == GUI::MouseButton::Left) { - if (event.buttons() == (GUI::MouseButton::Right | GUI::MouseButton::Left) || - m_square.field->is_single_chording()) { + if (event.buttons() == (GUI::MouseButton::Right | GUI::MouseButton::Left) || m_square.field->is_single_chording()) { m_chord = true; m_square.field->set_chord_preview(m_square, true); } @@ -120,15 +119,14 @@ public: bool m_chord { false }; }; -Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, GUI::Widget* parent, Function<void(Gfx::Size)> on_size_changed) - : GUI::Frame(parent) - , m_face_button(face_button) +Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::Size)> on_size_changed) + : m_face_button(face_button) , m_flag_label(flag_label) , m_time_label(time_label) , m_on_size_changed(move(on_size_changed)) { srand(time(nullptr)); - m_timer = Core::Timer::construct(); + m_timer = add<Core::Timer>(); m_timer->on_timeout = [this] { ++m_time_elapsed; m_time_label.set_text(String::format("%u.%u", m_time_elapsed / 10, m_time_elapsed % 10)); @@ -511,7 +509,8 @@ void Field::set_field_size(int rows, int columns, int mine_count) m_on_size_changed(preferred_size()); } -void Field::set_single_chording(bool enabled) { +void Field::set_single_chording(bool enabled) +{ auto config = Core::ConfigFile::get_for_app("Minesweeper"); m_single_chording = enabled; config->write_bool_entry("Minesweeper", "SingleChording", m_single_chording); diff --git a/Games/Minesweeper/Field.h b/Games/Minesweeper/Field.h index d31367c92c..b56813d460 100644 --- a/Games/Minesweeper/Field.h +++ b/Games/Minesweeper/Field.h @@ -60,7 +60,7 @@ class Field final : public GUI::Frame { friend class Square; friend class SquareLabel; public: - Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, GUI::Widget* parent, Function<void(Gfx::Size)> on_size_changed); + Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, Function<void(Gfx::Size)> on_size_changed); virtual ~Field() override; int rows() const { return m_rows; } diff --git a/Games/Minesweeper/main.cpp b/Games/Minesweeper/main.cpp index 2a35a47987..10e162ba31 100644 --- a/Games/Minesweeper/main.cpp +++ b/Games/Minesweeper/main.cpp @@ -62,22 +62,22 @@ int main(int argc, char** argv) widget->set_layout(make<GUI::VerticalBoxLayout>()); widget->layout()->set_spacing(0); - auto container = GUI::Widget::construct(widget.ptr()); + auto container = widget->add<GUI::Widget>(); container->set_fill_with_background_color(true); container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); container->set_preferred_size(0, 36); container->set_layout(make<GUI::HorizontalBoxLayout>()); - auto flag_icon_label = GUI::Label::construct(container); + auto flag_icon_label = container->add<GUI::Label>(); flag_icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/flag.png")); - auto flag_label = GUI::Label::construct(container); - auto face_button = GUI::Button::construct(container); + auto flag_label = container->add<GUI::Label>(); + auto face_button = container->add<GUI::Button>(); face_button->set_button_style(Gfx::ButtonStyle::CoolBar); face_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); face_button->set_preferred_size(36, 0); - auto time_icon_label = GUI::Label::construct(container); + auto time_icon_label = container->add<GUI::Label>(); time_icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/timer.png")); - auto time_label = GUI::Label::construct(container); - auto field = Field::construct(*flag_label, *time_label, *face_button, widget, [&](auto size) { + auto time_label = container->add<GUI::Label>(); + auto field = widget->add<Field>(*flag_label, *time_label, *face_button, [&](auto size) { size.set_height(size.height() + container->preferred_size().height()); window->resize(size); }); diff --git a/Libraries/LibHTML/DOM/HTMLInputElement.cpp b/Libraries/LibHTML/DOM/HTMLInputElement.cpp index 7780f08d26..7b0b6ea14d 100644 --- a/Libraries/LibHTML/DOM/HTMLInputElement.cpp +++ b/Libraries/LibHTML/DOM/HTMLInputElement.cpp @@ -52,7 +52,7 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*) RefPtr<GUI::Widget> widget; if (type() == "submit") { - auto button = GUI::Button::construct(value(), &html_view); + auto button = html_view.add<GUI::Button>(value()); int text_width = Gfx::Font::default_font().width(value()); button->set_relative_rect(0, 0, text_width + 20, 20); button->on_click = [this](auto&) { diff --git a/Libraries/LibHTML/HtmlView.cpp b/Libraries/LibHTML/HtmlView.cpp index 8d491d4e62..c6412d3c3e 100644 --- a/Libraries/LibHTML/HtmlView.cpp +++ b/Libraries/LibHTML/HtmlView.cpp @@ -46,9 +46,8 @@ #include <LibHTML/ResourceLoader.h> #include <stdio.h> -HtmlView::HtmlView(GUI::Widget* parent) - : GUI::ScrollableWidget(parent) - , m_main_frame(::Frame::create(*this)) +HtmlView::HtmlView() + : m_main_frame(::Frame::create(*this)) { main_frame().on_set_needs_display = [this](auto& content_rect) { if (content_rect.is_empty()) { diff --git a/Libraries/LibHTML/HtmlView.h b/Libraries/LibHTML/HtmlView.h index cb3da961cd..b38320afe0 100644 --- a/Libraries/LibHTML/HtmlView.h +++ b/Libraries/LibHTML/HtmlView.h @@ -62,7 +62,7 @@ public: virtual bool accepts_focus() const override { return true; } protected: - HtmlView(GUI::Widget* parent = nullptr); + HtmlView(); virtual void resize_event(GUI::ResizeEvent&) override; virtual void paint_event(GUI::PaintEvent&) override; diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp index 86646b3b6f..afb76a01ed 100644 --- a/Libraries/LibVT/TerminalWidget.cpp +++ b/Libraries/LibVT/TerminalWidget.cpp @@ -89,14 +89,14 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy, RefPtr<Co , m_config(move(config)) { set_pty_master_fd(ptm_fd); - m_cursor_blink_timer = Core::Timer::construct(); - m_visual_beep_timer = Core::Timer::construct(); + m_cursor_blink_timer = add<Core::Timer>(); + m_visual_beep_timer = add<Core::Timer>(); set_frame_shape(Gfx::FrameShape::Container); set_frame_shadow(Gfx::FrameShadow::Sunken); set_frame_thickness(2); - m_scrollbar = GUI::ScrollBar::construct(Orientation::Vertical, this); + m_scrollbar = add<GUI::ScrollBar>(Orientation::Vertical); m_scrollbar->set_relative_rect(0, 0, 16, 0); m_scrollbar->on_change = [this](int) { force_repaint(); diff --git a/MenuApplets/Clock/main.cpp b/MenuApplets/Clock/main.cpp index 1cb22e85db..3b926974f7 100644 --- a/MenuApplets/Clock/main.cpp +++ b/MenuApplets/Clock/main.cpp @@ -42,7 +42,7 @@ public: { m_time_width = Gfx::Font::default_bold_font().width("2222-22-22 22:22:22"); - m_timer = Core::Timer::construct(1000, [this] { + m_timer = add<Core::Timer>(1000, [this] { static time_t last_update_time; time_t now = time(nullptr); if (now != last_update_time) { diff --git a/Servers/NotificationServer/NotificationWindow.cpp b/Servers/NotificationServer/NotificationWindow.cpp index 2bfb35d5de..c112569c04 100644 --- a/Servers/NotificationServer/NotificationWindow.cpp +++ b/Servers/NotificationServer/NotificationWindow.cpp @@ -68,21 +68,21 @@ NotificationWindow::NotificationWindow(const String& text, const String& title) widget->layout()->set_margins({ 4, 4, 4, 4 }); widget->layout()->set_spacing(4); - auto left_container = GUI::Widget::construct(widget.ptr()); + auto left_container = widget->add<GUI::Widget>(); left_container->set_layout(make<GUI::VerticalBoxLayout>()); - auto title_label = GUI::Label::construct(title, left_container); + auto title_label = left_container->add<GUI::Label>(title); title_label->set_font(Gfx::Font::default_bold_font()); title_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); - auto text_label = GUI::Label::construct(text, left_container); + auto text_label = left_container->add<GUI::Label>(text); text_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); - auto right_container = GUI::Widget::construct(widget.ptr()); + auto right_container = widget->add<GUI::Widget>(); right_container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); right_container->set_preferred_size(40, 0); right_container->set_layout(make<GUI::HorizontalBoxLayout>()); - auto button = GUI::Button::construct("Okay", right_container); + auto button = right_container->add<GUI::Button>("Okay"); button->on_click = [this](auto&) { s_windows.remove(this); close(); diff --git a/Servers/WindowServer/Compositor.cpp b/Servers/WindowServer/Compositor.cpp index a779efa51e..394b0014a4 100644 --- a/Servers/WindowServer/Compositor.cpp +++ b/Servers/WindowServer/Compositor.cpp @@ -60,8 +60,8 @@ WallpaperMode mode_to_enum(const String& name) Compositor::Compositor() { - m_compose_timer = Core::Timer::construct(this); - m_immediate_compose_timer = Core::Timer::construct(this); + m_compose_timer = add<Core::Timer>(); + m_immediate_compose_timer = add<Core::Timer>(); m_screen_can_set_buffer = Screen::the().can_set_buffer(); |