diff options
Diffstat (limited to 'Libraries')
62 files changed, 101 insertions, 191 deletions
diff --git a/Libraries/LibGUI/AbstractButton.cpp b/Libraries/LibGUI/AbstractButton.cpp index 27f3ed998c..2c02b7d9fe 100644 --- a/Libraries/LibGUI/AbstractButton.cpp +++ b/Libraries/LibGUI/AbstractButton.cpp @@ -31,14 +31,8 @@ namespace GUI { -AbstractButton::AbstractButton(Widget* parent) - : AbstractButton({}, parent) -{ -} - -AbstractButton::AbstractButton(const StringView& text, Widget* parent) - : Widget(parent) - , m_text(text) +AbstractButton::AbstractButton(const StringView& text) + : m_text(text) { m_auto_repeat_timer = add<Core::Timer>(); m_auto_repeat_timer->on_timeout = [this] { diff --git a/Libraries/LibGUI/AbstractButton.h b/Libraries/LibGUI/AbstractButton.h index 4e504fd9e8..09780b6f8d 100644 --- a/Libraries/LibGUI/AbstractButton.h +++ b/Libraries/LibGUI/AbstractButton.h @@ -60,8 +60,7 @@ public: void set_auto_repeat_interval(int interval) { m_auto_repeat_interval = interval; } protected: - explicit AbstractButton(Widget* parent = nullptr); - AbstractButton(const StringView&, Widget* parent = nullptr); + explicit AbstractButton(const StringView& = {}); virtual void mousedown_event(MouseEvent&) override; virtual void mousemove_event(MouseEvent&) override; diff --git a/Libraries/LibGUI/AbstractTableView.cpp b/Libraries/LibGUI/AbstractTableView.cpp index 13a6e5bba5..d6cc468465 100644 --- a/Libraries/LibGUI/AbstractTableView.cpp +++ b/Libraries/LibGUI/AbstractTableView.cpp @@ -39,8 +39,7 @@ namespace GUI { static const int minimum_column_width = 2; -AbstractTableView::AbstractTableView(Widget* parent) - : AbstractView(parent) +AbstractTableView::AbstractTableView() { set_should_hide_unnecessary_scrollbars(true); } diff --git a/Libraries/LibGUI/AbstractTableView.h b/Libraries/LibGUI/AbstractTableView.h index 19b6bcb16f..41b0e905a8 100644 --- a/Libraries/LibGUI/AbstractTableView.h +++ b/Libraries/LibGUI/AbstractTableView.h @@ -72,7 +72,7 @@ public: protected: virtual ~AbstractTableView() override; - explicit AbstractTableView(Widget* parent = nullptr); + AbstractTableView(); virtual void did_update_model() override; virtual void mouseup_event(MouseEvent&) override; diff --git a/Libraries/LibGUI/AbstractView.cpp b/Libraries/LibGUI/AbstractView.cpp index c8411142b0..e9ac3dbc69 100644 --- a/Libraries/LibGUI/AbstractView.cpp +++ b/Libraries/LibGUI/AbstractView.cpp @@ -37,9 +37,8 @@ namespace GUI { -AbstractView::AbstractView(Widget* parent) - : ScrollableWidget(parent) - , m_selection(*this) +AbstractView::AbstractView() + : m_selection(*this) { } diff --git a/Libraries/LibGUI/AbstractView.h b/Libraries/LibGUI/AbstractView.h index 86564bc289..e8e339f86f 100644 --- a/Libraries/LibGUI/AbstractView.h +++ b/Libraries/LibGUI/AbstractView.h @@ -73,7 +73,7 @@ public: NonnullRefPtr<Gfx::Font> font_for_index(const ModelIndex&) const; protected: - explicit AbstractView(Widget* parent = nullptr); + AbstractView(); virtual ~AbstractView() override; virtual void mousedown_event(MouseEvent&) override; diff --git a/Libraries/LibGUI/Button.cpp b/Libraries/LibGUI/Button.cpp index 5ec77339c7..59c2ecc664 100644 --- a/Libraries/LibGUI/Button.cpp +++ b/Libraries/LibGUI/Button.cpp @@ -36,13 +36,8 @@ namespace GUI { -Button::Button(Widget* parent) - : AbstractButton(parent) -{ -} - -Button::Button(const StringView& text, Widget* parent) - : AbstractButton(text, parent) +Button::Button(const StringView& text) + : AbstractButton(text) { } diff --git a/Libraries/LibGUI/Button.h b/Libraries/LibGUI/Button.h index 225c8afc94..4ad0f2190e 100644 --- a/Libraries/LibGUI/Button.h +++ b/Libraries/LibGUI/Button.h @@ -62,8 +62,7 @@ public: void set_focusable(bool b) { m_focusable = b; } protected: - Button(const StringView& text, Widget* parent = nullptr); - explicit Button(Widget* parent = nullptr); + explicit Button(const StringView& text = {}); virtual void paint_event(PaintEvent&) override; private: diff --git a/Libraries/LibGUI/CheckBox.cpp b/Libraries/LibGUI/CheckBox.cpp index 34e87ac7d9..57a4df3a5f 100644 --- a/Libraries/LibGUI/CheckBox.cpp +++ b/Libraries/LibGUI/CheckBox.cpp @@ -52,13 +52,8 @@ static const int s_checked_bitmap_height = 9; static const int s_box_width = 13; static const int s_box_height = 13; -CheckBox::CheckBox(Widget* parent) - : AbstractButton(parent) -{ -} - -CheckBox::CheckBox(const StringView& text, Widget* parent) - : AbstractButton(text, parent) +CheckBox::CheckBox(const StringView& text) + : AbstractButton(text) { } diff --git a/Libraries/LibGUI/CheckBox.h b/Libraries/LibGUI/CheckBox.h index bee9ccad49..23367dfc96 100644 --- a/Libraries/LibGUI/CheckBox.h +++ b/Libraries/LibGUI/CheckBox.h @@ -38,8 +38,7 @@ public: virtual void click() override; private: - CheckBox(const StringView&, Widget* parent = nullptr); - explicit CheckBox(Widget* parent = nullptr); + explicit CheckBox(const StringView& = {}); // These don't make sense for a check box, so hide them. using AbstractButton::auto_repeat_interval; diff --git a/Libraries/LibGUI/ColumnsView.cpp b/Libraries/LibGUI/ColumnsView.cpp index 296b345c97..e71d86c608 100644 --- a/Libraries/LibGUI/ColumnsView.cpp +++ b/Libraries/LibGUI/ColumnsView.cpp @@ -47,8 +47,7 @@ static const char* s_arrow_bitmap_data = { static const int s_arrow_bitmap_width = 9; static const int s_arrow_bitmap_height = 9; -ColumnsView::ColumnsView(Widget* parent) - : AbstractView(parent) +ColumnsView::ColumnsView() { set_fill_with_background_color(true); set_background_role(ColorRole::Base); diff --git a/Libraries/LibGUI/ColumnsView.h b/Libraries/LibGUI/ColumnsView.h index 34245fc7bc..e92f31336e 100644 --- a/Libraries/LibGUI/ColumnsView.h +++ b/Libraries/LibGUI/ColumnsView.h @@ -40,8 +40,8 @@ public: virtual ModelIndex index_at_event_position(const Gfx::Point&) const override; private: - ColumnsView(Widget* parent = nullptr); - virtual ~ColumnsView(); + ColumnsView(); + virtual ~ColumnsView() override; void push_column(ModelIndex& parent_index); void update_column_sizes(); diff --git a/Libraries/LibGUI/ComboBox.cpp b/Libraries/LibGUI/ComboBox.cpp index 90bc2ed743..617a67dd4d 100644 --- a/Libraries/LibGUI/ComboBox.cpp +++ b/Libraries/LibGUI/ComboBox.cpp @@ -35,8 +35,7 @@ namespace GUI { -ComboBox::ComboBox(Widget* parent) - : Widget(parent) +ComboBox::ComboBox() { m_editor = add<TextBox>(); m_editor->on_change = [this] { @@ -57,11 +56,11 @@ ComboBox::ComboBox(Widget* parent) open(); }; - m_list_window = Window::construct(this); + m_list_window = add<Window>(); // 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(nullptr); + m_list_view = ListView::construct(); m_list_view->horizontal_scrollbar().set_visible(false); m_list_window->set_main_widget(m_list_view); diff --git a/Libraries/LibGUI/ComboBox.h b/Libraries/LibGUI/ComboBox.h index 51ebbd2e4c..f766a052d8 100644 --- a/Libraries/LibGUI/ComboBox.h +++ b/Libraries/LibGUI/ComboBox.h @@ -56,7 +56,7 @@ public: Function<void()> on_return_pressed; protected: - explicit ComboBox(Widget* parent = nullptr); + ComboBox(); virtual void resize_event(ResizeEvent&) override; private: diff --git a/Libraries/LibGUI/Frame.cpp b/Libraries/LibGUI/Frame.cpp index 18fd5eefeb..e2cb7c23d0 100644 --- a/Libraries/LibGUI/Frame.cpp +++ b/Libraries/LibGUI/Frame.cpp @@ -31,8 +31,7 @@ namespace GUI { -Frame::Frame(Widget* parent) - : Widget(parent) +Frame::Frame() { set_frame_thickness(2); set_frame_shape(Gfx::FrameShape::Container); diff --git a/Libraries/LibGUI/Frame.h b/Libraries/LibGUI/Frame.h index 1d78703c73..e31bf13052 100644 --- a/Libraries/LibGUI/Frame.h +++ b/Libraries/LibGUI/Frame.h @@ -49,7 +49,7 @@ public: Gfx::Rect frame_inner_rect() const { return frame_inner_rect_for_size(size()); } protected: - explicit Frame(Widget* parent = nullptr); + Frame(); void paint_event(PaintEvent&) override; private: diff --git a/Libraries/LibGUI/GroupBox.cpp b/Libraries/LibGUI/GroupBox.cpp index db9cb6480d..f74db7f20b 100644 --- a/Libraries/LibGUI/GroupBox.cpp +++ b/Libraries/LibGUI/GroupBox.cpp @@ -32,14 +32,8 @@ namespace GUI { -GroupBox::GroupBox(Widget* parent) - : GroupBox({}, parent) -{ -} - -GroupBox::GroupBox(const StringView& title, Widget* parent) - : Widget(parent) - , m_title(title) +GroupBox::GroupBox(const StringView& title) + : m_title(title) { } diff --git a/Libraries/LibGUI/GroupBox.h b/Libraries/LibGUI/GroupBox.h index 1e1c6164fe..1e56fb91f6 100644 --- a/Libraries/LibGUI/GroupBox.h +++ b/Libraries/LibGUI/GroupBox.h @@ -39,8 +39,7 @@ public: void set_title(const StringView&); protected: - explicit GroupBox(Widget* parent = nullptr); - GroupBox(const StringView& title, Widget* parent = nullptr); + explicit GroupBox(const StringView& title = {}); virtual void paint_event(PaintEvent&) override; diff --git a/Libraries/LibGUI/ItemView.cpp b/Libraries/LibGUI/ItemView.cpp index 3c4a394e73..73672fbb3a 100644 --- a/Libraries/LibGUI/ItemView.cpp +++ b/Libraries/LibGUI/ItemView.cpp @@ -37,8 +37,7 @@ namespace GUI { -ItemView::ItemView(Widget* parent) - : AbstractView(parent) +ItemView::ItemView() { set_background_role(ColorRole::Base); set_foreground_role(ColorRole::BaseText); diff --git a/Libraries/LibGUI/ItemView.h b/Libraries/LibGUI/ItemView.h index 625b7e1b3f..a960df73fb 100644 --- a/Libraries/LibGUI/ItemView.h +++ b/Libraries/LibGUI/ItemView.h @@ -48,7 +48,7 @@ public: virtual ModelIndex index_at_event_position(const Gfx::Point&) const override; private: - explicit ItemView(Widget* parent = nullptr); + ItemView(); virtual void did_update_model() override; virtual void paint_event(PaintEvent&) override; diff --git a/Libraries/LibGUI/Label.cpp b/Libraries/LibGUI/Label.cpp index 09a4dc87be..aaab033106 100644 --- a/Libraries/LibGUI/Label.cpp +++ b/Libraries/LibGUI/Label.cpp @@ -32,14 +32,8 @@ namespace GUI { -Label::Label(Widget* parent) - : Label({}, parent) -{ -} - -Label::Label(const StringView& text, Widget* parent) - : Frame(parent) - , m_text(text) +Label::Label(const StringView& text) + : m_text(text) { set_frame_thickness(0); set_frame_shadow(Gfx::FrameShadow::Plain); diff --git a/Libraries/LibGUI/Label.h b/Libraries/LibGUI/Label.h index d686fad13c..d0541eccfa 100644 --- a/Libraries/LibGUI/Label.h +++ b/Libraries/LibGUI/Label.h @@ -52,8 +52,7 @@ public: void size_to_fit(); protected: - explicit Label(Widget* parent = nullptr); - Label(const StringView& text, Widget* parent = nullptr); + explicit Label(const StringView& text = {}); virtual void paint_event(PaintEvent&) override; diff --git a/Libraries/LibGUI/LazyWidget.cpp b/Libraries/LibGUI/LazyWidget.cpp index 9de6f79d1b..3e1a9c4951 100644 --- a/Libraries/LibGUI/LazyWidget.cpp +++ b/Libraries/LibGUI/LazyWidget.cpp @@ -28,8 +28,7 @@ namespace GUI { -LazyWidget::LazyWidget(Widget* parent) - : Widget(parent) +LazyWidget::LazyWidget() { } diff --git a/Libraries/LibGUI/LazyWidget.h b/Libraries/LibGUI/LazyWidget.h index 887a53ede0..8b7717fb96 100644 --- a/Libraries/LibGUI/LazyWidget.h +++ b/Libraries/LibGUI/LazyWidget.h @@ -38,7 +38,7 @@ public: Function<void(LazyWidget&)> on_first_show; protected: - explicit LazyWidget(Widget* parent = nullptr); + LazyWidget(); private: virtual void show_event(ShowEvent&) override; diff --git a/Libraries/LibGUI/ListView.cpp b/Libraries/LibGUI/ListView.cpp index d87339e27d..ec1ca55dc4 100644 --- a/Libraries/LibGUI/ListView.cpp +++ b/Libraries/LibGUI/ListView.cpp @@ -33,8 +33,7 @@ namespace GUI { -ListView::ListView(Widget* parent) - : AbstractView(parent) +ListView::ListView() { set_background_role(ColorRole::Base); set_foreground_role(ColorRole::BaseText); diff --git a/Libraries/LibGUI/ListView.h b/Libraries/LibGUI/ListView.h index 070cc1bf04..0564a873df 100644 --- a/Libraries/LibGUI/ListView.h +++ b/Libraries/LibGUI/ListView.h @@ -33,7 +33,6 @@ namespace GUI { class ListView : public AbstractView { C_OBJECT(ListView) public: - explicit ListView(Widget* parent = nullptr); virtual ~ListView() override; int item_height() const { return 16; } @@ -54,6 +53,8 @@ public: void set_model_column(int column) { m_model_column = column; } private: + ListView(); + virtual void did_update_model() override; virtual void paint_event(PaintEvent&) override; virtual void doubleclick_event(MouseEvent&) override; diff --git a/Libraries/LibGUI/ModelEditingDelegate.h b/Libraries/LibGUI/ModelEditingDelegate.h index 5b8efeed20..0815075f6f 100644 --- a/Libraries/LibGUI/ModelEditingDelegate.h +++ b/Libraries/LibGUI/ModelEditingDelegate.h @@ -77,7 +77,7 @@ public: virtual RefPtr<Widget> create_widget() override { - auto textbox = TextBox::construct(nullptr); + auto textbox = TextBox::construct(); textbox->on_return_pressed = [this] { commit(); }; diff --git a/Libraries/LibGUI/ProgressBar.cpp b/Libraries/LibGUI/ProgressBar.cpp index 4fee5a63c6..a193f61b48 100644 --- a/Libraries/LibGUI/ProgressBar.cpp +++ b/Libraries/LibGUI/ProgressBar.cpp @@ -32,8 +32,7 @@ namespace GUI { -ProgressBar::ProgressBar(Widget* parent) - : Frame(parent) +ProgressBar::ProgressBar() { } diff --git a/Libraries/LibGUI/ProgressBar.h b/Libraries/LibGUI/ProgressBar.h index 02bafeb06e..9ba6f21297 100644 --- a/Libraries/LibGUI/ProgressBar.h +++ b/Libraries/LibGUI/ProgressBar.h @@ -56,7 +56,7 @@ public: void set_format(Format format) { m_format = format; } protected: - explicit ProgressBar(Widget* parent = nullptr); + ProgressBar(); virtual void paint_event(PaintEvent&) override; diff --git a/Libraries/LibGUI/RadioButton.cpp b/Libraries/LibGUI/RadioButton.cpp index e633a909b5..8d00f8105f 100644 --- a/Libraries/LibGUI/RadioButton.cpp +++ b/Libraries/LibGUI/RadioButton.cpp @@ -33,13 +33,8 @@ namespace GUI { -RadioButton::RadioButton(Widget* parent) - : RadioButton({}, parent) -{ -} - -RadioButton::RadioButton(const StringView& text, Widget* parent) - : AbstractButton(text, parent) +RadioButton::RadioButton(const StringView& text) + : AbstractButton(text) { } diff --git a/Libraries/LibGUI/RadioButton.h b/Libraries/LibGUI/RadioButton.h index cb03930cea..77c77ec426 100644 --- a/Libraries/LibGUI/RadioButton.h +++ b/Libraries/LibGUI/RadioButton.h @@ -38,8 +38,7 @@ public: virtual void click() override; protected: - explicit RadioButton(Widget* parent = nullptr); - explicit RadioButton(const StringView& text, Widget* parent = nullptr); + explicit RadioButton(const StringView& text = {}); virtual void paint_event(PaintEvent&) override; private: diff --git a/Libraries/LibGUI/ResizeCorner.cpp b/Libraries/LibGUI/ResizeCorner.cpp index e17989a06f..4aa3ca2939 100644 --- a/Libraries/LibGUI/ResizeCorner.cpp +++ b/Libraries/LibGUI/ResizeCorner.cpp @@ -75,8 +75,7 @@ static Gfx::CharacterBitmap* s_resize_corner_highlights_bitmap; static const int s_resize_corner_bitmap_width = 16; static const int s_resize_corner_bitmap_height = 16; -ResizeCorner::ResizeCorner(Widget* parent) - : Widget(parent) +ResizeCorner::ResizeCorner() { set_background_role(ColorRole::Button); set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); diff --git a/Libraries/LibGUI/ResizeCorner.h b/Libraries/LibGUI/ResizeCorner.h index a91379de5a..c2ebbd9ce3 100644 --- a/Libraries/LibGUI/ResizeCorner.h +++ b/Libraries/LibGUI/ResizeCorner.h @@ -34,7 +34,7 @@ public: virtual ~ResizeCorner() override; protected: - explicit ResizeCorner(Widget* parent = nullptr); + ResizeCorner(); virtual void paint_event(PaintEvent&) override; virtual void mousedown_event(MouseEvent&) override; diff --git a/Libraries/LibGUI/ScrollBar.cpp b/Libraries/LibGUI/ScrollBar.cpp index 73bdc42c16..0f217ce1ae 100644 --- a/Libraries/LibGUI/ScrollBar.cpp +++ b/Libraries/LibGUI/ScrollBar.cpp @@ -86,14 +86,8 @@ static Gfx::CharacterBitmap* s_down_arrow_bitmap; static Gfx::CharacterBitmap* s_left_arrow_bitmap; static Gfx::CharacterBitmap* s_right_arrow_bitmap; -ScrollBar::ScrollBar(Widget* parent) - : ScrollBar(Orientation::Vertical, parent) -{ -} - -ScrollBar::ScrollBar(Orientation orientation, Widget* parent) - : Widget(parent) - , m_orientation(orientation) +ScrollBar::ScrollBar(Orientation orientation) + : m_orientation(orientation) { m_automatic_scrolling_timer = add<Core::Timer>(); if (!s_up_arrow_bitmap) diff --git a/Libraries/LibGUI/ScrollBar.h b/Libraries/LibGUI/ScrollBar.h index 556dbff0f2..dd943e6a0e 100644 --- a/Libraries/LibGUI/ScrollBar.h +++ b/Libraries/LibGUI/ScrollBar.h @@ -65,8 +65,7 @@ public: }; private: - explicit ScrollBar(Widget* parent = nullptr); - explicit ScrollBar(Orientation, Widget* parent = nullptr); + explicit ScrollBar(Gfx::Orientation = Gfx::Orientation::Vertical); virtual void paint_event(PaintEvent&) override; virtual void mousedown_event(MouseEvent&) override; diff --git a/Libraries/LibGUI/ScrollableWidget.cpp b/Libraries/LibGUI/ScrollableWidget.cpp index d5fe7de93a..42fc5ebf25 100644 --- a/Libraries/LibGUI/ScrollableWidget.cpp +++ b/Libraries/LibGUI/ScrollableWidget.cpp @@ -29,17 +29,16 @@ namespace GUI { -ScrollableWidget::ScrollableWidget(Widget* parent) - : Frame(parent) +ScrollableWidget::ScrollableWidget() { - m_vertical_scrollbar = ScrollBar::construct(Orientation::Vertical, this); + m_vertical_scrollbar = add<ScrollBar>(Orientation::Vertical); m_vertical_scrollbar->set_step(4); m_vertical_scrollbar->on_change = [this](int) { did_scroll(); update(); }; - m_horizontal_scrollbar = ScrollBar::construct(Orientation::Horizontal, this); + m_horizontal_scrollbar = add<ScrollBar>(Orientation::Horizontal); m_horizontal_scrollbar->set_step(4); m_horizontal_scrollbar->set_big_step(30); m_horizontal_scrollbar->on_change = [this](int) { @@ -47,7 +46,7 @@ ScrollableWidget::ScrollableWidget(Widget* parent) update(); }; - m_corner_widget = Widget::construct(this); + m_corner_widget = add<Widget>(); m_corner_widget->set_fill_with_background_color(true); } diff --git a/Libraries/LibGUI/ScrollableWidget.h b/Libraries/LibGUI/ScrollableWidget.h index 923fc6ed68..a83739d126 100644 --- a/Libraries/LibGUI/ScrollableWidget.h +++ b/Libraries/LibGUI/ScrollableWidget.h @@ -71,7 +71,7 @@ public: Gfx::Point to_widget_position(const Gfx::Point& content_position) const; protected: - explicit ScrollableWidget(Widget* parent = nullptr); + ScrollableWidget(); virtual void custom_layout() override; virtual void resize_event(ResizeEvent&) override; virtual void mousewheel_event(MouseEvent&) override; diff --git a/Libraries/LibGUI/Slider.cpp b/Libraries/LibGUI/Slider.cpp index 540806846f..6fcafa766c 100644 --- a/Libraries/LibGUI/Slider.cpp +++ b/Libraries/LibGUI/Slider.cpp @@ -33,14 +33,8 @@ namespace GUI { -Slider::Slider(Widget* parent) - : Slider(Orientation::Horizontal, parent) -{ -} - -Slider::Slider(Orientation orientation, Widget* parent) - : Widget(parent) - , m_orientation(orientation) +Slider::Slider(Orientation orientation) + : m_orientation(orientation) { } diff --git a/Libraries/LibGUI/Slider.h b/Libraries/LibGUI/Slider.h index 74f217bdcf..597f3d1e65 100644 --- a/Libraries/LibGUI/Slider.h +++ b/Libraries/LibGUI/Slider.h @@ -74,8 +74,7 @@ public: Function<void(int)> on_value_changed; protected: - explicit Slider(Widget* = nullptr); - explicit Slider(Orientation, Widget* = nullptr); + explicit Slider(Orientation = Orientation::Vertical); virtual void paint_event(PaintEvent&) override; virtual void mousedown_event(MouseEvent&) override; @@ -106,8 +105,8 @@ public: virtual ~VerticalSlider() override {} private: - explicit VerticalSlider(Widget* parent = nullptr) - : Slider(Orientation::Vertical, parent) + VerticalSlider() + : Slider(Orientation::Vertical) { } }; @@ -118,8 +117,8 @@ public: virtual ~HorizontalSlider() override {} private: - explicit HorizontalSlider(Widget* parent = nullptr) - : Slider(Orientation::Horizontal, parent) + HorizontalSlider() + : Slider(Orientation::Horizontal) { } }; diff --git a/Libraries/LibGUI/SpinBox.cpp b/Libraries/LibGUI/SpinBox.cpp index 26b71612f9..718b1d7aa9 100644 --- a/Libraries/LibGUI/SpinBox.cpp +++ b/Libraries/LibGUI/SpinBox.cpp @@ -30,8 +30,7 @@ namespace GUI { -SpinBox::SpinBox(Widget* parent) - : Widget(parent) +SpinBox::SpinBox() { m_editor = add<TextBox>(); m_editor->set_text("0"); diff --git a/Libraries/LibGUI/SpinBox.h b/Libraries/LibGUI/SpinBox.h index e86d87948c..f47b64b168 100644 --- a/Libraries/LibGUI/SpinBox.h +++ b/Libraries/LibGUI/SpinBox.h @@ -47,7 +47,7 @@ public: Function<void(int value)> on_change; protected: - explicit SpinBox(Widget* parent = nullptr); + SpinBox(); virtual void resize_event(ResizeEvent&) override; diff --git a/Libraries/LibGUI/Splitter.cpp b/Libraries/LibGUI/Splitter.cpp index 6d8b935d65..671c540776 100644 --- a/Libraries/LibGUI/Splitter.cpp +++ b/Libraries/LibGUI/Splitter.cpp @@ -32,9 +32,8 @@ namespace GUI { -Splitter::Splitter(Orientation orientation, Widget* parent) - : Frame(parent) - , m_orientation(orientation) +Splitter::Splitter(Orientation orientation) + : m_orientation(orientation) { set_background_role(ColorRole::Button); set_layout(make<BoxLayout>(orientation)); diff --git a/Libraries/LibGUI/Splitter.h b/Libraries/LibGUI/Splitter.h index 4d05f47526..25de077667 100644 --- a/Libraries/LibGUI/Splitter.h +++ b/Libraries/LibGUI/Splitter.h @@ -36,7 +36,7 @@ public: virtual ~Splitter() override; protected: - Splitter(Gfx::Orientation, Widget* parent = nullptr); + explicit Splitter(Gfx::Orientation); virtual void paint_event(PaintEvent&) override; virtual void resize_event(ResizeEvent&) override; @@ -68,8 +68,8 @@ public: virtual ~VerticalSplitter() override {} private: - explicit VerticalSplitter(Widget* parent = nullptr) - : Splitter(Gfx::Orientation::Vertical, parent) + VerticalSplitter() + : Splitter(Gfx::Orientation::Vertical) { } }; @@ -80,8 +80,8 @@ public: virtual ~HorizontalSplitter() override {} private: - explicit HorizontalSplitter(Widget* parent = nullptr) - : Splitter(Gfx::Orientation::Horizontal, parent) + HorizontalSplitter() + : Splitter(Gfx::Orientation::Horizontal) { } }; diff --git a/Libraries/LibGUI/StackWidget.cpp b/Libraries/LibGUI/StackWidget.cpp index 2b33f187df..f3ac39070e 100644 --- a/Libraries/LibGUI/StackWidget.cpp +++ b/Libraries/LibGUI/StackWidget.cpp @@ -29,8 +29,7 @@ namespace GUI { -StackWidget::StackWidget(Widget* parent) - : Widget(parent) +StackWidget::StackWidget() { } diff --git a/Libraries/LibGUI/StackWidget.h b/Libraries/LibGUI/StackWidget.h index d8057c2a18..0d1d66b31f 100644 --- a/Libraries/LibGUI/StackWidget.h +++ b/Libraries/LibGUI/StackWidget.h @@ -42,7 +42,7 @@ public: Function<void(Widget*)> on_active_widget_change; protected: - explicit StackWidget(Widget* parent = nullptr); + StackWidget(); virtual void child_event(Core::ChildEvent&) override; virtual void resize_event(ResizeEvent&) override; diff --git a/Libraries/LibGUI/StatusBar.cpp b/Libraries/LibGUI/StatusBar.cpp index 8f9d41820a..9019816abb 100644 --- a/Libraries/LibGUI/StatusBar.cpp +++ b/Libraries/LibGUI/StatusBar.cpp @@ -34,13 +34,7 @@ namespace GUI { -StatusBar::StatusBar(Widget* parent) - : StatusBar(1, parent) -{ -} - -StatusBar::StatusBar(int label_count, Widget* parent) - : Widget(parent) +StatusBar::StatusBar(int label_count) { set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); set_preferred_size(0, 20); @@ -54,7 +48,7 @@ StatusBar::StatusBar(int label_count, Widget* parent) for (auto i = 0; i < label_count; i++) m_labels.append(create_label()); - m_corner = ResizeCorner::construct(this); + m_corner = add<ResizeCorner>(); } StatusBar::~StatusBar() @@ -63,7 +57,7 @@ StatusBar::~StatusBar() NonnullRefPtr<Label> StatusBar::create_label() { - auto label = Label::construct(this); + auto label = add<Label>(); label->set_frame_shadow(Gfx::FrameShadow::Sunken); label->set_frame_shape(Gfx::FrameShape::Panel); label->set_frame_thickness(1); diff --git a/Libraries/LibGUI/StatusBar.h b/Libraries/LibGUI/StatusBar.h index 70bfc88111..411f525856 100644 --- a/Libraries/LibGUI/StatusBar.h +++ b/Libraries/LibGUI/StatusBar.h @@ -41,8 +41,7 @@ public: void set_text(int index, const StringView&); protected: - explicit StatusBar(Widget* parent = nullptr); - explicit StatusBar(int label_count, Widget* parent = nullptr); + explicit StatusBar(int label_count = 1); virtual void paint_event(PaintEvent&) override; private: diff --git a/Libraries/LibGUI/TabWidget.cpp b/Libraries/LibGUI/TabWidget.cpp index e1ee40cbce..6a2d519421 100644 --- a/Libraries/LibGUI/TabWidget.cpp +++ b/Libraries/LibGUI/TabWidget.cpp @@ -33,8 +33,7 @@ namespace GUI { -TabWidget::TabWidget(Widget* parent) - : Widget(parent) +TabWidget::TabWidget() { } diff --git a/Libraries/LibGUI/TabWidget.h b/Libraries/LibGUI/TabWidget.h index 24d0583ee2..2b0fdcaa15 100644 --- a/Libraries/LibGUI/TabWidget.h +++ b/Libraries/LibGUI/TabWidget.h @@ -38,7 +38,6 @@ public: Bottom, }; - explicit TabWidget(Widget* parent = nullptr); virtual ~TabWidget() override; TabPosition tab_position() const { return m_tab_position; } @@ -56,6 +55,8 @@ public: void add_widget(const StringView&, Widget*); protected: + TabWidget(); + virtual void paint_event(PaintEvent&) override; virtual void child_event(Core::ChildEvent&) override; virtual void resize_event(ResizeEvent&) override; diff --git a/Libraries/LibGUI/TableView.cpp b/Libraries/LibGUI/TableView.cpp index 4eb8ca9c3b..3522f08464 100644 --- a/Libraries/LibGUI/TableView.cpp +++ b/Libraries/LibGUI/TableView.cpp @@ -38,8 +38,7 @@ namespace GUI { -TableView::TableView(Widget* parent) - : AbstractTableView(parent) +TableView::TableView() { set_background_role(ColorRole::Base); set_foreground_role(ColorRole::BaseText); diff --git a/Libraries/LibGUI/TableView.h b/Libraries/LibGUI/TableView.h index 28983a1565..76dcf565f6 100644 --- a/Libraries/LibGUI/TableView.h +++ b/Libraries/LibGUI/TableView.h @@ -36,7 +36,7 @@ public: virtual ~TableView() override; protected: - explicit TableView(Widget* parent = nullptr); + TableView(); virtual void paint_event(PaintEvent&) override; }; diff --git a/Libraries/LibGUI/TextBox.cpp b/Libraries/LibGUI/TextBox.cpp index 5e04fb71ce..2df42b73b1 100644 --- a/Libraries/LibGUI/TextBox.cpp +++ b/Libraries/LibGUI/TextBox.cpp @@ -28,8 +28,8 @@ namespace GUI { -TextBox::TextBox(Widget* parent) - : TextEditor(TextEditor::SingleLine, parent) +TextBox::TextBox() + : TextEditor(TextEditor::SingleLine) { } diff --git a/Libraries/LibGUI/TextBox.h b/Libraries/LibGUI/TextBox.h index c57d32d9fb..566c567a60 100644 --- a/Libraries/LibGUI/TextBox.h +++ b/Libraries/LibGUI/TextBox.h @@ -33,7 +33,7 @@ namespace GUI { class TextBox : public TextEditor { C_OBJECT(TextBox) public: - explicit TextBox(Widget* parent = nullptr); + TextBox(); virtual ~TextBox() override; }; diff --git a/Libraries/LibGUI/TextEditor.cpp b/Libraries/LibGUI/TextEditor.cpp index 736ac7ec0b..231266a5f6 100644 --- a/Libraries/LibGUI/TextEditor.cpp +++ b/Libraries/LibGUI/TextEditor.cpp @@ -49,14 +49,8 @@ namespace GUI { -TextEditor::TextEditor(Widget* parent) - : TextEditor(Type::MultiLine, parent) -{ -} - -TextEditor::TextEditor(Type type, Widget* parent) - : ScrollableWidget(parent) - , m_type(type) +TextEditor::TextEditor(Type type) + : m_type(type) { set_background_role(ColorRole::Base); set_foreground_role(ColorRole::BaseText); diff --git a/Libraries/LibGUI/TextEditor.h b/Libraries/LibGUI/TextEditor.h index db42b55998..35c1187f82 100644 --- a/Libraries/LibGUI/TextEditor.h +++ b/Libraries/LibGUI/TextEditor.h @@ -130,8 +130,7 @@ public: void set_syntax_highlighter(OwnPtr<SyntaxHighlighter>); protected: - explicit TextEditor(Widget* parent = nullptr); - explicit TextEditor(Type, Widget* parent = nullptr); + explicit TextEditor(Type = Type::MultiLine); virtual void did_change_font() override; virtual void paint_event(PaintEvent&) override; diff --git a/Libraries/LibGUI/ToolBar.cpp b/Libraries/LibGUI/ToolBar.cpp index e387963bb7..922f944954 100644 --- a/Libraries/LibGUI/ToolBar.cpp +++ b/Libraries/LibGUI/ToolBar.cpp @@ -34,14 +34,8 @@ namespace GUI { -ToolBar::ToolBar(Widget* parent) - : ToolBar(Orientation::Horizontal, 16, parent) -{ -} - -ToolBar::ToolBar(Orientation orientation, int button_size, Widget* parent) - : Widget(parent) - , m_button_size(button_size) +ToolBar::ToolBar(Orientation orientation, int button_size) + : m_button_size(button_size) { if (orientation == Orientation::Horizontal) { set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); @@ -87,8 +81,7 @@ void ToolBar::add_action(Action& action) class SeparatorWidget final : public Widget { C_OBJECT(SeparatorWidget) public: - SeparatorWidget(Widget* parent) - : Widget(parent) + SeparatorWidget() { set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); set_preferred_size(8, 22); @@ -109,7 +102,7 @@ void ToolBar::add_separator() { auto item = make<Item>(); item->type = Item::Type::Separator; - new SeparatorWidget(this); + add<SeparatorWidget>(); m_items.append(move(item)); } diff --git a/Libraries/LibGUI/ToolBar.h b/Libraries/LibGUI/ToolBar.h index 24c5950f9b..6601d1b2dd 100644 --- a/Libraries/LibGUI/ToolBar.h +++ b/Libraries/LibGUI/ToolBar.h @@ -43,8 +43,7 @@ public: void set_has_frame(bool has_frame) { m_has_frame = has_frame; } protected: - explicit ToolBar(Widget* parent = nullptr); - explicit ToolBar(Orientation, int button_size, Widget* parent = nullptr); + explicit ToolBar(Gfx::Orientation = Gfx::Orientation::Horizontal, int button_size = 16); virtual void paint_event(PaintEvent&) override; diff --git a/Libraries/LibGUI/TreeView.cpp b/Libraries/LibGUI/TreeView.cpp index 3264234382..407560a112 100644 --- a/Libraries/LibGUI/TreeView.cpp +++ b/Libraries/LibGUI/TreeView.cpp @@ -51,8 +51,7 @@ TreeView::MetadataForIndex& TreeView::ensure_metadata_for_index(const ModelIndex return new_metadata_ref; } -TreeView::TreeView(Widget* parent) - : AbstractTableView(parent) +TreeView::TreeView() { set_background_role(ColorRole::Base); set_foreground_role(ColorRole::BaseText); diff --git a/Libraries/LibGUI/TreeView.h b/Libraries/LibGUI/TreeView.h index 7a08bf9585..e5c94edcb9 100644 --- a/Libraries/LibGUI/TreeView.h +++ b/Libraries/LibGUI/TreeView.h @@ -41,7 +41,7 @@ public: virtual int item_count() const override; protected: - explicit TreeView(Widget* parent = nullptr); + TreeView(); virtual void paint_event(PaintEvent&) override; virtual void doubleclick_event(MouseEvent&) override; diff --git a/Libraries/LibGUI/Widget.cpp b/Libraries/LibGUI/Widget.cpp index e7ab4aa14a..b8142d1087 100644 --- a/Libraries/LibGUI/Widget.cpp +++ b/Libraries/LibGUI/Widget.cpp @@ -70,7 +70,7 @@ static HashMap<String, WidgetClassRegistration*>& widget_classes() return *map; } -WidgetClassRegistration::WidgetClassRegistration(const String& class_name, Function<NonnullRefPtr<Widget>(Widget*)> factory) +WidgetClassRegistration::WidgetClassRegistration(const String& class_name, Function<NonnullRefPtr<Widget>()> factory) : m_class_name(class_name) , m_factory(move(factory)) { @@ -93,8 +93,8 @@ const WidgetClassRegistration* WidgetClassRegistration::find(const String& class return widget_classes().get(class_name).value_or(nullptr); } -Widget::Widget(Widget* parent) - : Core::Object(parent, true) +Widget::Widget() + : Core::Object(nullptr, true) , m_background_role(Gfx::ColorRole::Window) , m_foreground_role(Gfx::ColorRole::WindowText) , m_font(Gfx::Font::default_font()) diff --git a/Libraries/LibGUI/Widget.h b/Libraries/LibGUI/Widget.h index 4cd76ef0fd..3de5ac95da 100644 --- a/Libraries/LibGUI/Widget.h +++ b/Libraries/LibGUI/Widget.h @@ -37,7 +37,7 @@ #define REGISTER_GWIDGET(class_name) \ extern WidgetClassRegistration registration_##class_name; \ - WidgetClassRegistration registration_##class_name(#class_name, [](Widget* parent) { return class_name::construct(parent); }); + WidgetClassRegistration registration_##class_name(#class_name, []() { return class_name::construct(); }); template<> inline bool Core::is<GUI::Widget>(const Core::Object& object) @@ -75,18 +75,18 @@ class WidgetClassRegistration { AK_MAKE_NONCOPYABLE(WidgetClassRegistration) AK_MAKE_NONMOVABLE(WidgetClassRegistration) public: - WidgetClassRegistration(const String& class_name, Function<NonnullRefPtr<Widget>(Widget*)> factory); + WidgetClassRegistration(const String& class_name, Function<NonnullRefPtr<Widget>()> factory); ~WidgetClassRegistration(); String class_name() const { return m_class_name; } - NonnullRefPtr<Widget> construct(Widget* parent) const { return m_factory(parent); } + NonnullRefPtr<Widget> construct() const { return m_factory(); } static void for_each(Function<void(const WidgetClassRegistration&)>); static const WidgetClassRegistration* find(const String& class_name); private: String m_class_name; - Function<NonnullRefPtr<Widget>(Widget*)> m_factory; + Function<NonnullRefPtr<Widget>()> m_factory; }; class Widget : public Core::Object { @@ -259,7 +259,7 @@ public: void set_palette(const Gfx::Palette&); protected: - explicit Widget(Widget* parent = nullptr); + Widget(); virtual void custom_layout() {} virtual void did_change_font() {} diff --git a/Libraries/LibHTML/DOM/HTMLInputElement.cpp b/Libraries/LibHTML/DOM/HTMLInputElement.cpp index 7b0b6ea14d..7c72fb1993 100644 --- a/Libraries/LibHTML/DOM/HTMLInputElement.cpp +++ b/Libraries/LibHTML/DOM/HTMLInputElement.cpp @@ -63,7 +63,7 @@ RefPtr<LayoutNode> HTMLInputElement::create_layout_node(const StyleProperties*) }; widget = button; } else { - auto text_box = GUI::TextBox::construct(&html_view); + auto text_box = html_view.add<GUI::TextBox>(); text_box->set_text(value()); text_box->on_change = [this] { auto& widget = to<LayoutWidget>(layout_node())->widget(); |