From 29e80178a8b16fe80b489b886d8cd7b6df5f8999 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 11 Jun 2021 13:27:47 +0200 Subject: [PATCH] PixelPaint: Convert to east-const style --- .../Applications/PixelPaint/BrushTool.cpp | 4 ++-- Userland/Applications/PixelPaint/BrushTool.h | 4 ++-- .../Applications/PixelPaint/BucketTool.cpp | 4 ++-- .../PixelPaint/CreateNewImageDialog.h | 4 ++-- .../PixelPaint/CreateNewLayerDialog.cpp | 2 +- .../PixelPaint/CreateNewLayerDialog.h | 6 ++--- .../Applications/PixelPaint/EllipseTool.cpp | 4 ++-- .../Applications/PixelPaint/EllipseTool.h | 4 ++-- .../Applications/PixelPaint/EraseTool.cpp | 2 +- Userland/Applications/PixelPaint/EraseTool.h | 2 +- .../Applications/PixelPaint/FilterParams.h | 2 +- Userland/Applications/PixelPaint/Image.h | 8 +++---- .../Applications/PixelPaint/ImageEditor.cpp | 22 ++++++++--------- .../Applications/PixelPaint/ImageEditor.h | 24 +++++++++---------- Userland/Applications/PixelPaint/Layer.cpp | 12 +++++----- Userland/Applications/PixelPaint/Layer.h | 20 ++++++++-------- .../PixelPaint/LayerListWidget.cpp | 2 +- .../Applications/PixelPaint/LayerListWidget.h | 2 +- Userland/Applications/PixelPaint/LineTool.cpp | 4 ++-- Userland/Applications/PixelPaint/LineTool.h | 2 +- .../Applications/PixelPaint/RectangleTool.cpp | 4 ++-- .../Applications/PixelPaint/RectangleTool.h | 4 ++-- Userland/Applications/PixelPaint/Tool.h | 2 +- 23 files changed, 72 insertions(+), 72 deletions(-) diff --git a/Userland/Applications/PixelPaint/BrushTool.cpp b/Userland/Applications/PixelPaint/BrushTool.cpp index 6398f92582d..ce8088fd27a 100644 --- a/Userland/Applications/PixelPaint/BrushTool.cpp +++ b/Userland/Applications/PixelPaint/BrushTool.cpp @@ -52,7 +52,7 @@ void BrushTool::on_mouseup(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) } } -void BrushTool::draw_point(Gfx::Bitmap& bitmap, const Gfx::Color& color, const Gfx::IntPoint& point) +void BrushTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) { for (int y = point.y() - m_size; y < point.y() + m_size; y++) { for (int x = point.x() - m_size; x < point.x() + m_size; x++) { @@ -70,7 +70,7 @@ void BrushTool::draw_point(Gfx::Bitmap& bitmap, const Gfx::Color& color, const G } } -void BrushTool::draw_line(Gfx::Bitmap& bitmap, const Gfx::Color& color, const Gfx::IntPoint& start, const Gfx::IntPoint& end) +void BrushTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) { int length_x = end.x() - start.x(); int length_y = end.y() - start.y(); diff --git a/Userland/Applications/PixelPaint/BrushTool.h b/Userland/Applications/PixelPaint/BrushTool.h index 51a3315174c..bb96b93f38a 100644 --- a/Userland/Applications/PixelPaint/BrushTool.h +++ b/Userland/Applications/PixelPaint/BrushTool.h @@ -27,8 +27,8 @@ private: bool m_was_drawing { false }; Gfx::IntPoint m_last_position; - void draw_line(Gfx::Bitmap& bitmap, const Gfx::Color& color, const Gfx::IntPoint& start, const Gfx::IntPoint& end); - void draw_point(Gfx::Bitmap& bitmap, const Gfx::Color& color, const Gfx::IntPoint& point); + void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end); + void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point); }; } diff --git a/Userland/Applications/PixelPaint/BucketTool.cpp b/Userland/Applications/PixelPaint/BucketTool.cpp index 277f3e2a6a1..2e49e257a1c 100644 --- a/Userland/Applications/PixelPaint/BucketTool.cpp +++ b/Userland/Applications/PixelPaint/BucketTool.cpp @@ -25,7 +25,7 @@ BucketTool::~BucketTool() { } -static float color_distance_squared(const Gfx::Color& lhs, const Gfx::Color& rhs) +static float color_distance_squared(Gfx::Color const& lhs, Gfx::Color const& rhs) { int a = rhs.red() - lhs.red(); int b = rhs.green() - lhs.green(); @@ -33,7 +33,7 @@ static float color_distance_squared(const Gfx::Color& lhs, const Gfx::Color& rhs return (a * a + b * b + c * c) / (255.0f * 255.0f); } -static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::IntPoint& start_position, Color target_color, Color fill_color, int threshold) +static void flood_fill(Gfx::Bitmap& bitmap, Gfx::IntPoint const& start_position, Color target_color, Color fill_color, int threshold) { VERIFY(bitmap.bpp() == 32); diff --git a/Userland/Applications/PixelPaint/CreateNewImageDialog.h b/Userland/Applications/PixelPaint/CreateNewImageDialog.h index d12c3f131c8..8025950a829 100644 --- a/Userland/Applications/PixelPaint/CreateNewImageDialog.h +++ b/Userland/Applications/PixelPaint/CreateNewImageDialog.h @@ -14,8 +14,8 @@ class CreateNewImageDialog final : public GUI::Dialog { C_OBJECT(CreateNewImageDialog) public: - const Gfx::IntSize& image_size() const { return m_image_size; } - const String& image_name() const { return m_image_name; } + Gfx::IntSize const& image_size() const { return m_image_size; } + String const& image_name() const { return m_image_name; } private: CreateNewImageDialog(GUI::Window* parent_window); diff --git a/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp b/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp index 3e3ac7cd257..f6df5fa373c 100644 --- a/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp +++ b/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp @@ -13,7 +13,7 @@ namespace PixelPaint { -CreateNewLayerDialog::CreateNewLayerDialog(const Gfx::IntSize& suggested_size, GUI::Window* parent_window) +CreateNewLayerDialog::CreateNewLayerDialog(Gfx::IntSize const& suggested_size, GUI::Window* parent_window) : Dialog(parent_window) { set_title("Create new layer"); diff --git a/Userland/Applications/PixelPaint/CreateNewLayerDialog.h b/Userland/Applications/PixelPaint/CreateNewLayerDialog.h index baf9995e007..f3f7853610b 100644 --- a/Userland/Applications/PixelPaint/CreateNewLayerDialog.h +++ b/Userland/Applications/PixelPaint/CreateNewLayerDialog.h @@ -14,11 +14,11 @@ class CreateNewLayerDialog final : public GUI::Dialog { C_OBJECT(CreateNewLayerDialog); public: - const Gfx::IntSize& layer_size() const { return m_layer_size; } - const String& layer_name() const { return m_layer_name; } + Gfx::IntSize const& layer_size() const { return m_layer_size; } + String const& layer_name() const { return m_layer_name; } private: - CreateNewLayerDialog(const Gfx::IntSize& suggested_size, GUI::Window* parent_window); + CreateNewLayerDialog(Gfx::IntSize const& suggested_size, GUI::Window* parent_window); Gfx::IntSize m_layer_size; String m_layer_name; diff --git a/Userland/Applications/PixelPaint/EllipseTool.cpp b/Userland/Applications/PixelPaint/EllipseTool.cpp index f485adaf1f4..7d9ccbf336c 100644 --- a/Userland/Applications/PixelPaint/EllipseTool.cpp +++ b/Userland/Applications/PixelPaint/EllipseTool.cpp @@ -23,7 +23,7 @@ EllipseTool::~EllipseTool() { } -void EllipseTool::draw_using(GUI::Painter& painter, const Gfx::IntRect& ellipse_intersecting_rect) +void EllipseTool::draw_using(GUI::Painter& painter, Gfx::IntRect const& ellipse_intersecting_rect) { switch (m_mode) { case Mode::Outline: @@ -71,7 +71,7 @@ void EllipseTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) m_editor->update(); } -void EllipseTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event) +void EllipseTool::on_second_paint(Layer const& layer, GUI::PaintEvent& event) { if (m_drawing_button == GUI::MouseButton::None) return; diff --git a/Userland/Applications/PixelPaint/EllipseTool.h b/Userland/Applications/PixelPaint/EllipseTool.h index 3b295839c59..63659c34429 100644 --- a/Userland/Applications/PixelPaint/EllipseTool.h +++ b/Userland/Applications/PixelPaint/EllipseTool.h @@ -21,7 +21,7 @@ public: virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_tool_button_contextmenu(GUI::ContextMenuEvent&) override; - virtual void on_second_paint(const Layer&, GUI::PaintEvent&) override; + virtual void on_second_paint(Layer const&, GUI::PaintEvent&) override; virtual void on_keydown(GUI::KeyEvent&) override; private: @@ -30,7 +30,7 @@ private: Fill, }; - void draw_using(GUI::Painter&, const Gfx::IntRect&); + void draw_using(GUI::Painter&, Gfx::IntRect const&); GUI::MouseButton m_drawing_button { GUI::MouseButton::None }; Gfx::IntPoint m_ellipse_start_position; diff --git a/Userland/Applications/PixelPaint/EraseTool.cpp b/Userland/Applications/PixelPaint/EraseTool.cpp index 69b05ad3151..67da2de5552 100644 --- a/Userland/Applications/PixelPaint/EraseTool.cpp +++ b/Userland/Applications/PixelPaint/EraseTool.cpp @@ -22,7 +22,7 @@ EraseTool::~EraseTool() { } -Gfx::IntRect EraseTool::build_rect(const Gfx::IntPoint& pos, const Gfx::IntRect& widget_rect) +Gfx::IntRect EraseTool::build_rect(Gfx::IntPoint const& pos, Gfx::IntRect const& widget_rect) { const int base_eraser_size = 10; const int eraser_size = (base_eraser_size * m_thickness); diff --git a/Userland/Applications/PixelPaint/EraseTool.h b/Userland/Applications/PixelPaint/EraseTool.h index 4c5cb3f2729..80472ddf654 100644 --- a/Userland/Applications/PixelPaint/EraseTool.h +++ b/Userland/Applications/PixelPaint/EraseTool.h @@ -25,7 +25,7 @@ public: private: Gfx::Color get_color() const; - Gfx::IntRect build_rect(const Gfx::IntPoint& pos, const Gfx::IntRect& widget_rect); + Gfx::IntRect build_rect(Gfx::IntPoint const& pos, Gfx::IntRect const& widget_rect); RefPtr m_context_menu; bool m_use_secondary_color { false }; diff --git a/Userland/Applications/PixelPaint/FilterParams.h b/Userland/Applications/PixelPaint/FilterParams.h index 7acb1eb5fc5..6861665d3a1 100644 --- a/Userland/Applications/PixelPaint/FilterParams.h +++ b/Userland/Applications/PixelPaint/FilterParams.h @@ -31,7 +31,7 @@ class GenericConvolutionFilterInputDialog : public GUI::Dialog { C_OBJECT(GenericConvolutionFilterInputDialog); public: - const Matrix& matrix() const { return m_matrix; } + Matrix const& matrix() const { return m_matrix; } bool should_wrap() const { return m_should_wrap; } private: diff --git a/Userland/Applications/PixelPaint/Image.h b/Userland/Applications/PixelPaint/Image.h index b75cb106b14..5aaebb1c05b 100644 --- a/Userland/Applications/PixelPaint/Image.h +++ b/Userland/Applications/PixelPaint/Image.h @@ -41,10 +41,10 @@ public: static RefPtr create_from_bitmap(RefPtr bitmap); size_t layer_count() const { return m_layers.size(); } - const Layer& layer(size_t index) const { return m_layers.at(index); } + Layer const& layer(size_t index) const { return m_layers.at(index); } Layer& layer(size_t index) { return m_layers.at(index); } - const Gfx::IntSize& size() const { return m_size; } + Gfx::IntSize const& size() const { return m_size; } Gfx::IntRect rect() const { return { {}, m_size }; } void add_layer(NonnullRefPtr); @@ -70,10 +70,10 @@ public: void layer_did_modify_bitmap(Badge, Layer const&); void layer_did_modify_properties(Badge, Layer const&); - size_t index_of(const Layer&) const; + size_t index_of(Layer const&) const; private: - explicit Image(const Gfx::IntSize&); + explicit Image(Gfx::IntSize const&); static RefPtr create_from_pixel_paint_file(String const& file_path); diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 9871fd83358..58a1da317b7 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -97,12 +97,12 @@ void ImageEditor::paint_event(GUI::PaintEvent& event) } } -Gfx::FloatRect ImageEditor::layer_rect_to_editor_rect(const Layer& layer, const Gfx::IntRect& layer_rect) const +Gfx::FloatRect ImageEditor::layer_rect_to_editor_rect(Layer const& layer, Gfx::IntRect const& layer_rect) const { return image_rect_to_editor_rect(layer_rect.translated(layer.location())); } -Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(const Gfx::IntRect& image_rect) const +Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(Gfx::IntRect const& image_rect) const { Gfx::FloatRect editor_rect; editor_rect.set_location(image_position_to_editor_position(image_rect.location())); @@ -111,7 +111,7 @@ Gfx::FloatRect ImageEditor::image_rect_to_editor_rect(const Gfx::IntRect& image_ return editor_rect; } -Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(const Gfx::IntRect& editor_rect) const +Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(Gfx::IntRect const& editor_rect) const { Gfx::FloatRect image_rect; image_rect.set_location(editor_position_to_image_position(editor_rect.location())); @@ -120,12 +120,12 @@ Gfx::FloatRect ImageEditor::editor_rect_to_image_rect(const Gfx::IntRect& editor return image_rect; } -Gfx::FloatPoint ImageEditor::layer_position_to_editor_position(const Layer& layer, const Gfx::IntPoint& layer_position) const +Gfx::FloatPoint ImageEditor::layer_position_to_editor_position(Layer const& layer, Gfx::IntPoint const& layer_position) const { return image_position_to_editor_position(layer_position.translated(layer.location())); } -Gfx::FloatPoint ImageEditor::image_position_to_editor_position(const Gfx::IntPoint& image_position) const +Gfx::FloatPoint ImageEditor::image_position_to_editor_position(Gfx::IntPoint const& image_position) const { Gfx::FloatPoint editor_position; editor_position.set_x(m_editor_image_rect.x() + ((float)image_position.x() * m_scale)); @@ -133,7 +133,7 @@ Gfx::FloatPoint ImageEditor::image_position_to_editor_position(const Gfx::IntPoi return editor_position; } -Gfx::FloatPoint ImageEditor::editor_position_to_image_position(const Gfx::IntPoint& editor_position) const +Gfx::FloatPoint ImageEditor::editor_position_to_image_position(Gfx::IntPoint const& editor_position) const { Gfx::FloatPoint image_position; image_position.set_x(((float)editor_position.x() - m_editor_image_rect.x()) / m_scale); @@ -147,7 +147,7 @@ void ImageEditor::second_paint_event(GUI::PaintEvent& event) m_active_tool->on_second_paint(*m_active_layer, event); } -GUI::MouseEvent ImageEditor::event_with_pan_and_scale_applied(const GUI::MouseEvent& event) const +GUI::MouseEvent ImageEditor::event_with_pan_and_scale_applied(GUI::MouseEvent const& event) const { auto image_position = editor_position_to_image_position(event.position()); return { @@ -160,7 +160,7 @@ GUI::MouseEvent ImageEditor::event_with_pan_and_scale_applied(const GUI::MouseEv }; } -GUI::MouseEvent ImageEditor::event_adjusted_for_layer(const GUI::MouseEvent& event, const Layer& layer) const +GUI::MouseEvent ImageEditor::event_adjusted_for_layer(GUI::MouseEvent const& event, Layer const& layer) const { auto image_position = editor_position_to_image_position(event.position()); image_position.translate_by(-layer.location().x(), -layer.location().y()); @@ -309,7 +309,7 @@ Color ImageEditor::color_for(GUI::MouseButton button) const VERIFY_NOT_REACHED(); } -Color ImageEditor::color_for(const GUI::MouseEvent& event) const +Color ImageEditor::color_for(GUI::MouseEvent const& event) const { if (event.buttons() & GUI::MouseButton::Left) return m_primary_color; @@ -336,7 +336,7 @@ void ImageEditor::set_secondary_color(Color color) on_secondary_color_change(color); } -Layer* ImageEditor::layer_at_editor_position(const Gfx::IntPoint& editor_position) +Layer* ImageEditor::layer_at_editor_position(Gfx::IntPoint const& editor_position) { if (!m_image) return nullptr; @@ -360,7 +360,7 @@ void ImageEditor::clamped_scale(float scale_delta) m_scale = 100.0f; } -void ImageEditor::scale_centered_on_position(const Gfx::IntPoint& position, float scale_delta) +void ImageEditor::scale_centered_on_position(Gfx::IntPoint const& position, float scale_delta) { auto old_scale = m_scale; clamped_scale(scale_delta); diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h index b4d2f5f438f..9606402f5e9 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.h +++ b/Userland/Applications/PixelPaint/ImageEditor.h @@ -24,7 +24,7 @@ class ImageEditor final public: virtual ~ImageEditor() override; - const Image* image() const { return m_image; } + Image const* image() const { return m_image; } Image* image() { return m_image; } void set_image(RefPtr); @@ -41,9 +41,9 @@ public: void layers_did_change(); - Layer* layer_at_editor_position(const Gfx::IntPoint&); + Layer* layer_at_editor_position(Gfx::IntPoint const&); - void scale_centered_on_position(const Gfx::IntPoint&, float); + void scale_centered_on_position(Gfx::IntPoint const&, float); void reset_scale_and_position(); void scale_by(float); @@ -53,7 +53,7 @@ public: Color secondary_color() const { return m_secondary_color; } void set_secondary_color(Color); - Color color_for(const GUI::MouseEvent&) const; + Color color_for(GUI::MouseEvent const&) const; Color color_for(GUI::MouseButton) const; Function on_primary_color_change; @@ -61,12 +61,12 @@ public: Function on_active_layer_change; - Gfx::FloatRect layer_rect_to_editor_rect(const Layer&, const Gfx::IntRect&) const; - Gfx::FloatRect image_rect_to_editor_rect(const Gfx::IntRect&) const; - Gfx::FloatRect editor_rect_to_image_rect(const Gfx::IntRect&) const; - Gfx::FloatPoint layer_position_to_editor_position(const Layer&, const Gfx::IntPoint&) const; - Gfx::FloatPoint image_position_to_editor_position(const Gfx::IntPoint&) const; - Gfx::FloatPoint editor_position_to_image_position(const Gfx::IntPoint&) const; + Gfx::FloatRect layer_rect_to_editor_rect(Layer const&, Gfx::IntRect const&) const; + Gfx::FloatRect image_rect_to_editor_rect(Gfx::IntRect const&) const; + Gfx::FloatRect editor_rect_to_image_rect(Gfx::IntRect const&) const; + Gfx::FloatPoint layer_position_to_editor_position(Layer const&, Gfx::IntPoint const&) const; + Gfx::FloatPoint image_position_to_editor_position(Gfx::IntPoint const&) const; + Gfx::FloatPoint editor_position_to_image_position(Gfx::IntPoint const&) const; private: ImageEditor(); @@ -85,8 +85,8 @@ private: virtual void image_did_change() override; virtual void image_select_layer(Layer*) override; - GUI::MouseEvent event_adjusted_for_layer(const GUI::MouseEvent&, const Layer&) const; - GUI::MouseEvent event_with_pan_and_scale_applied(const GUI::MouseEvent&) const; + GUI::MouseEvent event_adjusted_for_layer(GUI::MouseEvent const&, Layer const&) const; + GUI::MouseEvent event_with_pan_and_scale_applied(GUI::MouseEvent const&) const; void clamped_scale(float); void relayout(); diff --git a/Userland/Applications/PixelPaint/Layer.cpp b/Userland/Applications/PixelPaint/Layer.cpp index 92ce3422b97..280a39fe8c5 100644 --- a/Userland/Applications/PixelPaint/Layer.cpp +++ b/Userland/Applications/PixelPaint/Layer.cpp @@ -10,7 +10,7 @@ namespace PixelPaint { -RefPtr Layer::create_with_size(Image& image, const Gfx::IntSize& size, const String& name) +RefPtr Layer::create_with_size(Image& image, Gfx::IntSize const& size, String const& name) { if (size.is_empty()) return nullptr; @@ -21,7 +21,7 @@ RefPtr Layer::create_with_size(Image& image, const Gfx::IntSize& size, co return adopt_ref(*new Layer(image, size, name)); } -RefPtr Layer::create_with_bitmap(Image& image, const Gfx::Bitmap& bitmap, const String& name) +RefPtr Layer::create_with_bitmap(Image& image, Gfx::Bitmap const& bitmap, String const& name) { if (bitmap.size().is_empty()) return nullptr; @@ -32,7 +32,7 @@ RefPtr Layer::create_with_bitmap(Image& image, const Gfx::Bitmap& bitmap, return adopt_ref(*new Layer(image, bitmap, name)); } -RefPtr Layer::create_snapshot(Image& image, const Layer& layer) +RefPtr Layer::create_snapshot(Image& image, Layer const& layer) { auto snapshot = create_with_bitmap(image, *layer.bitmap().clone(), layer.name()); /* @@ -49,14 +49,14 @@ RefPtr Layer::create_snapshot(Image& image, const Layer& layer) return snapshot; } -Layer::Layer(Image& image, const Gfx::IntSize& size, const String& name) +Layer::Layer(Image& image, Gfx::IntSize const& size, String const& name) : m_image(image) , m_name(name) { m_bitmap = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, size); } -Layer::Layer(Image& image, const Gfx::Bitmap& bitmap, const String& name) +Layer::Layer(Image& image, Gfx::Bitmap const& bitmap, String const& name) : m_image(image) , m_name(name) , m_bitmap(bitmap) @@ -84,7 +84,7 @@ void Layer::set_opacity_percent(int opacity_percent) m_image.layer_did_modify_properties({}, *this); } -void Layer::set_name(const String& name) +void Layer::set_name(String const& name) { if (m_name == name) return; diff --git a/Userland/Applications/PixelPaint/Layer.h b/Userland/Applications/PixelPaint/Layer.h index 1cd2cea99dd..c0f58e4402f 100644 --- a/Userland/Applications/PixelPaint/Layer.h +++ b/Userland/Applications/PixelPaint/Layer.h @@ -24,24 +24,24 @@ class Layer AK_MAKE_NONMOVABLE(Layer); public: - static RefPtr create_with_size(Image&, const Gfx::IntSize&, const String& name); - static RefPtr create_with_bitmap(Image&, const Gfx::Bitmap&, const String& name); - static RefPtr create_snapshot(Image&, const Layer&); + static RefPtr create_with_size(Image&, Gfx::IntSize const&, String const& name); + static RefPtr create_with_bitmap(Image&, Gfx::Bitmap const&, String const& name); + static RefPtr create_snapshot(Image&, Layer const&); ~Layer() { } - const Gfx::IntPoint& location() const { return m_location; } - void set_location(const Gfx::IntPoint& location) { m_location = location; } + Gfx::IntPoint const& location() const { return m_location; } + void set_location(Gfx::IntPoint const& location) { m_location = location; } - const Gfx::Bitmap& bitmap() const { return *m_bitmap; } + Gfx::Bitmap const& bitmap() const { return *m_bitmap; } Gfx::Bitmap& bitmap() { return *m_bitmap; } Gfx::IntSize size() const { return bitmap().size(); } Gfx::IntRect relative_rect() const { return { location(), size() }; } Gfx::IntRect rect() const { return { {}, size() }; } - const String& name() const { return m_name; } - void set_name(const String&); + String const& name() const { return m_name; } + void set_name(String const&); void set_bitmap(Gfx::Bitmap& bitmap) { m_bitmap = bitmap; } @@ -57,8 +57,8 @@ public: void set_opacity_percent(int); private: - Layer(Image&, const Gfx::IntSize&, const String& name); - Layer(Image&, const Gfx::Bitmap&, const String& name); + Layer(Image&, Gfx::IntSize const&, String const& name); + Layer(Image&, Gfx::Bitmap const&, String const& name); Image& m_image; diff --git a/Userland/Applications/PixelPaint/LayerListWidget.cpp b/Userland/Applications/PixelPaint/LayerListWidget.cpp index a627dccb42e..083c6cd73e2 100644 --- a/Userland/Applications/PixelPaint/LayerListWidget.cpp +++ b/Userland/Applications/PixelPaint/LayerListWidget.cpp @@ -103,7 +103,7 @@ void LayerListWidget::paint_event(GUI::PaintEvent& event) paint_gadget(m_gadgets[m_moving_gadget_index.value()]); } -Optional LayerListWidget::gadget_at(const Gfx::IntPoint& position) +Optional LayerListWidget::gadget_at(Gfx::IntPoint const& position) { for (size_t i = 0; i < m_gadgets.size(); ++i) { if (m_gadgets[i].rect.contains(position)) diff --git a/Userland/Applications/PixelPaint/LayerListWidget.h b/Userland/Applications/PixelPaint/LayerListWidget.h index 3f8edd2658f..4a5d34039d2 100644 --- a/Userland/Applications/PixelPaint/LayerListWidget.h +++ b/Userland/Applications/PixelPaint/LayerListWidget.h @@ -57,7 +57,7 @@ private: bool is_moving_gadget() const { return m_moving_gadget_index.has_value(); } - Optional gadget_at(const Gfx::IntPoint&); + Optional gadget_at(Gfx::IntPoint const&); Vector m_gadgets; RefPtr m_image; diff --git a/Userland/Applications/PixelPaint/LineTool.cpp b/Userland/Applications/PixelPaint/LineTool.cpp index 23669c27df4..7577f96e6b5 100644 --- a/Userland/Applications/PixelPaint/LineTool.cpp +++ b/Userland/Applications/PixelPaint/LineTool.cpp @@ -14,7 +14,7 @@ namespace PixelPaint { -static Gfx::IntPoint constrain_line_angle(const Gfx::IntPoint& start_pos, const Gfx::IntPoint& end_pos, float angle_increment) +static Gfx::IntPoint constrain_line_angle(Gfx::IntPoint const& start_pos, Gfx::IntPoint const& end_pos, float angle_increment) { float current_angle = atan2f(end_pos.y() - start_pos.y(), end_pos.x() - start_pos.x()) + float { M_PI * 2 }; @@ -76,7 +76,7 @@ void LineTool::on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEven m_editor->update(); } -void LineTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event) +void LineTool::on_second_paint(Layer const& layer, GUI::PaintEvent& event) { if (m_drawing_button == GUI::MouseButton::None) return; diff --git a/Userland/Applications/PixelPaint/LineTool.h b/Userland/Applications/PixelPaint/LineTool.h index 742bb8d675d..5cda0ed9d0a 100644 --- a/Userland/Applications/PixelPaint/LineTool.h +++ b/Userland/Applications/PixelPaint/LineTool.h @@ -21,7 +21,7 @@ public: virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_tool_button_contextmenu(GUI::ContextMenuEvent&) override; - virtual void on_second_paint(const Layer&, GUI::PaintEvent&) override; + virtual void on_second_paint(Layer const&, GUI::PaintEvent&) override; virtual void on_keydown(GUI::KeyEvent&) override; virtual void on_keyup(GUI::KeyEvent&) override; diff --git a/Userland/Applications/PixelPaint/RectangleTool.cpp b/Userland/Applications/PixelPaint/RectangleTool.cpp index 113976c1e7c..bb14cc8ffd4 100644 --- a/Userland/Applications/PixelPaint/RectangleTool.cpp +++ b/Userland/Applications/PixelPaint/RectangleTool.cpp @@ -23,7 +23,7 @@ RectangleTool::~RectangleTool() { } -void RectangleTool::draw_using(GUI::Painter& painter, const Gfx::IntRect& rect) +void RectangleTool::draw_using(GUI::Painter& painter, Gfx::IntRect const& rect) { switch (m_mode) { case Mode::Fill: @@ -75,7 +75,7 @@ void RectangleTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent m_editor->update(); } -void RectangleTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event) +void RectangleTool::on_second_paint(Layer const& layer, GUI::PaintEvent& event) { if (m_drawing_button == GUI::MouseButton::None) return; diff --git a/Userland/Applications/PixelPaint/RectangleTool.h b/Userland/Applications/PixelPaint/RectangleTool.h index 1a2898395a2..52c74d8668b 100644 --- a/Userland/Applications/PixelPaint/RectangleTool.h +++ b/Userland/Applications/PixelPaint/RectangleTool.h @@ -21,7 +21,7 @@ public: virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_tool_button_contextmenu(GUI::ContextMenuEvent&) override; - virtual void on_second_paint(const Layer&, GUI::PaintEvent&) override; + virtual void on_second_paint(Layer const&, GUI::PaintEvent&) override; virtual void on_keydown(GUI::KeyEvent&) override; private: @@ -31,7 +31,7 @@ private: Gradient, }; - void draw_using(GUI::Painter&, const Gfx::IntRect&); + void draw_using(GUI::Painter&, Gfx::IntRect const&); GUI::MouseButton m_drawing_button { GUI::MouseButton::None }; Gfx::IntPoint m_rectangle_start_position; diff --git a/Userland/Applications/PixelPaint/Tool.h b/Userland/Applications/PixelPaint/Tool.h index 94e01543907..b359dd06844 100644 --- a/Userland/Applications/PixelPaint/Tool.h +++ b/Userland/Applications/PixelPaint/Tool.h @@ -23,7 +23,7 @@ public: virtual void on_mouseup(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) { } virtual void on_context_menu(Layer&, GUI::ContextMenuEvent&) { } virtual void on_tool_button_contextmenu(GUI::ContextMenuEvent&) { } - virtual void on_second_paint(const Layer&, GUI::PaintEvent&) { } + virtual void on_second_paint(Layer const&, GUI::PaintEvent&) { } virtual void on_keydown(GUI::KeyEvent&) { } virtual void on_keyup(GUI::KeyEvent&) { } virtual GUI::Widget* get_properties_widget() { return nullptr; }