summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
Diffstat (limited to 'Libraries')
-rw-r--r--Libraries/LibGUI/AboutDialog.cpp11
-rw-r--r--Libraries/LibGUI/Application.cpp3
-rw-r--r--Libraries/LibGUI/ColorPicker.cpp13
-rw-r--r--Libraries/LibGUI/ComboBox.cpp3
-rw-r--r--Libraries/LibGUI/FilePicker.cpp13
-rw-r--r--Libraries/LibGUI/InputBox.cpp21
-rw-r--r--Libraries/LibGUI/MessageBox.cpp17
7 files changed, 37 insertions, 44 deletions
diff --git a/Libraries/LibGUI/AboutDialog.cpp b/Libraries/LibGUI/AboutDialog.cpp
index 1de49c2c3b..5b0f0a8cbc 100644
--- a/Libraries/LibGUI/AboutDialog.cpp
+++ b/Libraries/LibGUI/AboutDialog.cpp
@@ -42,12 +42,11 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Core::
set_title(String::format("About %s", m_name.characters()));
set_resizable(false);
- auto widget = Widget::construct();
- set_main_widget(widget);
- widget->set_fill_with_background_color(true);
- widget->set_layout<HorizontalBoxLayout>();
+ auto& widget = set_main_widget<Widget>();
+ widget.set_fill_with_background_color(true);
+ widget.set_layout<HorizontalBoxLayout>();
- auto left_container = widget->add<Widget>();
+ auto left_container = widget.add<Widget>();
left_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
left_container->set_preferred_size(48, 0);
left_container->set_layout<VerticalBoxLayout>();
@@ -57,7 +56,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Core::
icon_label->set_preferred_size(40, 40);
left_container->layout()->add_spacer();
- auto right_container = widget->add<Widget>();
+ auto right_container = widget.add<Widget>();
right_container->set_layout<VerticalBoxLayout>();
right_container->layout()->set_margins({ 0, 4, 4, 4 });
diff --git a/Libraries/LibGUI/Application.cpp b/Libraries/LibGUI/Application.cpp
index 3e75168eb8..420a938711 100644
--- a/Libraries/LibGUI/Application.cpp
+++ b/Libraries/LibGUI/Application.cpp
@@ -122,13 +122,12 @@ private:
TooltipWindow()
{
set_window_type(WindowType::Tooltip);
- m_label = Label::construct();
+ m_label = set_main_widget<Label>();
m_label->set_background_color(Color::from_rgb(0xdac7b5));
m_label->set_fill_with_background_color(true);
m_label->set_frame_thickness(1);
m_label->set_frame_shape(Gfx::FrameShape::Container);
m_label->set_frame_shadow(Gfx::FrameShadow::Plain);
- set_main_widget(m_label);
}
RefPtr<Label> m_label;
diff --git a/Libraries/LibGUI/ColorPicker.cpp b/Libraries/LibGUI/ColorPicker.cpp
index 2f453570fd..e5d2df6eb1 100644
--- a/Libraries/LibGUI/ColorPicker.cpp
+++ b/Libraries/LibGUI/ColorPicker.cpp
@@ -48,16 +48,15 @@ ColorPicker::~ColorPicker()
void ColorPicker::build()
{
- auto horizontal_container = Widget::construct();
- horizontal_container->set_fill_with_background_color(true);
- horizontal_container->set_layout<HorizontalBoxLayout>();
- horizontal_container->layout()->set_margins({ 4, 4, 4, 4 });
- set_main_widget(horizontal_container);
+ auto& horizontal_container = set_main_widget<Widget>();
+ horizontal_container.set_fill_with_background_color(true);
+ horizontal_container.set_layout<HorizontalBoxLayout>();
+ horizontal_container.layout()->set_margins({ 4, 4, 4, 4 });
- auto left_vertical_container = horizontal_container->add<Widget>();
+ auto left_vertical_container = horizontal_container.add<Widget>();
left_vertical_container->set_layout<VerticalBoxLayout>();
- auto right_vertical_container = horizontal_container->add<Widget>();
+ auto right_vertical_container = horizontal_container.add<Widget>();
right_vertical_container->set_layout<VerticalBoxLayout>();
enum RGBComponent {
diff --git a/Libraries/LibGUI/ComboBox.cpp b/Libraries/LibGUI/ComboBox.cpp
index f6132a70fb..6be9e6b2d6 100644
--- a/Libraries/LibGUI/ComboBox.cpp
+++ b/Libraries/LibGUI/ComboBox.cpp
@@ -60,9 +60,8 @@ ComboBox::ComboBox()
// FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm.
m_list_window->set_window_type(WindowType::Tooltip);
- m_list_view = ListView::construct();
+ m_list_view = m_list_window->set_main_widget<ListView>();
m_list_view->horizontal_scrollbar().set_visible(false);
- m_list_window->set_main_widget(m_list_view);
m_list_view->on_selection = [this](auto& index) {
ASSERT(model());
diff --git a/Libraries/LibGUI/FilePicker.cpp b/Libraries/LibGUI/FilePicker.cpp
index d2988b3a4b..7d0abcdb84 100644
--- a/Libraries/LibGUI/FilePicker.cpp
+++ b/Libraries/LibGUI/FilePicker.cpp
@@ -81,13 +81,12 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
{
set_title(m_mode == Mode::Open ? "Open File" : "Save File");
set_rect(200, 200, 700, 400);
- auto horizontal_container = Widget::construct();
- set_main_widget(horizontal_container);
- horizontal_container->set_layout<HorizontalBoxLayout>();
- horizontal_container->layout()->set_margins({ 4, 4, 4, 4 });
- horizontal_container->set_fill_with_background_color(true);
+ auto& horizontal_container = set_main_widget<Widget>();
+ horizontal_container.set_layout<HorizontalBoxLayout>();
+ horizontal_container.layout()->set_margins({ 4, 4, 4, 4 });
+ horizontal_container.set_fill_with_background_color(true);
- auto vertical_container = horizontal_container->add<Widget>();
+ auto vertical_container = horizontal_container.add<Widget>();
vertical_container->set_layout<VerticalBoxLayout>();
vertical_container->layout()->set_spacing(4);
@@ -236,7 +235,7 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
}
};
- auto preview_container = horizontal_container->add<Frame>();
+ auto preview_container = horizontal_container.add<Frame>();
preview_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
preview_container->set_preferred_size(180, 0);
preview_container->set_layout<VerticalBoxLayout>();
diff --git a/Libraries/LibGUI/InputBox.cpp b/Libraries/LibGUI/InputBox.cpp
index 32c3e24c02..aca0d182b8 100644
--- a/Libraries/LibGUI/InputBox.cpp
+++ b/Libraries/LibGUI/InputBox.cpp
@@ -48,30 +48,29 @@ InputBox::~InputBox()
void InputBox::build()
{
- auto widget = Widget::construct();
- set_main_widget(widget);
+ auto& widget = set_main_widget<Widget>();
- int text_width = widget->font().width(m_prompt);
- int title_width = widget->font().width(title()) + 24 /* icon, plus a little padding -- not perfect */;
+ int text_width = widget.font().width(m_prompt);
+ int title_width = widget.font().width(title()) + 24 /* icon, plus a little padding -- not perfect */;
int max_width = AK::max(text_width, title_width);
set_rect(x(), y(), max_width + 80, 80);
- widget->set_layout<VerticalBoxLayout>();
- widget->set_fill_with_background_color(true);
+ widget.set_layout<VerticalBoxLayout>();
+ widget.set_fill_with_background_color(true);
- widget->layout()->set_margins({ 8, 8, 8, 8 });
- widget->layout()->set_spacing(8);
+ widget.layout()->set_margins({ 8, 8, 8, 8 });
+ widget.layout()->set_spacing(8);
- auto label = widget->add<Label>(m_prompt);
+ auto label = widget.add<Label>(m_prompt);
label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
label->set_preferred_size(text_width, 16);
- m_text_editor = widget->add<TextBox>();
+ m_text_editor = widget.add<TextBox>();
m_text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
m_text_editor->set_preferred_size(0, 19);
- auto button_container_outer = widget->add<Widget>();
+ auto button_container_outer = widget.add<Widget>();
button_container_outer->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
button_container_outer->set_preferred_size(0, 20);
button_container_outer->set_layout<VerticalBoxLayout>();
diff --git a/Libraries/LibGUI/MessageBox.cpp b/Libraries/LibGUI/MessageBox.cpp
index 78319508a6..bd8a0bb447 100644
--- a/Libraries/LibGUI/MessageBox.cpp
+++ b/Libraries/LibGUI/MessageBox.cpp
@@ -91,21 +91,20 @@ bool MessageBox::should_include_no_button() const
void MessageBox::build()
{
- auto widget = Widget::construct();
- set_main_widget(widget);
+ auto& widget = set_main_widget<Widget>();
- int text_width = widget->font().width(m_text);
+ int text_width = widget.font().width(m_text);
int icon_width = 0;
- widget->set_layout<VerticalBoxLayout>();
- widget->set_fill_with_background_color(true);
+ widget.set_layout<VerticalBoxLayout>();
+ widget.set_fill_with_background_color(true);
- widget->layout()->set_margins({ 0, 15, 0, 15 });
- widget->layout()->set_spacing(15);
+ widget.layout()->set_margins({ 0, 15, 0, 15 });
+ widget.layout()->set_spacing(15);
RefPtr<Widget> message_container = widget;
if (m_type != Type::None) {
- message_container = widget->add<Widget>();
+ message_container = widget.add<Widget>();
message_container->set_layout<HorizontalBoxLayout>();
message_container->layout()->set_margins({ 8, 0, 8, 0 });
message_container->layout()->set_spacing(8);
@@ -121,7 +120,7 @@ void MessageBox::build()
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
label->set_preferred_size(text_width, 16);
- auto button_container = widget->add<Widget>();
+ auto button_container = widget.add<Widget>();
button_container->set_layout<HorizontalBoxLayout>();
button_container->layout()->set_spacing(5);
button_container->layout()->set_margins({ 15, 0, 15, 0 });