diff --git a/Applications/PaintBrush/BucketTool.cpp b/Applications/PaintBrush/BucketTool.cpp index 7c5bde56ec..d7aed49e4d 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 8749025d1e..8052f018dd 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 661005bf2f..9dc39225be 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 3638920bcd..3223404c91 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 e1aa1c913c..90403df340 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 8384b8e8fe..f610a80220 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 99b5f3f91d..95018fdfe6 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 e2a071334b..a714130cf1 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 a30286ac5e..ad64e4c1e2 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 8a88850c0a..c6514a09b4 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 0000000000..a1b20125a7 --- /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 0000000000..b4718dcb2b --- /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 2891bdba98..326db74100 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 b0c7c46f9a..432410ba38 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 2994869dd8..5af72c7935 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 34e6afab24..c9f682762e 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 a7a30fa17a..d99a3e2de5 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 71871b4cb3..a34e3386b9 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 ff668002ba..5349ec3db5 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 d5e4564f9d..5a4f2ba75b 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 2ef8a0920c..ddb4ce5315 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 9dda50ea2f..b21b0d1190 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());