summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Applications/PaintBrush/ColorDialog.cpp12
-rw-r--r--Applications/PaintBrush/ColorDialog.h6
-rw-r--r--Applications/PaintBrush/PaletteWidget.cpp10
-rw-r--r--Applications/PaintBrush/PaletteWidget.h4
-rw-r--r--Applications/Taskbar/TaskbarWindow.cpp2
-rw-r--r--Libraries/LibGUI/GFilePicker.cpp2
-rw-r--r--Libraries/LibGUI/GFrame.h2
7 files changed, 21 insertions, 17 deletions
diff --git a/Applications/PaintBrush/ColorDialog.cpp b/Applications/PaintBrush/ColorDialog.cpp
index aef7778650..bf83a5c18f 100644
--- a/Applications/PaintBrush/ColorDialog.cpp
+++ b/Applications/PaintBrush/ColorDialog.cpp
@@ -35,9 +35,9 @@ void ColorDialog::build()
Red, Green, Blue
};
- auto* preview_widget = new GFrame(right_vertical_container);
- preview_widget->set_background_color(m_color);
- preview_widget->set_fill_with_background_color(true);
+ m_preview_widget = GFrame::construct(right_vertical_container);
+ m_preview_widget->set_background_color(m_color);
+ m_preview_widget->set_fill_with_background_color(true);
right_vertical_container->layout()->add_spacer();
auto* cancel_button = new GButton("Cancel", right_vertical_container);
cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
@@ -60,7 +60,7 @@ void ColorDialog::build()
spinbox->set_max(255);
spinbox->set_value(initial_value);
- spinbox->on_change = [=](auto value) {
+ spinbox->on_change = [this, component](auto value) {
if (component == Red)
m_color.set_red(value);
if (component == Green)
@@ -68,8 +68,8 @@ void ColorDialog::build()
if (component == Blue)
m_color.set_blue(value);
- preview_widget->set_background_color(m_color);
- preview_widget->update();
+ m_preview_widget->set_background_color(m_color);
+ m_preview_widget->update();
};
return spinbox;
};
diff --git a/Applications/PaintBrush/ColorDialog.h b/Applications/PaintBrush/ColorDialog.h
index d148ca8d2a..40ee1e3c76 100644
--- a/Applications/PaintBrush/ColorDialog.h
+++ b/Applications/PaintBrush/ColorDialog.h
@@ -2,16 +2,20 @@
#include <LibGUI/GDialog.h>
+class GFrame;
+
class ColorDialog final : public GDialog {
C_OBJECT(ColorDialog)
public:
- explicit ColorDialog(Color, CObject* parent = nullptr);
virtual ~ColorDialog() override;
Color color() const { return m_color; }
private:
+ explicit ColorDialog(Color, CObject* parent = nullptr);
+
void build();
Color m_color;
+ ObjectPtr<GFrame> m_preview_widget;
};
diff --git a/Applications/PaintBrush/PaletteWidget.cpp b/Applications/PaintBrush/PaletteWidget.cpp
index c90933a121..be2d442abe 100644
--- a/Applications/PaintBrush/PaletteWidget.cpp
+++ b/Applications/PaintBrush/PaletteWidget.cpp
@@ -22,9 +22,9 @@ public:
virtual void mousedown_event(GMouseEvent& event) override
{
if (event.modifiers() & KeyModifier::Mod_Ctrl && event.button() == GMouseButton::Left) {
- ColorDialog dialog(m_color, window());
- if (dialog.exec() == GDialog::ExecOK) {
- m_color = dialog.color();
+ auto dialog = ColorDialog::construct(m_color, window());
+ if (dialog->exec() == GDialog::ExecOK) {
+ m_color = dialog->color();
set_background_color(m_color);
update();
}
@@ -55,7 +55,7 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GWidget* parent)
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
set_preferred_size(0, 34);
- m_secondary_color_widget = new GFrame(this);
+ m_secondary_color_widget = GFrame::construct(this);
m_secondary_color_widget->set_frame_thickness(2);
m_secondary_color_widget->set_frame_shape(FrameShape::Container);
m_secondary_color_widget->set_frame_shadow(FrameShadow::Sunken);
@@ -63,7 +63,7 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GWidget* parent)
m_secondary_color_widget->set_fill_with_background_color(true);
set_secondary_color(paintable_widget.secondary_color());
- m_primary_color_widget = new GFrame(this);
+ m_primary_color_widget = GFrame::construct(this);
m_primary_color_widget->set_frame_thickness(2);
m_primary_color_widget->set_frame_shape(FrameShape::Container);
m_primary_color_widget->set_frame_shadow(FrameShadow::Sunken);
diff --git a/Applications/PaintBrush/PaletteWidget.h b/Applications/PaintBrush/PaletteWidget.h
index 22f176aace..e9e0c5ebbb 100644
--- a/Applications/PaintBrush/PaletteWidget.h
+++ b/Applications/PaintBrush/PaletteWidget.h
@@ -15,6 +15,6 @@ public:
private:
PaintableWidget& m_paintable_widget;
- GFrame* m_primary_color_widget { nullptr };
- GFrame* m_secondary_color_widget { nullptr };
+ ObjectPtr<GFrame> m_primary_color_widget;
+ ObjectPtr<GFrame> m_secondary_color_widget;
};
diff --git a/Applications/Taskbar/TaskbarWindow.cpp b/Applications/Taskbar/TaskbarWindow.cpp
index c39ce4938f..f4492650f3 100644
--- a/Applications/Taskbar/TaskbarWindow.cpp
+++ b/Applications/Taskbar/TaskbarWindow.cpp
@@ -21,7 +21,7 @@ TaskbarWindow::TaskbarWindow()
GDesktop::the().on_rect_change = [this](const Rect& rect) { on_screen_rect_change(rect); };
- auto* widget = new GFrame;
+ auto widget = GFrame::construct();
widget->set_fill_with_background_color(true);
widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
widget->layout()->set_margins({ 3, 2, 3, 2 });
diff --git a/Libraries/LibGUI/GFilePicker.cpp b/Libraries/LibGUI/GFilePicker.cpp
index d4ebc80320..5e18087fe4 100644
--- a/Libraries/LibGUI/GFilePicker.cpp
+++ b/Libraries/LibGUI/GFilePicker.cpp
@@ -192,7 +192,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& file_name, const StringVie
}
};
- auto* preview_container = new GFrame(horizontal_container);
+ auto preview_container = GFrame::construct(horizontal_container);
preview_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
preview_container->set_preferred_size(180, 0);
preview_container->set_frame_shape(FrameShape::Container);
diff --git a/Libraries/LibGUI/GFrame.h b/Libraries/LibGUI/GFrame.h
index 7ce5c0ac1d..8cfbca7ee6 100644
--- a/Libraries/LibGUI/GFrame.h
+++ b/Libraries/LibGUI/GFrame.h
@@ -6,7 +6,6 @@
class GFrame : public GWidget {
C_OBJECT(GFrame)
public:
- explicit GFrame(GWidget* parent = nullptr);
virtual ~GFrame() override;
int frame_thickness() const { return m_thickness; }
@@ -22,6 +21,7 @@ public:
Rect frame_inner_rect() const { return frame_inner_rect_for_size(size()); }
protected:
+ explicit GFrame(GWidget* parent = nullptr);
void paint_event(GPaintEvent&) override;
private: