From 3d50f40396a6b8000fa267d51144cd983c7d4fea Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 13 May 2020 00:08:47 +0200 Subject: [PATCH] PaintBrush: Add a "Move" tool for moving layers around :^) Tool mouse event handlers now receive both a layer-relative mouse event and the original event. This is needed for the move tool since it moves the layer and thereby changes the origin of future events every time it moves. --- Applications/PaintBrush/BucketTool.cpp | 2 +- Applications/PaintBrush/BucketTool.h | 2 +- Applications/PaintBrush/EllipseTool.cpp | 6 +- Applications/PaintBrush/EllipseTool.h | 6 +- Applications/PaintBrush/EraseTool.cpp | 4 +- Applications/PaintBrush/EraseTool.h | 4 +- Applications/PaintBrush/ImageEditor.cpp | 6 +- Applications/PaintBrush/LineTool.cpp | 6 +- Applications/PaintBrush/LineTool.h | 6 +- Applications/PaintBrush/Makefile | 1 + Applications/PaintBrush/MoveTool.cpp | 70 +++++++++++++++++++++++ Applications/PaintBrush/MoveTool.h | 50 ++++++++++++++++ Applications/PaintBrush/PenTool.cpp | 6 +- Applications/PaintBrush/PenTool.h | 6 +- Applications/PaintBrush/PickerTool.cpp | 2 +- Applications/PaintBrush/PickerTool.h | 2 +- Applications/PaintBrush/RectangleTool.cpp | 6 +- Applications/PaintBrush/RectangleTool.h | 6 +- Applications/PaintBrush/SprayTool.cpp | 6 +- Applications/PaintBrush/SprayTool.h | 6 +- Applications/PaintBrush/Tool.h | 6 +- Applications/PaintBrush/ToolboxWidget.cpp | 2 + 22 files changed, 167 insertions(+), 44 deletions(-) create mode 100644 Applications/PaintBrush/MoveTool.cpp create mode 100644 Applications/PaintBrush/MoveTool.h diff --git a/Applications/PaintBrush/BucketTool.cpp b/Applications/PaintBrush/BucketTool.cpp index 7c5bde56ec3..d7aed49e4d2 100644 --- a/Applications/PaintBrush/BucketTool.cpp +++ b/Applications/PaintBrush/BucketTool.cpp @@ -78,7 +78,7 @@ static void flood_fill(Gfx::Bitmap& bitmap, const Gfx::Point& start_position, Co } } -void BucketTool::on_mousedown(Layer& layer, GUI::MouseEvent& event) +void BucketTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (!layer.rect().contains(event.position())) return; diff --git a/Applications/PaintBrush/BucketTool.h b/Applications/PaintBrush/BucketTool.h index 8749025d1e5..8052f018dd1 100644 --- a/Applications/PaintBrush/BucketTool.h +++ b/Applications/PaintBrush/BucketTool.h @@ -35,7 +35,7 @@ public: BucketTool(); virtual ~BucketTool() override; - virtual void on_mousedown(Layer&, GUI::MouseEvent&) override; + virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; private: virtual const char* class_name() const override { return "BucketTool"; } diff --git a/Applications/PaintBrush/EllipseTool.cpp b/Applications/PaintBrush/EllipseTool.cpp index 661005bf2f8..9dc39225be0 100644 --- a/Applications/PaintBrush/EllipseTool.cpp +++ b/Applications/PaintBrush/EllipseTool.cpp @@ -56,7 +56,7 @@ void EllipseTool::draw_using(GUI::Painter& painter) } } -void EllipseTool::on_mousedown(Layer&, GUI::MouseEvent& event) +void EllipseTool::on_mousedown(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) { if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; @@ -70,7 +70,7 @@ void EllipseTool::on_mousedown(Layer&, GUI::MouseEvent& event) m_editor->update(); } -void EllipseTool::on_mouseup(Layer& layer, GUI::MouseEvent& event) +void EllipseTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (event.button() == m_drawing_button) { GUI::Painter painter(layer.bitmap()); @@ -80,7 +80,7 @@ void EllipseTool::on_mouseup(Layer& layer, GUI::MouseEvent& event) } } -void EllipseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event) +void EllipseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (m_drawing_button == GUI::MouseButton::None) return; diff --git a/Applications/PaintBrush/EllipseTool.h b/Applications/PaintBrush/EllipseTool.h index 3638920bcd6..3223404c91c 100644 --- a/Applications/PaintBrush/EllipseTool.h +++ b/Applications/PaintBrush/EllipseTool.h @@ -37,9 +37,9 @@ public: EllipseTool(); virtual ~EllipseTool() override; - virtual void on_mousedown(Layer&, GUI::MouseEvent&) override; - virtual void on_mousemove(Layer&, GUI::MouseEvent&) override; - virtual void on_mouseup(Layer&, GUI::MouseEvent&) override; + virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; virtual void on_contextmenu(GUI::ContextMenuEvent&) override; virtual void on_second_paint(GUI::PaintEvent&) override; virtual void on_keydown(GUI::KeyEvent&) override; diff --git a/Applications/PaintBrush/EraseTool.cpp b/Applications/PaintBrush/EraseTool.cpp index e1aa1c913cb..90403df340f 100644 --- a/Applications/PaintBrush/EraseTool.cpp +++ b/Applications/PaintBrush/EraseTool.cpp @@ -53,7 +53,7 @@ Gfx::Rect EraseTool::build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_r return Gfx::Rect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect); } -void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event) +void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; @@ -63,7 +63,7 @@ void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event) m_editor->update(); } -void EraseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event) +void EraseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (!m_editor->rect().contains(event.position())) return; diff --git a/Applications/PaintBrush/EraseTool.h b/Applications/PaintBrush/EraseTool.h index 8384b8e8fee..f610a80220e 100644 --- a/Applications/PaintBrush/EraseTool.h +++ b/Applications/PaintBrush/EraseTool.h @@ -38,8 +38,8 @@ public: EraseTool(); virtual ~EraseTool() override; - virtual void on_mousedown(Layer&, GUI::MouseEvent&) override; - virtual void on_mousemove(Layer&, GUI::MouseEvent&) override; + virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; virtual void on_contextmenu(GUI::ContextMenuEvent&) override; private: diff --git a/Applications/PaintBrush/ImageEditor.cpp b/Applications/PaintBrush/ImageEditor.cpp index 99b5f3f91d7..95018fdfe69 100644 --- a/Applications/PaintBrush/ImageEditor.cpp +++ b/Applications/PaintBrush/ImageEditor.cpp @@ -79,7 +79,7 @@ void ImageEditor::mousedown_event(GUI::MouseEvent& event) if (!m_active_layer || !m_active_tool) return; auto layer_event = event_adjusted_for_layer(event, *m_active_layer); - m_active_tool->on_mousedown(*m_active_layer, layer_event); + m_active_tool->on_mousedown(*m_active_layer, layer_event, event); } void ImageEditor::mousemove_event(GUI::MouseEvent& event) @@ -87,7 +87,7 @@ void ImageEditor::mousemove_event(GUI::MouseEvent& event) if (!m_active_layer || !m_active_tool) return; auto layer_event = event_adjusted_for_layer(event, *m_active_layer); - m_active_tool->on_mousemove(*m_active_layer, layer_event); + m_active_tool->on_mousemove(*m_active_layer, layer_event, event); } void ImageEditor::mouseup_event(GUI::MouseEvent& event) @@ -95,7 +95,7 @@ void ImageEditor::mouseup_event(GUI::MouseEvent& event) if (!m_active_layer || !m_active_tool) return; auto layer_event = event_adjusted_for_layer(event, *m_active_layer); - m_active_tool->on_mouseup(*m_active_layer, layer_event); + m_active_tool->on_mouseup(*m_active_layer, layer_event, event); } void ImageEditor::set_active_layer(Layer* layer) diff --git a/Applications/PaintBrush/LineTool.cpp b/Applications/PaintBrush/LineTool.cpp index e2a071334b5..a714130cf1d 100644 --- a/Applications/PaintBrush/LineTool.cpp +++ b/Applications/PaintBrush/LineTool.cpp @@ -56,7 +56,7 @@ LineTool::~LineTool() { } -void LineTool::on_mousedown(Layer&, GUI::MouseEvent& event) +void LineTool::on_mousedown(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) { if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; @@ -70,7 +70,7 @@ void LineTool::on_mousedown(Layer&, GUI::MouseEvent& event) m_editor->update(); } -void LineTool::on_mouseup(Layer& layer, GUI::MouseEvent& event) +void LineTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (event.button() == m_drawing_button) { GUI::Painter painter(layer.bitmap()); @@ -80,7 +80,7 @@ void LineTool::on_mouseup(Layer& layer, GUI::MouseEvent& event) } } -void LineTool::on_mousemove(Layer&, GUI::MouseEvent& event) +void LineTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) { if (m_drawing_button == GUI::MouseButton::None) return; diff --git a/Applications/PaintBrush/LineTool.h b/Applications/PaintBrush/LineTool.h index a30286ac5e1..ad64e4c1e22 100644 --- a/Applications/PaintBrush/LineTool.h +++ b/Applications/PaintBrush/LineTool.h @@ -37,9 +37,9 @@ public: LineTool(); virtual ~LineTool() override; - virtual void on_mousedown(Layer&, GUI::MouseEvent&) override; - virtual void on_mousemove(Layer&, GUI::MouseEvent&) override; - virtual void on_mouseup(Layer&, GUI::MouseEvent&) override; + virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; virtual void on_contextmenu(GUI::ContextMenuEvent&) override; virtual void on_second_paint(GUI::PaintEvent&) override; virtual void on_keydown(GUI::KeyEvent&) override; diff --git a/Applications/PaintBrush/Makefile b/Applications/PaintBrush/Makefile index 8a88850c0a7..c6514a09b4e 100644 --- a/Applications/PaintBrush/Makefile +++ b/Applications/PaintBrush/Makefile @@ -7,6 +7,7 @@ OBJS = \ Layer.o \ LayerModel.o \ LineTool.o \ + MoveTool.o \ PaintableWidget.o \ PaletteWidget.o \ PenTool.o \ diff --git a/Applications/PaintBrush/MoveTool.cpp b/Applications/PaintBrush/MoveTool.cpp new file mode 100644 index 00000000000..a1b20125a7e --- /dev/null +++ b/Applications/PaintBrush/MoveTool.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2020, Andreas Kling + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "MoveTool.h" +#include "ImageEditor.h" +#include "Layer.h" +#include "PaintableWidget.h" +#include + +namespace PaintBrush { + +MoveTool::MoveTool() +{ +} + +MoveTool::~MoveTool() +{ +} + +void MoveTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent& original_event) +{ + if (event.button() != GUI::MouseButton::Left) + return; + if (!layer.rect().contains(event.position())) + return; + m_layer_being_moved = layer; + m_event_origin = original_event.position(); + m_layer_origin = layer.location(); +} + +void MoveTool::on_mousemove(Layer&, GUI::MouseEvent&, GUI::MouseEvent& original_event) +{ + if (!m_layer_being_moved) + return; + auto delta = original_event.position() - m_event_origin; + m_layer_being_moved->set_location(m_layer_origin.translated(delta)); + m_editor->update(); +} + +void MoveTool::on_mouseup(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) +{ + if (event.button() != GUI::MouseButton::Left) + return; + m_layer_being_moved = nullptr; +} + +} diff --git a/Applications/PaintBrush/MoveTool.h b/Applications/PaintBrush/MoveTool.h new file mode 100644 index 00000000000..b4718dcb2bd --- /dev/null +++ b/Applications/PaintBrush/MoveTool.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020, Andreas Kling + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "Tool.h" + +namespace PaintBrush { + +class MoveTool final : public Tool { +public: + MoveTool(); + virtual ~MoveTool() override; + + virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + +private: + virtual const char* class_name() const override { return "MoveTool"; } + + RefPtr m_layer_being_moved; + Gfx::Point m_event_origin; + Gfx::Point m_layer_origin; +}; + +} diff --git a/Applications/PaintBrush/PenTool.cpp b/Applications/PaintBrush/PenTool.cpp index 2891bdba984..326db741006 100644 --- a/Applications/PaintBrush/PenTool.cpp +++ b/Applications/PaintBrush/PenTool.cpp @@ -42,7 +42,7 @@ PenTool::~PenTool() { } -void PenTool::on_mousedown(Layer& layer, GUI::MouseEvent& event) +void PenTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; @@ -53,13 +53,13 @@ void PenTool::on_mousedown(Layer& layer, GUI::MouseEvent& event) m_last_drawing_event_position = event.position(); } -void PenTool::on_mouseup(Layer&, GUI::MouseEvent& event) +void PenTool::on_mouseup(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) { if (event.button() == GUI::MouseButton::Left || event.button() == GUI::MouseButton::Right) m_last_drawing_event_position = { -1, -1 }; } -void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event) +void PenTool::on_mousemove(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (!layer.rect().contains(event.position())) return; diff --git a/Applications/PaintBrush/PenTool.h b/Applications/PaintBrush/PenTool.h index b0c7c46f9a5..432410ba386 100644 --- a/Applications/PaintBrush/PenTool.h +++ b/Applications/PaintBrush/PenTool.h @@ -37,9 +37,9 @@ public: PenTool(); virtual ~PenTool() override; - virtual void on_mousedown(Layer&, GUI::MouseEvent&) override; - virtual void on_mousemove(Layer&, GUI::MouseEvent&) override; - virtual void on_mouseup(Layer&, GUI::MouseEvent&) override; + virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; virtual void on_contextmenu(GUI::ContextMenuEvent&) override; private: diff --git a/Applications/PaintBrush/PickerTool.cpp b/Applications/PaintBrush/PickerTool.cpp index 2994869dd84..5af72c7935e 100644 --- a/Applications/PaintBrush/PickerTool.cpp +++ b/Applications/PaintBrush/PickerTool.cpp @@ -39,7 +39,7 @@ PickerTool::~PickerTool() { } -void PickerTool::on_mousedown(Layer& layer, GUI::MouseEvent& event) +void PickerTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (!layer.rect().contains(event.position())) return; diff --git a/Applications/PaintBrush/PickerTool.h b/Applications/PaintBrush/PickerTool.h index 34e6afab247..c9f682762e2 100644 --- a/Applications/PaintBrush/PickerTool.h +++ b/Applications/PaintBrush/PickerTool.h @@ -35,7 +35,7 @@ public: PickerTool(); virtual ~PickerTool() override; - virtual void on_mousedown(Layer&, GUI::MouseEvent&) override; + virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; private: virtual const char* class_name() const override { return "PickerTool"; } diff --git a/Applications/PaintBrush/RectangleTool.cpp b/Applications/PaintBrush/RectangleTool.cpp index a7a30fa17ab..d99a3e2de5a 100644 --- a/Applications/PaintBrush/RectangleTool.cpp +++ b/Applications/PaintBrush/RectangleTool.cpp @@ -62,7 +62,7 @@ void RectangleTool::draw_using(GUI::Painter& painter) } } -void RectangleTool::on_mousedown(Layer&, GUI::MouseEvent& event) +void RectangleTool::on_mousedown(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) { if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; @@ -76,7 +76,7 @@ void RectangleTool::on_mousedown(Layer&, GUI::MouseEvent& event) m_editor->update(); } -void RectangleTool::on_mouseup(Layer& layer, GUI::MouseEvent& event) +void RectangleTool::on_mouseup(Layer& layer, GUI::MouseEvent& event, GUI::MouseEvent&) { if (event.button() == m_drawing_button) { GUI::Painter painter(layer.bitmap()); @@ -86,7 +86,7 @@ void RectangleTool::on_mouseup(Layer& layer, GUI::MouseEvent& event) } } -void RectangleTool::on_mousemove(Layer&, GUI::MouseEvent& event) +void RectangleTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) { if (m_drawing_button == GUI::MouseButton::None) return; diff --git a/Applications/PaintBrush/RectangleTool.h b/Applications/PaintBrush/RectangleTool.h index 71871b4cb30..a34e3386b96 100644 --- a/Applications/PaintBrush/RectangleTool.h +++ b/Applications/PaintBrush/RectangleTool.h @@ -37,9 +37,9 @@ public: RectangleTool(); virtual ~RectangleTool() override; - virtual void on_mousedown(Layer&, GUI::MouseEvent&) override; - virtual void on_mousemove(Layer&, GUI::MouseEvent&) override; - virtual void on_mouseup(Layer&, GUI::MouseEvent&) override; + virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; virtual void on_contextmenu(GUI::ContextMenuEvent&) override; virtual void on_second_paint(GUI::PaintEvent&) override; virtual void on_keydown(GUI::KeyEvent&) override; diff --git a/Applications/PaintBrush/SprayTool.cpp b/Applications/PaintBrush/SprayTool.cpp index ff668002bab..5349ec3db5b 100644 --- a/Applications/PaintBrush/SprayTool.cpp +++ b/Applications/PaintBrush/SprayTool.cpp @@ -82,7 +82,7 @@ void SprayTool::paint_it() } } -void SprayTool::on_mousedown(Layer&, GUI::MouseEvent& event) +void SprayTool::on_mousedown(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) { if (!m_editor->rect().contains(event.position())) return; @@ -93,7 +93,7 @@ void SprayTool::on_mousedown(Layer&, GUI::MouseEvent& event) paint_it(); } -void SprayTool::on_mousemove(Layer&, GUI::MouseEvent& event) +void SprayTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) { m_last_pos = event.position(); if (m_timer->is_active()) { @@ -102,7 +102,7 @@ void SprayTool::on_mousemove(Layer&, GUI::MouseEvent& event) } } -void SprayTool::on_mouseup(Layer&, GUI::MouseEvent&) +void SprayTool::on_mouseup(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) { m_timer->stop(); } diff --git a/Applications/PaintBrush/SprayTool.h b/Applications/PaintBrush/SprayTool.h index d5e4564f9d0..5a4f2ba75b1 100644 --- a/Applications/PaintBrush/SprayTool.h +++ b/Applications/PaintBrush/SprayTool.h @@ -38,9 +38,9 @@ public: SprayTool(); virtual ~SprayTool() override; - virtual void on_mousedown(Layer&, GUI::MouseEvent&) override; - virtual void on_mouseup(Layer&, GUI::MouseEvent&) override; - virtual void on_mousemove(Layer&, GUI::MouseEvent&) override; + virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; + virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& original_event) override; virtual void on_contextmenu(GUI::ContextMenuEvent&) override; private: diff --git a/Applications/PaintBrush/Tool.h b/Applications/PaintBrush/Tool.h index 2ef8a0920c7..ddb4ce53153 100644 --- a/Applications/PaintBrush/Tool.h +++ b/Applications/PaintBrush/Tool.h @@ -39,9 +39,9 @@ public: virtual const char* class_name() const = 0; - virtual void on_mousedown(Layer&, GUI::MouseEvent&) {} - virtual void on_mousemove(Layer&, GUI::MouseEvent&) {} - virtual void on_mouseup(Layer&, GUI::MouseEvent&) {} + virtual void on_mousedown(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) {} + virtual void on_mousemove(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) {} + virtual void on_mouseup(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) {} virtual void on_contextmenu(GUI::ContextMenuEvent&) {} virtual void on_second_paint(GUI::PaintEvent&) {} virtual void on_keydown(GUI::KeyEvent&) {} diff --git a/Applications/PaintBrush/ToolboxWidget.cpp b/Applications/PaintBrush/ToolboxWidget.cpp index 9dda50ea2f5..b21b0d11907 100644 --- a/Applications/PaintBrush/ToolboxWidget.cpp +++ b/Applications/PaintBrush/ToolboxWidget.cpp @@ -29,6 +29,7 @@ #include "EllipseTool.h" #include "EraseTool.h" #include "LineTool.h" +#include "MoveTool.h" #include "PaintableWidget.h" #include "PenTool.h" #include "PickerTool.h" @@ -92,6 +93,7 @@ ToolboxWidget::ToolboxWidget() }; }; + add_tool("Move", "move", make()); add_tool("Pen", "pen", make()); add_tool("Bucket Fill", "bucket", make()); add_tool("Spray", "spray", make());