summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTimothy Slater <tslater2006@gmail.com>2022-10-26 18:33:43 -0500
committerSam Atkins <atkinssj@gmail.com>2022-12-16 10:14:20 +0000
commita321df12e155b6ba7fb8905f444a454133506fb5 (patch)
tree9edcdcb21e6e301d6db5b2b136382b8a0ebee74c /Userland
parentd28c9ba054112cda3788cef73e5abccecfeefc66 (diff)
downloadserenity-a321df12e155b6ba7fb8905f444a454133506fb5.zip
PixelPaint: Allow tools to know when the user has left them
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/PixelPaint/ImageEditor.cpp4
-rw-r--r--Userland/Applications/PixelPaint/Tools/Tool.h1
2 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp
index e4212781a4..8de57a6fb9 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 0662e46f80..4f056ab5a5 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<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() { return Gfx::StandardCursor::None; }
virtual Gfx::IntPoint point_position_to_preferred_cell(Gfx::FloatPoint position) const { return position.to_type<int>(); }