1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 11:07:46 +00:00

Applications: Use default constructors/destructors

https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules

"The compiler is more likely to get the default semantics right and
you cannot implement these functions better than the compiler."
This commit is contained in:
Lenny Maiorani 2022-02-10 12:28:48 -07:00 committed by Linus Groh
parent 6be75bd5e4
commit 160bda7228
195 changed files with 335 additions and 638 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -29,7 +30,7 @@ public:
static ErrorOr<NonnullRefPtr<Layer>> try_create_with_bitmap(Image&, NonnullRefPtr<Gfx::Bitmap>, String name);
static ErrorOr<NonnullRefPtr<Layer>> try_create_snapshot(Image&, Layer const&);
~Layer() { }
~Layer() = default;
Gfx::IntPoint const& location() const { return m_location; }
void set_location(Gfx::IntPoint const& location) { m_location = location; }

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -65,10 +66,6 @@ LayerPropertiesWidget::LayerPropertiesWidget()
};
}
LayerPropertiesWidget::~LayerPropertiesWidget()
{
}
void LayerPropertiesWidget::set_layer(Layer* layer)
{
if (m_layer == layer)

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -16,7 +17,7 @@ class LayerPropertiesWidget final : public GUI::Widget {
C_OBJECT(LayerPropertiesWidget);
public:
virtual ~LayerPropertiesWidget() override;
virtual ~LayerPropertiesWidget() override = default;
void set_layer(Layer*);

View file

@ -2,6 +2,7 @@
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Felix Rauch <noreply@felixrau.ch>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -25,9 +26,7 @@ class ColorWidget : public GUI::Frame {
C_OBJECT(ColorWidget);
public:
virtual ~ColorWidget() override
{
}
virtual ~ColorWidget() override = default;
virtual Color color() { return m_color; }
@ -66,7 +65,7 @@ class SelectedColorWidget : public GUI::Frame {
C_OBJECT(SelectedColorWidget);
public:
virtual ~SelectedColorWidget() override { }
virtual ~SelectedColorWidget() override = default;
virtual void mousedown_event(GUI::MouseEvent& event) override
{
@ -162,10 +161,6 @@ void PaletteWidget::set_image_editor(ImageEditor* editor)
};
}
PaletteWidget::~PaletteWidget()
{
}
void PaletteWidget::set_primary_color(Color color)
{
if (m_editor)

View file

@ -2,6 +2,7 @@
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Felix Rauch <noreply@felixrau.ch>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -21,7 +22,7 @@ class PaletteWidget final : public GUI::Frame {
C_OBJECT(PaletteWidget);
public:
virtual ~PaletteWidget() override;
virtual ~PaletteWidget() override = default;
void set_primary_color(Color);
void set_secondary_color(Color);

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Ben Jilks <benjyjilks@gmail.com>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -42,9 +43,4 @@ void ToolPropertiesWidget::set_active_tool(Tool* tool)
m_tool_widget_stack->set_active_widget(m_active_tool_widget);
}
ToolPropertiesWidget::~ToolPropertiesWidget()
{
}
}

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Ben Jilks <benjyjilks@gmail.com>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -19,7 +20,7 @@ class ToolPropertiesWidget final : public GUI::Widget {
C_OBJECT(ToolPropertiesWidget);
public:
virtual ~ToolPropertiesWidget() override;
virtual ~ToolPropertiesWidget() override = default;
void set_active_tool(Tool*);

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -45,10 +46,6 @@ ToolboxWidget::ToolboxWidget()
setup_tools();
}
ToolboxWidget::~ToolboxWidget()
{
}
void ToolboxWidget::setup_tools()
{
auto add_tool = [&](String name, StringView icon_name, GUI::Shortcut const& shortcut, NonnullOwnPtr<Tool> tool) {

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,7 +19,7 @@ class ToolboxWidget final : public GUI::Widget {
C_OBJECT(ToolboxWidget);
public:
virtual ~ToolboxWidget() override;
virtual ~ToolboxWidget() override = default;
Function<void(Tool*)> on_tool_selection;

View file

@ -18,14 +18,6 @@
namespace PixelPaint {
BrushTool::BrushTool()
{
}
BrushTool::~BrushTool()
{
}
void BrushTool::on_mousedown(Layer* layer, MouseEvent& event)
{
if (!layer)

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2020, Ben Jilks <benjyjilks@gmail.com>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -13,8 +14,8 @@ namespace PixelPaint {
class BrushTool : public Tool {
public:
BrushTool();
virtual ~BrushTool() override;
BrushTool() = default;
virtual ~BrushTool() override = default;
virtual void on_mousedown(Layer*, MouseEvent&) override;
virtual void on_mousemove(Layer*, MouseEvent&) override;

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -23,10 +24,6 @@ BucketTool::BucketTool()
m_cursor = Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/bucket.png").release_value_but_fixme_should_propagate_errors();
}
BucketTool::~BucketTool()
{
}
static float color_distance_squared(Gfx::Color const& lhs, Gfx::Color const& rhs)
{
int a = rhs.red() - lhs.red();

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -13,7 +14,7 @@ namespace PixelPaint {
class BucketTool final : public Tool {
public:
BucketTool();
virtual ~BucketTool() override;
virtual ~BucketTool() override = default;
virtual void on_mousedown(Layer*, MouseEvent&) override;
virtual GUI::Widget* get_properties_widget() override;

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -20,14 +21,6 @@
namespace PixelPaint {
EllipseTool::EllipseTool()
{
}
EllipseTool::~EllipseTool()
{
}
void EllipseTool::draw_using(GUI::Painter& painter, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position, int thickness)
{
Gfx::IntRect ellipse_intersecting_rect;

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -9,14 +10,15 @@
#include "Tool.h"
#include <LibGUI/Forward.h>
#include <LibGUI/TextBox.h>
#include <LibGfx/Point.h>
namespace PixelPaint {
class EllipseTool final : public Tool {
public:
EllipseTool();
virtual ~EllipseTool() override;
EllipseTool() = default;
virtual ~EllipseTool() override = default;
virtual void on_mousedown(Layer*, MouseEvent&) override;
virtual void on_mousemove(Layer*, MouseEvent&) override;

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -20,14 +21,6 @@
namespace PixelPaint {
EraseTool::EraseTool()
{
}
EraseTool::~EraseTool()
{
}
Color EraseTool::color_for(GUI::MouseEvent const&)
{
if (m_use_secondary_color)

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -16,8 +17,8 @@ namespace PixelPaint {
class EraseTool final : public BrushTool {
public:
EraseTool();
virtual ~EraseTool() override;
EraseTool() = default;
virtual ~EraseTool() override = default;
virtual GUI::Widget* get_properties_widget() override;

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -15,14 +16,6 @@
namespace PixelPaint {
GuideTool::GuideTool()
{
}
GuideTool::~GuideTool()
{
}
RefPtr<Guide> GuideTool::closest_guide(const Gfx::IntPoint& point)
{
auto guides = editor()->guides();

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -9,14 +10,15 @@
#include "../Guide.h"
#include "Tool.h"
#include <AK/RefPtr.h>
#include <LibGUI/Menu.h>
namespace PixelPaint {
class GuideTool final : public Tool {
public:
GuideTool();
GuideTool() = default;
virtual ~GuideTool() override;
virtual ~GuideTool() override = default;
virtual void on_mousedown(Layer*, MouseEvent&) override;
virtual void on_mousemove(Layer*, MouseEvent&) override;

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -31,14 +32,6 @@ static Gfx::IntPoint constrain_line_angle(Gfx::IntPoint const& start_pos, Gfx::I
start_pos.y() + (int)(AK::sin(constrained_angle) * line_length) };
}
LineTool::LineTool()
{
}
LineTool::~LineTool()
{
}
void LineTool::on_mousedown(Layer* layer, MouseEvent& event)
{
if (!layer)

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -14,8 +15,8 @@ namespace PixelPaint {
class LineTool final : public Tool {
public:
LineTool();
virtual ~LineTool() override;
LineTool() = default;
virtual ~LineTool() override = default;
virtual void on_mousedown(Layer*, MouseEvent&) override;
virtual void on_mousemove(Layer*, MouseEvent&) override;

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -14,14 +15,6 @@
namespace PixelPaint {
MoveTool::MoveTool()
{
}
MoveTool::~MoveTool()
{
}
void MoveTool::on_mousedown(Layer* layer, MouseEvent& event)
{
if (event.image_event().button() == GUI::MouseButton::Secondary) {

View file

@ -1,19 +1,21 @@
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "../Layer.h"
#include "Tool.h"
namespace PixelPaint {
class MoveTool final : public Tool {
public:
MoveTool();
virtual ~MoveTool() override;
MoveTool() = default;
virtual ~MoveTool() override = default;
virtual void on_mousedown(Layer*, MouseEvent&) override;
virtual void on_mousemove(Layer*, MouseEvent&) override;

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -22,10 +23,6 @@ PenTool::PenTool()
set_size(1);
}
PenTool::~PenTool()
{
}
void PenTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point)
{
GUI::Painter painter(bitmap);

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -16,7 +17,7 @@ namespace PixelPaint {
class PenTool final : public BrushTool {
public:
PenTool();
virtual ~PenTool() override;
virtual ~PenTool() override = default;
virtual GUI::Widget* get_properties_widget() override;

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -13,14 +14,6 @@
namespace PixelPaint {
PickerTool::PickerTool()
{
}
PickerTool::~PickerTool()
{
}
void PickerTool::on_mousedown(Layer* layer, MouseEvent& event)
{
auto& position = event.layer_event().position();

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -13,8 +14,8 @@ namespace PixelPaint {
class PickerTool final : public Tool {
public:
PickerTool();
virtual ~PickerTool() override;
PickerTool() = default;
virtual ~PickerTool() override = default;
virtual void on_mousedown(Layer*, MouseEvent&) override;

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -18,14 +19,6 @@
namespace PixelPaint {
RectangleSelectTool::RectangleSelectTool()
{
}
RectangleSelectTool::~RectangleSelectTool()
{
}
void RectangleSelectTool::on_mousedown(Layer*, MouseEvent& event)
{
auto& image_event = event.image_event();

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -16,8 +17,8 @@ namespace PixelPaint {
class RectangleSelectTool final : public Tool {
public:
RectangleSelectTool();
virtual ~RectangleSelectTool();
RectangleSelectTool() = default;
virtual ~RectangleSelectTool() = default;
virtual void on_mousedown(Layer*, MouseEvent& event) override;
virtual void on_mousemove(Layer*, MouseEvent& event) override;

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -20,14 +21,6 @@
namespace PixelPaint {
RectangleTool::RectangleTool()
{
}
RectangleTool::~RectangleTool()
{
}
void RectangleTool::draw_using(GUI::Painter& painter, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position, int thickness)
{
Gfx::IntRect rect;

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -15,8 +16,8 @@ namespace PixelPaint {
class RectangleTool final : public Tool {
public:
RectangleTool();
virtual ~RectangleTool() override;
RectangleTool() = default;
virtual ~RectangleTool() override = default;
virtual void on_mousedown(Layer*, MouseEvent&) override;
virtual void on_mousemove(Layer*, MouseEvent&) override;

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -28,10 +29,6 @@ SprayTool::SprayTool()
m_timer->set_interval(200);
}
SprayTool::~SprayTool()
{
}
static double nrand()
{
return double(rand()) / double(RAND_MAX);

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -16,7 +17,7 @@ namespace PixelPaint {
class SprayTool final : public Tool {
public:
SprayTool();
virtual ~SprayTool() override;
virtual ~SprayTool() override = default;
virtual void on_mousedown(Layer*, MouseEvent&) override;
virtual void on_mouseup(Layer*, MouseEvent&) override;

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -11,14 +12,6 @@
namespace PixelPaint {
Tool::Tool()
{
}
Tool::~Tool()
{
}
void Tool::setup(ImageEditor& editor)
{
m_editor = editor;

View file

@ -1,6 +1,7 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -8,6 +9,7 @@
#pragma once
#include <AK/Variant.h>
#include <LibGUI/Action.h>
#include <LibGUI/Event.h>
#include <LibGUI/Forward.h>
#include <LibGUI/ValueSlider.h>
@ -20,7 +22,7 @@ class Layer;
class Tool {
public:
virtual ~Tool();
virtual ~Tool() = default;
class MouseEvent {
public:
@ -73,7 +75,7 @@ public:
void set_action(GUI::Action*);
protected:
Tool();
Tool() = default;
WeakPtr<ImageEditor> m_editor;
RefPtr<GUI::Action> m_action;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, the SerenityOS developers.
* Copyright (c) 2021-2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -12,14 +12,6 @@
namespace PixelPaint {
ZoomTool::ZoomTool()
{
}
ZoomTool::~ZoomTool()
{
}
void ZoomTool::on_mousedown(Layer*, MouseEvent& event)
{
auto& raw_event = event.raw_event();

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, the SerenityOS developers.
* Copyright (c) 2021-2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -14,8 +14,8 @@ namespace PixelPaint {
class ZoomTool final : public Tool {
public:
ZoomTool();
virtual ~ZoomTool() override;
ZoomTool() = default;
virtual ~ZoomTool() override = default;
virtual void on_mousedown(Layer*, MouseEvent&) override;
virtual GUI::Widget* get_properties_widget() override;