diff options
author | Timothy Slater <tslater2006@gmail.com> | 2022-08-31 18:41:10 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-19 23:04:07 +0200 |
commit | 20f6485311b0f3f6bfb8c92fe2a4a587695bbbc6 (patch) | |
tree | 18d988ef6a976245eda12f12be780f3fbc65cac1 /Userland/Applications | |
parent | 7b163573e651ea18188130773a4e38fb92ecc25e (diff) | |
download | serenity-20f6485311b0f3f6bfb8c92fe2a4a587695bbbc6.zip |
PixelPaint: Pass doubleclick events to tools
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/PixelPaint/ImageEditor.cpp | 8 | ||||
-rw-r--r-- | Userland/Applications/PixelPaint/ImageEditor.h | 1 | ||||
-rw-r--r-- | Userland/Applications/PixelPaint/Tools/Tool.h | 2 |
3 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 7e9abeedb5..e23ae92859 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -356,6 +356,14 @@ void ImageEditor::mousedown_event(GUI::MouseEvent& event) m_active_tool->on_mousedown(m_active_layer.ptr(), tool_event); } +void ImageEditor::doubleclick_event(GUI::MouseEvent& event) +{ + auto layer_event = m_active_layer ? event_adjusted_for_layer(event, *m_active_layer) : event; + auto image_event = event_with_pan_and_scale_applied(event); + Tool::MouseEvent tool_event(Tool::MouseEvent::Action::DoubleClick, layer_event, image_event, event); + m_active_tool->on_doubleclick(m_active_layer.ptr(), tool_event); +} + void ImageEditor::mousemove_event(GUI::MouseEvent& event) { m_mouse_position = event.position(); diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h index 39d0df4f5b..fc1997458b 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.h +++ b/Userland/Applications/PixelPaint/ImageEditor.h @@ -125,6 +125,7 @@ private: virtual void paint_event(GUI::PaintEvent&) override; virtual void second_paint_event(GUI::PaintEvent&) override; + virtual void doubleclick_event(GUI::MouseEvent&) override; virtual void mousedown_event(GUI::MouseEvent&) override; virtual void mousemove_event(GUI::MouseEvent&) override; virtual void mouseup_event(GUI::MouseEvent&) override; diff --git a/Userland/Applications/PixelPaint/Tools/Tool.h b/Userland/Applications/PixelPaint/Tools/Tool.h index c3140e5ebc..f6df95eb20 100644 --- a/Userland/Applications/PixelPaint/Tools/Tool.h +++ b/Userland/Applications/PixelPaint/Tools/Tool.h @@ -27,6 +27,7 @@ public: class MouseEvent { public: enum class Action { + DoubleClick, MouseDown, MouseMove, MouseUp @@ -53,6 +54,7 @@ public: GUI::MouseEvent& m_raw_event; }; + virtual void on_doubleclick(Layer*, MouseEvent&) { } virtual void on_mousedown(Layer*, MouseEvent&) { } virtual void on_mousemove(Layer*, MouseEvent&) { } virtual void on_mouseup(Layer*, MouseEvent&) { } |