summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/PixelPaint/Tools/EllipseTool.cpp1
-rw-r--r--Userland/Applications/PixelPaint/Tools/LineTool.cpp1
-rw-r--r--Userland/Applications/PixelPaint/Tools/RectangleTool.cpp1
-rw-r--r--Userland/Applications/PixelPaint/Tools/Tool.cpp6
-rw-r--r--Userland/Applications/PixelPaint/Tools/Tool.h2
5 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp b/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp
index c45bec5884..cd709bc090 100644
--- a/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/EllipseTool.cpp
@@ -116,6 +116,7 @@ void EllipseTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event)
GUI::Painter painter(*m_editor);
painter.add_clip_rect(event.rect());
+ painter.translate(editor_layer_location(*layer));
auto preview_start = m_editor->content_to_frame_position(m_ellipse_start_position).to_type<int>();
auto preview_end = m_editor->content_to_frame_position(m_ellipse_end_position).to_type<int>();
draw_using(painter, preview_start, preview_end, AK::max(m_thickness * m_editor->scale(), 1));
diff --git a/Userland/Applications/PixelPaint/Tools/LineTool.cpp b/Userland/Applications/PixelPaint/Tools/LineTool.cpp
index bbe7f50e47..a394494b0e 100644
--- a/Userland/Applications/PixelPaint/Tools/LineTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/LineTool.cpp
@@ -117,6 +117,7 @@ void LineTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event)
GUI::Painter painter(*m_editor);
painter.add_clip_rect(event.rect());
+ painter.translate(editor_layer_location(*layer));
auto preview_start = editor_stroke_position(m_line_start_position, m_thickness);
auto preview_end = editor_stroke_position(m_line_end_position, m_thickness);
draw_using(painter, preview_start, preview_end, m_editor->color_for(m_drawing_button), AK::max(m_thickness * m_editor->scale(), 1));
diff --git a/Userland/Applications/PixelPaint/Tools/RectangleTool.cpp b/Userland/Applications/PixelPaint/Tools/RectangleTool.cpp
index efe9ee0058..5ec0f35122 100644
--- a/Userland/Applications/PixelPaint/Tools/RectangleTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/RectangleTool.cpp
@@ -123,6 +123,7 @@ void RectangleTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event)
GUI::Painter painter(*m_editor);
painter.add_clip_rect(event.rect());
+ painter.translate(editor_layer_location(*layer));
auto start_position = editor_stroke_position(m_rectangle_start_position, m_thickness);
auto end_position = editor_stroke_position(m_rectangle_end_position, m_thickness);
draw_using(painter, start_position, end_position, AK::max(m_thickness * m_editor->scale(), 1), m_corner_radius * m_editor->scale());
diff --git a/Userland/Applications/PixelPaint/Tools/Tool.cpp b/Userland/Applications/PixelPaint/Tools/Tool.cpp
index 4c647b1d5b..86ea2160a9 100644
--- a/Userland/Applications/PixelPaint/Tools/Tool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/Tool.cpp
@@ -8,6 +8,7 @@
#include "Tool.h"
#include "../ImageEditor.h"
+#include "../Layer.h"
#include <LibGUI/Action.h>
namespace PixelPaint {
@@ -46,6 +47,11 @@ void Tool::on_keydown(GUI::KeyEvent& event)
}
}
+Gfx::IntPoint Tool::editor_layer_location(Layer const& layer) const
+{
+ return (Gfx::FloatPoint { layer.location() } * m_editor->scale()).to_rounded<int>();
+}
+
Gfx::IntPoint Tool::editor_stroke_position(Gfx::IntPoint const& pixel_coords, int stroke_thickness) const
{
auto position = m_editor->content_to_frame_position(pixel_coords);
diff --git a/Userland/Applications/PixelPaint/Tools/Tool.h b/Userland/Applications/PixelPaint/Tools/Tool.h
index 14a9ed935c..379513a4af 100644
--- a/Userland/Applications/PixelPaint/Tools/Tool.h
+++ b/Userland/Applications/PixelPaint/Tools/Tool.h
@@ -79,6 +79,8 @@ protected:
WeakPtr<ImageEditor> m_editor;
RefPtr<GUI::Action> m_action;
+ Gfx::IntPoint editor_layer_location(Layer const& layer) const;
+
virtual Gfx::IntPoint editor_stroke_position(Gfx::IntPoint const& pixel_coords, int stroke_thickness) const;
void set_primary_slider(GUI::ValueSlider* primary) { m_primary_slider = primary; }