mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
LibGUI: Convert GFrame to ObjectPtr
This commit is contained in:
parent
7b5342b2e3
commit
55a6e4ac0b
7 changed files with 21 additions and 17 deletions
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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 });
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue