diff options
author | MacDue <macdue@dueutil.tech> | 2022-12-06 19:43:46 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-07 11:48:27 +0100 |
commit | bbc149ebb935532c9382278ed98cf9fe8a616422 (patch) | |
tree | bf9b37fb4947579351f57de87e1377da8413e097 /Userland/Applications | |
parent | f76c7f3788242e8b486c51cd251e6c59179e33dd (diff) | |
download | serenity-bbc149ebb935532c9382278ed98cf9fe8a616422.zip |
Meta+Userland: Pass Gfx::Color by value
Gfx::Color is always 4 bytes (it's just a wrapper over u32) it's less
work just to pass the color directly.
This also updates IPCCompiler to prevent from generating
Gfx::Color const &, which makes replacement easier.
Diffstat (limited to 'Userland/Applications')
10 files changed, 19 insertions, 19 deletions
diff --git a/Userland/Applications/MouseSettings/HighlightPreviewWidget.h b/Userland/Applications/MouseSettings/HighlightPreviewWidget.h index 06714f13c8..bafcbeb15b 100644 --- a/Userland/Applications/MouseSettings/HighlightPreviewWidget.h +++ b/Userland/Applications/MouseSettings/HighlightPreviewWidget.h @@ -26,7 +26,7 @@ public: update(); } - void set_color(Gfx::Color const& color) + void set_color(Gfx::Color color) { m_color = color; update(); diff --git a/Userland/Applications/PixelPaint/PaletteWidget.cpp b/Userland/Applications/PixelPaint/PaletteWidget.cpp index f40e16c96c..a5a3fd836a 100644 --- a/Userland/Applications/PixelPaint/PaletteWidget.cpp +++ b/Userland/Applications/PixelPaint/PaletteWidget.cpp @@ -77,7 +77,7 @@ public: on_color_change(dialog->color()); } - void set_background_color(Color const& color) + void set_background_color(Color color) { auto pal = palette(); pal.set_color(ColorRole::Background, color); @@ -86,7 +86,7 @@ public: m_color = color; } - Function<void(Color const&)> on_color_change; + Function<void(Color)> on_color_change; Color m_color = Color::White; private: @@ -103,14 +103,14 @@ PaletteWidget::PaletteWidget() set_fixed_height(35); m_secondary_color_widget = add<SelectedColorWidget>(); - m_secondary_color_widget->on_color_change = [&](auto& color) { + m_secondary_color_widget->on_color_change = [&](auto color) { set_secondary_color(color); }; m_secondary_color_widget->set_relative_rect({ 0, 2, 60, 33 }); m_secondary_color_widget->set_fill_with_background_color(true); m_primary_color_widget = add<SelectedColorWidget>(); - m_primary_color_widget->on_color_change = [&](auto& color) { + m_primary_color_widget->on_color_change = [&](auto color) { set_primary_color(color); }; auto rect = Gfx::IntRect(0, 0, 35, 17).centered_within(m_secondary_color_widget->relative_rect()); diff --git a/Userland/Applications/PixelPaint/Tools/BrushTool.cpp b/Userland/Applications/PixelPaint/Tools/BrushTool.cpp index 3873b97ecf..47499fa5e6 100644 --- a/Userland/Applications/PixelPaint/Tools/BrushTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/BrushTool.cpp @@ -84,7 +84,7 @@ Color BrushTool::color_for(GUI::MouseEvent const& event) return m_editor->color_for(event); } -void BrushTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) +void BrushTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point) { constexpr auto flow_scale = 10; for (int y = point.y() - size(); y < point.y() + size(); y++) { @@ -103,7 +103,7 @@ void BrushTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::In } } -void BrushTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) +void BrushTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color 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/Tools/BrushTool.h b/Userland/Applications/PixelPaint/Tools/BrushTool.h index 0f23b93dfc..90ad4550ac 100644 --- a/Userland/Applications/PixelPaint/Tools/BrushTool.h +++ b/Userland/Applications/PixelPaint/Tools/BrushTool.h @@ -46,8 +46,8 @@ protected: virtual StringView tool_name() const override { return "Brush Tool"sv; } virtual Color color_for(GUI::MouseEvent const& event); - virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point); - virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end); + virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point); + virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end); virtual NonnullRefPtr<Gfx::Bitmap> build_cursor(); void refresh_editor_cursor(); float m_scale_last_created_cursor = 0; diff --git a/Userland/Applications/PixelPaint/Tools/CloneTool.cpp b/Userland/Applications/PixelPaint/Tools/CloneTool.cpp index 56805197b1..3926915cb8 100644 --- a/Userland/Applications/PixelPaint/Tools/CloneTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/CloneTool.cpp @@ -16,7 +16,7 @@ namespace PixelPaint { -void CloneTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const&, Gfx::IntPoint const& point) +void CloneTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color, Gfx::IntPoint const& point) { if (!m_sample_location.has_value()) return; @@ -45,7 +45,7 @@ void CloneTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const&, Gfx::IntPoint } } -void CloneTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) +void CloneTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) { if (!m_sample_location.has_value()) return; diff --git a/Userland/Applications/PixelPaint/Tools/CloneTool.h b/Userland/Applications/PixelPaint/Tools/CloneTool.h index 0aa3ada005..973a37069c 100644 --- a/Userland/Applications/PixelPaint/Tools/CloneTool.h +++ b/Userland/Applications/PixelPaint/Tools/CloneTool.h @@ -21,8 +21,8 @@ public: virtual bool is_overriding_alt() override { return true; } protected: - virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) override; - virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) override; + virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point) override; + virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) override; virtual void on_mousedown(Layer*, MouseEvent&) override; virtual void on_mousemove(Layer*, MouseEvent&) override; diff --git a/Userland/Applications/PixelPaint/Tools/EraseTool.cpp b/Userland/Applications/PixelPaint/Tools/EraseTool.cpp index 48d489186f..f449a0b3a4 100644 --- a/Userland/Applications/PixelPaint/Tools/EraseTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/EraseTool.cpp @@ -28,7 +28,7 @@ Color EraseTool::color_for(GUI::MouseEvent const&) return Color(255, 255, 255, 0); } -void EraseTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) +void EraseTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point) { if (m_draw_mode == DrawMode::Pencil) { int radius = size() / 2; diff --git a/Userland/Applications/PixelPaint/Tools/EraseTool.h b/Userland/Applications/PixelPaint/Tools/EraseTool.h index 41b6371d46..bee0ad308d 100644 --- a/Userland/Applications/PixelPaint/Tools/EraseTool.h +++ b/Userland/Applications/PixelPaint/Tools/EraseTool.h @@ -24,7 +24,7 @@ public: protected: virtual Color color_for(GUI::MouseEvent const& event) override; - virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) override; + virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point) override; virtual NonnullRefPtr<Gfx::Bitmap> build_cursor() override; private: diff --git a/Userland/Applications/PixelPaint/Tools/PenTool.cpp b/Userland/Applications/PixelPaint/Tools/PenTool.cpp index fa7170ba92..de44ff6b28 100644 --- a/Userland/Applications/PixelPaint/Tools/PenTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/PenTool.cpp @@ -23,13 +23,13 @@ PenTool::PenTool() set_size(1); } -void PenTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) +void PenTool::draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point) { GUI::Painter painter(bitmap); painter.draw_line(point, point, color, size()); } -void PenTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) +void PenTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) { GUI::Painter painter(bitmap); painter.draw_line(start, end, color, size()); diff --git a/Userland/Applications/PixelPaint/Tools/PenTool.h b/Userland/Applications/PixelPaint/Tools/PenTool.h index 1799a66c86..486184e8d9 100644 --- a/Userland/Applications/PixelPaint/Tools/PenTool.h +++ b/Userland/Applications/PixelPaint/Tools/PenTool.h @@ -22,8 +22,8 @@ public: virtual GUI::Widget* get_properties_widget() override; protected: - virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) override; - virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) override; + virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& point) override; + virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) override; private: virtual StringView tool_name() const override { return "Pen Tool"sv; } |