summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-23 10:57:42 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-23 11:10:52 +0100
commit3d20da9ee451460b6e233f5efdf5a13e11525f97 (patch)
tree524b72d0874304c68036dbbc0514b632a4a08c59 /Applications
parent7ec758773cdd85755d91f52614f361e7e750c7e9 (diff)
downloadserenity-3d20da9ee451460b6e233f5efdf5a13e11525f97.zip
Userspace: Use Core::Object::add() when building interfaces
Diffstat (limited to 'Applications')
-rw-r--r--Applications/About/main.cpp12
-rw-r--r--Applications/Browser/InspectorWidget.cpp10
-rw-r--r--Applications/Browser/main.cpp8
-rw-r--r--Applications/Calculator/CalculatorWidget.cpp43
-rw-r--r--Applications/Calculator/CalculatorWidget.h2
-rw-r--r--Applications/Calculator/main.cpp2
-rw-r--r--Applications/ChanViewer/main.cpp6
-rw-r--r--Applications/DisplayProperties/DisplayProperties.cpp24
-rw-r--r--Applications/FileManager/DirectoryView.cpp11
-rw-r--r--Applications/FileManager/DirectoryView.h2
-rw-r--r--Applications/FileManager/PropertiesDialog.cpp32
-rw-r--r--Applications/FileManager/main.cpp24
-rw-r--r--Applications/FontEditor/FontEditor.cpp4
-rw-r--r--Applications/FontEditor/GlyphEditorWidget.cpp5
-rw-r--r--Applications/FontEditor/GlyphEditorWidget.h2
-rw-r--r--Applications/FontEditor/GlyphMapWidget.cpp5
-rw-r--r--Applications/FontEditor/GlyphMapWidget.h2
-rw-r--r--Applications/Help/main.cpp8
-rw-r--r--Applications/IRCClient/IRCAppWindow.cpp14
-rw-r--r--Applications/IRCClient/IRCWindow.cpp8
-rw-r--r--Applications/PaintBrush/PaintableWidget.cpp3
-rw-r--r--Applications/PaintBrush/PaintableWidget.h3
-rw-r--r--Applications/PaintBrush/PaletteWidget.cpp22
-rw-r--r--Applications/PaintBrush/PaletteWidget.h2
-rw-r--r--Applications/PaintBrush/ToolboxWidget.cpp10
-rw-r--r--Applications/PaintBrush/ToolboxWidget.h2
-rw-r--r--Applications/PaintBrush/main.cpp8
-rw-r--r--Applications/Piano/KeysWidget.cpp5
-rw-r--r--Applications/Piano/KeysWidget.h2
-rw-r--r--Applications/Piano/KnobsWidget.cpp53
-rw-r--r--Applications/Piano/KnobsWidget.h2
-rw-r--r--Applications/Piano/MainWidget.cpp14
-rw-r--r--Applications/Piano/RollWidget.cpp5
-rw-r--r--Applications/Piano/RollWidget.h2
-rw-r--r--Applications/Piano/SamplerWidget.cpp18
-rw-r--r--Applications/Piano/SamplerWidget.h4
-rw-r--r--Applications/Piano/WaveWidget.cpp5
-rw-r--r--Applications/Piano/WaveWidget.h2
-rw-r--r--Applications/SoundPlayer/SampleWidget.cpp3
-rw-r--r--Applications/SoundPlayer/SampleWidget.h2
-rw-r--r--Applications/SoundPlayer/SoundPlayerWidget.cpp20
-rw-r--r--Applications/SoundPlayer/SoundPlayerWidget.h4
-rw-r--r--Applications/SystemMonitor/GraphWidget.cpp3
-rw-r--r--Applications/SystemMonitor/GraphWidget.h2
-rw-r--r--Applications/SystemMonitor/MemoryStatsWidget.cpp11
-rw-r--r--Applications/SystemMonitor/MemoryStatsWidget.h2
-rw-r--r--Applications/SystemMonitor/NetworkStatisticsWidget.cpp13
-rw-r--r--Applications/SystemMonitor/ProcessMemoryMapWidget.cpp4
-rw-r--r--Applications/SystemMonitor/ProcessStacksWidget.cpp4
-rw-r--r--Applications/SystemMonitor/main.cpp39
-rw-r--r--Applications/Taskbar/TaskbarButton.cpp5
-rw-r--r--Applications/Taskbar/TaskbarButton.h3
-rw-r--r--Applications/Taskbar/TaskbarWindow.cpp6
-rw-r--r--Applications/Terminal/main.cpp10
-rw-r--r--Applications/TextEditor/TextEditorWidget.cpp30
-rw-r--r--Applications/Welcome/main.cpp20
56 files changed, 274 insertions, 293 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);