summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint/Tools/Tool.cpp
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2022-08-20 18:09:20 +0100
committerAndreas Kling <kling@serenityos.org>2022-08-21 14:13:08 +0200
commit78813313f9f1946afad202acfc537c7d0d465de4 (patch)
tree01cdb440c9f58aea15f3c95f0fa111b19a6250d2 /Userland/Applications/PixelPaint/Tools/Tool.cpp
parent973771f8f431cb9c5faaa87f9c66cfcf480a83c4 (diff)
downloadserenity-78813313f9f1946afad202acfc537c7d0d465de4.zip
PixelPaint: Fix tool preview positions after moving a layer
Previously the tool previews did not account for the position of the layer, so would be drawn in the wrong location if the layer was not at 0,0.
Diffstat (limited to 'Userland/Applications/PixelPaint/Tools/Tool.cpp')
-rw-r--r--Userland/Applications/PixelPaint/Tools/Tool.cpp6
1 files changed, 6 insertions, 0 deletions
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);