From 24f9406784b4db6b7d4b4f5e9100afdecd44057b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 13 May 2020 13:50:35 +0200 Subject: [PATCH] PaintBrush: Most tools still care about mousemoves outside layer This allows you to do things like start a line outside the layer, or spray a little outside but still partly hitting the layer. :^) --- Applications/PaintBrush/EllipseTool.cpp | 5 +---- Applications/PaintBrush/EraseTool.cpp | 3 --- Applications/PaintBrush/LineTool.cpp | 3 --- Applications/PaintBrush/PenTool.cpp | 19 ++++++++----------- Applications/PaintBrush/RectangleTool.cpp | 3 --- Applications/PaintBrush/SprayTool.cpp | 3 --- 6 files changed, 9 insertions(+), 27 deletions(-) diff --git a/Applications/PaintBrush/EllipseTool.cpp b/Applications/PaintBrush/EllipseTool.cpp index 00c90700fd..8169207491 100644 --- a/Applications/PaintBrush/EllipseTool.cpp +++ b/Applications/PaintBrush/EllipseTool.cpp @@ -79,14 +79,11 @@ void EllipseTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseEve } } -void EllipseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) +void EllipseTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) { if (m_drawing_button == GUI::MouseButton::None) return; - if (!layer.rect().contains(event.position())) - return; - m_ellipse_end_position = event.position(); m_editor->update(); } diff --git a/Applications/PaintBrush/EraseTool.cpp b/Applications/PaintBrush/EraseTool.cpp index e4db9db861..992183091e 100644 --- a/Applications/PaintBrush/EraseTool.cpp +++ b/Applications/PaintBrush/EraseTool.cpp @@ -64,9 +64,6 @@ void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEve void EraseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { - if (!m_editor->rect().contains(event.position())) - return; - if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) { Gfx::Rect r = build_rect(event.position(), layer.rect()); GUI::Painter painter(layer.bitmap()); diff --git a/Applications/PaintBrush/LineTool.cpp b/Applications/PaintBrush/LineTool.cpp index d098ab3bc0..47db6e2437 100644 --- a/Applications/PaintBrush/LineTool.cpp +++ b/Applications/PaintBrush/LineTool.cpp @@ -84,9 +84,6 @@ void LineTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) if (m_drawing_button == GUI::MouseButton::None) return; - if (!m_editor->rect().contains(event.position())) - return; - if (!m_constrain_angle) { m_line_end_position = event.position(); } else { diff --git a/Applications/PaintBrush/PenTool.cpp b/Applications/PaintBrush/PenTool.cpp index f672fc2180..8254acb8e1 100644 --- a/Applications/PaintBrush/PenTool.cpp +++ b/Applications/PaintBrush/PenTool.cpp @@ -60,20 +60,17 @@ void PenTool::on_mouseup(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { - if (!layer.rect().contains(event.position())) + if (!(event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right)) return; + GUI::Painter painter(layer.bitmap()); - if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) { - GUI::Painter painter(layer.bitmap()); + if (m_last_drawing_event_position != Gfx::Point(-1, -1)) + painter.draw_line(m_last_drawing_event_position, event.position(), m_editor->color_for(event), m_thickness); + else + painter.draw_line(event.position(), event.position(), m_editor->color_for(event), m_thickness); + m_editor->update(); - if (m_last_drawing_event_position != Gfx::Point(-1, -1)) - painter.draw_line(m_last_drawing_event_position, event.position(), m_editor->color_for(event), m_thickness); - else - painter.draw_line(event.position(), event.position(), m_editor->color_for(event), m_thickness); - m_editor->update(); - - m_last_drawing_event_position = event.position(); - } + m_last_drawing_event_position = event.position(); } void PenTool::on_contextmenu(GUI::ContextMenuEvent& event) diff --git a/Applications/PaintBrush/RectangleTool.cpp b/Applications/PaintBrush/RectangleTool.cpp index 171e20896c..09547ff4f6 100644 --- a/Applications/PaintBrush/RectangleTool.cpp +++ b/Applications/PaintBrush/RectangleTool.cpp @@ -90,9 +90,6 @@ void RectangleTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent if (m_drawing_button == GUI::MouseButton::None) return; - if (!m_editor->rect().contains(event.position())) - return; - m_rectangle_end_position = event.position(); m_editor->update(); } diff --git a/Applications/PaintBrush/SprayTool.cpp b/Applications/PaintBrush/SprayTool.cpp index d9dbd89974..160d641f33 100644 --- a/Applications/PaintBrush/SprayTool.cpp +++ b/Applications/PaintBrush/SprayTool.cpp @@ -83,9 +83,6 @@ void SprayTool::paint_it() void SprayTool::on_mousedown(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) { - if (!m_editor->rect().contains(event.position())) - return; - m_color = m_editor->color_for(event); m_last_pos = event.position(); m_timer->start();