summaryrefslogtreecommitdiff
path: root/Applications/PaintBrush/EllipseTool.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-13 13:41:12 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-13 13:43:20 +0200
commit96d03546efb79f33b0bb4bd507825ad847724b02 (patch)
tree6ab36036453bedf2f96f1bd444b79f821198f5ec /Applications/PaintBrush/EllipseTool.cpp
parent8318842c7e5a9ec72cdd7bcb10786749bf773793 (diff)
downloadserenity-96d03546efb79f33b0bb4bd507825ad847724b02.zip
PaintBrush: Make the line, rectangle and ellipsis preview work again
You can now see what you're drawing before committing to it. This works by passing the second_paint_event from the ImageEditor to the tool. We also pass the active layer which makes it easier for the tool to keep his logic in layer-relative coordinates even while drawing preview states directly into the ImageEditor backing bitmap.
Diffstat (limited to 'Applications/PaintBrush/EllipseTool.cpp')
-rw-r--r--Applications/PaintBrush/EllipseTool.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Applications/PaintBrush/EllipseTool.cpp b/Applications/PaintBrush/EllipseTool.cpp
index 462ffb20af..00c90700fd 100644
--- a/Applications/PaintBrush/EllipseTool.cpp
+++ b/Applications/PaintBrush/EllipseTool.cpp
@@ -91,13 +91,14 @@ void EllipseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseE
m_editor->update();
}
-void EllipseTool::on_second_paint(GUI::PaintEvent& event)
+void EllipseTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event)
{
if (m_drawing_button == GUI::MouseButton::None)
return;
GUI::Painter painter(*m_editor);
painter.add_clip_rect(event.rect());
+ painter.translate(layer.location());
draw_using(painter);
}