From a321df12e155b6ba7fb8905f444a454133506fb5 Mon Sep 17 00:00:00 2001 From: Timothy Slater Date: Wed, 26 Oct 2022 18:33:43 -0500 Subject: [PATCH] PixelPaint: Allow tools to know when the user has left them --- Userland/Applications/PixelPaint/ImageEditor.cpp | 4 +++- Userland/Applications/PixelPaint/Tools/Tool.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index e4212781a4e..8de57a6fb97 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -521,8 +521,10 @@ void ImageEditor::set_active_tool(Tool* tool) return; } - if (m_active_tool) + if (m_active_tool) { + m_active_tool->on_tool_deactivation(); m_active_tool->clear(); + } m_active_tool = tool; diff --git a/Userland/Applications/PixelPaint/Tools/Tool.h b/Userland/Applications/PixelPaint/Tools/Tool.h index 0662e46f804..4f056ab5a56 100644 --- a/Userland/Applications/PixelPaint/Tools/Tool.h +++ b/Userland/Applications/PixelPaint/Tools/Tool.h @@ -64,6 +64,7 @@ public: virtual bool on_keydown(GUI::KeyEvent const&); virtual void on_keyup(GUI::KeyEvent&) { } virtual void on_tool_activation() { } + virtual void on_tool_deactivation() { } virtual GUI::Widget* get_properties_widget() { return nullptr; } virtual Variant> cursor() { return Gfx::StandardCursor::None; } virtual Gfx::IntPoint point_position_to_preferred_cell(Gfx::FloatPoint position) const { return position.to_type(); }