summaryrefslogtreecommitdiff
path: root/Applications/PixelPaint
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-22 15:57:04 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-22 15:57:04 +0200
commit9fc4ad2a52229ba464229b020be7d0f2f710ede0 (patch)
tree26eb58144b862d2d6be50f75a2e2f181075223f1 /Applications/PixelPaint
parentd12cce76a7776876f09dcdad9b81e3e839a52951 (diff)
downloadserenity-9fc4ad2a52229ba464229b020be7d0f2f710ede0.zip
PixelPaint: Make the EllipseTool previews work while zoomed in
Diffstat (limited to 'Applications/PixelPaint')
-rw-r--r--Applications/PixelPaint/EllipseTool.cpp10
-rw-r--r--Applications/PixelPaint/EllipseTool.h2
2 files changed, 6 insertions, 6 deletions
diff --git a/Applications/PixelPaint/EllipseTool.cpp b/Applications/PixelPaint/EllipseTool.cpp
index 91b03473cc..9a24c07745 100644
--- a/Applications/PixelPaint/EllipseTool.cpp
+++ b/Applications/PixelPaint/EllipseTool.cpp
@@ -43,9 +43,8 @@ EllipseTool::~EllipseTool()
{
}
-void EllipseTool::draw_using(GUI::Painter& painter)
+void EllipseTool::draw_using(GUI::Painter& painter, const Gfx::Rect& ellipse_intersecting_rect)
{
- auto ellipse_intersecting_rect = Gfx::Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position);
switch (m_mode) {
case Mode::Outline:
painter.draw_ellipse_intersecting(ellipse_intersecting_rect, m_editor->color_for(m_drawing_button), m_thickness);
@@ -73,7 +72,7 @@ void EllipseTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseEve
{
if (event.button() == m_drawing_button) {
GUI::Painter painter(layer.bitmap());
- draw_using(painter);
+ draw_using(painter, Gfx::Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position));
m_drawing_button = GUI::MouseButton::None;
m_editor->update();
}
@@ -95,8 +94,9 @@ void EllipseTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event)
GUI::Painter painter(*m_editor);
painter.add_clip_rect(event.rect());
- painter.translate(layer.location());
- draw_using(painter);
+ auto preview_start = m_editor->layer_position_to_editor_position(layer, m_ellipse_start_position).to_int_point();
+ auto preview_end = m_editor->layer_position_to_editor_position(layer, m_ellipse_end_position).to_int_point();
+ draw_using(painter, Gfx::Rect::from_two_points(preview_start, preview_end));
}
void EllipseTool::on_keydown(GUI::KeyEvent& event)
diff --git a/Applications/PixelPaint/EllipseTool.h b/Applications/PixelPaint/EllipseTool.h
index 8bf2d7689e..8169bc2c8e 100644
--- a/Applications/PixelPaint/EllipseTool.h
+++ b/Applications/PixelPaint/EllipseTool.h
@@ -51,7 +51,7 @@ private:
};
virtual const char* class_name() const override { return "EllipseTool"; }
- void draw_using(GUI::Painter& painter);
+ void draw_using(GUI::Painter&, const Gfx::Rect&);
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
Gfx::Point m_ellipse_start_position;