From d6348e1b322152e6a803a906281fd467b5dbe31b Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Mon, 6 Sep 2021 20:48:36 -0400 Subject: [PATCH] PixelPaint: Use correct thickness in `RectangleTool::on_second_paint()` Previously, we were ignoring the scale of the editor in the second paint step. If you were zoomed in, the size while you were drawing was not the same as the size of the final shape. --- Userland/Applications/PixelPaint/RectangleTool.cpp | 6 +++--- Userland/Applications/PixelPaint/RectangleTool.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Applications/PixelPaint/RectangleTool.cpp b/Userland/Applications/PixelPaint/RectangleTool.cpp index 19592fb694..fdab706dd9 100644 --- a/Userland/Applications/PixelPaint/RectangleTool.cpp +++ b/Userland/Applications/PixelPaint/RectangleTool.cpp @@ -27,7 +27,7 @@ RectangleTool::~RectangleTool() { } -void RectangleTool::draw_using(GUI::Painter& painter, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position) +void RectangleTool::draw_using(GUI::Painter& painter, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position, int thickness) { Gfx::IntRect rect; if (m_draw_mode == DrawMode::FromCenter) { @@ -42,7 +42,7 @@ void RectangleTool::draw_using(GUI::Painter& painter, Gfx::IntPoint const& start painter.fill_rect(rect, m_editor->color_for(m_drawing_button)); break; case FillMode::Outline: - painter.draw_rect_with_thickness(rect, m_editor->color_for(m_drawing_button), m_thickness); + painter.draw_rect_with_thickness(rect, m_editor->color_for(m_drawing_button), thickness); break; case FillMode::Gradient: painter.fill_rect_with_gradient(rect, m_editor->primary_color(), m_editor->secondary_color()); @@ -77,7 +77,7 @@ void RectangleTool::on_mouseup(Layer* layer, MouseEvent& event) if (event.layer_event().button() == m_drawing_button) { GUI::Painter painter(layer->bitmap()); - draw_using(painter, m_rectangle_start_position, m_rectangle_end_position); + draw_using(painter, m_rectangle_start_position, m_rectangle_end_position, m_thickness); m_drawing_button = GUI::MouseButton::None; layer->did_modify_bitmap(); m_editor->did_complete_action(); diff --git a/Userland/Applications/PixelPaint/RectangleTool.h b/Userland/Applications/PixelPaint/RectangleTool.h index c74ceed66e..2cd7820f6c 100644 --- a/Userland/Applications/PixelPaint/RectangleTool.h +++ b/Userland/Applications/PixelPaint/RectangleTool.h @@ -38,7 +38,7 @@ private: FromCorner, }; - void draw_using(GUI::Painter&, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position); + void draw_using(GUI::Painter&, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position, int thickness); RefPtr m_properties_widget; GUI::MouseButton m_drawing_button { GUI::MouseButton::None };