diff --git a/Userland/Applications/PixelPaint/BrushTool.h b/Userland/Applications/PixelPaint/BrushTool.h index bb96b93f38..f09e9b706a 100644 --- a/Userland/Applications/PixelPaint/BrushTool.h +++ b/Userland/Applications/PixelPaint/BrushTool.h @@ -19,6 +19,7 @@ public: virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual GUI::Widget* get_properties_widget() override; + virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } private: RefPtr m_properties_widget; diff --git a/Userland/Applications/PixelPaint/EllipseTool.h b/Userland/Applications/PixelPaint/EllipseTool.h index 7fa27685e1..a37d4bfad1 100644 --- a/Userland/Applications/PixelPaint/EllipseTool.h +++ b/Userland/Applications/PixelPaint/EllipseTool.h @@ -23,6 +23,7 @@ public: virtual void on_second_paint(Layer const&, GUI::PaintEvent&) override; virtual void on_keydown(GUI::KeyEvent&) override; virtual GUI::Widget* get_properties_widget() override; + virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } private: enum class Mode { diff --git a/Userland/Applications/PixelPaint/GuideTool.h b/Userland/Applications/PixelPaint/GuideTool.h index 6c3d85c07a..57616d31cf 100644 --- a/Userland/Applications/PixelPaint/GuideTool.h +++ b/Userland/Applications/PixelPaint/GuideTool.h @@ -24,6 +24,7 @@ public: virtual void on_context_menu(Layer&, GUI::ContextMenuEvent&) override; virtual GUI::Widget* get_properties_widget() override; + virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } private: RefPtr closest_guide(Gfx::IntPoint const&); diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 080416be4e..f180b5e110 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -181,6 +181,7 @@ void ImageEditor::mousedown_event(GUI::MouseEvent& event) if (event.button() == GUI::MouseButton::Middle) { m_click_position = event.position(); m_saved_pan_origin = m_pan_origin; + set_override_cursor(Gfx::StandardCursor::Drag); return; } @@ -227,6 +228,8 @@ void ImageEditor::mousemove_event(GUI::MouseEvent& event) void ImageEditor::mouseup_event(GUI::MouseEvent& event) { + set_override_cursor(m_active_cursor); + if (!m_active_layer || !m_active_tool) return; auto layer_event = event_adjusted_for_layer(event, *m_active_layer); @@ -265,8 +268,15 @@ void ImageEditor::keyup_event(GUI::KeyEvent& event) m_active_tool->on_keyup(event); } +void ImageEditor::enter_event(Core::Event&) +{ + set_override_cursor(m_active_cursor); +} + void ImageEditor::leave_event(Core::Event&) { + set_override_cursor(Gfx::StandardCursor::None); + if (on_leave) on_leave(); } @@ -304,8 +314,10 @@ void ImageEditor::set_active_tool(Tool* tool) m_active_tool = tool; - if (m_active_tool) + if (m_active_tool) { m_active_tool->setup(*this); + m_active_cursor = m_active_tool->cursor(); + } } void ImageEditor::layers_did_change() diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h index 5c3f09f2fc..122892699f 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.h +++ b/Userland/Applications/PixelPaint/ImageEditor.h @@ -100,6 +100,7 @@ private: virtual void keyup_event(GUI::KeyEvent&) override; virtual void context_menu_event(GUI::ContextMenuEvent&) override; virtual void resize_event(GUI::ResizeEvent&) override; + virtual void enter_event(Core::Event&) override; virtual void leave_event(Core::Event&) override; virtual void image_did_change(Gfx::IntRect const&) override; @@ -130,6 +131,8 @@ private: Gfx::FloatPoint m_saved_pan_origin; Gfx::IntPoint m_click_position; + Gfx::StandardCursor m_active_cursor { Gfx::StandardCursor::None }; + Selection m_selection; }; diff --git a/Userland/Applications/PixelPaint/LineTool.h b/Userland/Applications/PixelPaint/LineTool.h index d61cf1bd9d..92652b11e7 100644 --- a/Userland/Applications/PixelPaint/LineTool.h +++ b/Userland/Applications/PixelPaint/LineTool.h @@ -23,6 +23,7 @@ public: virtual void on_second_paint(Layer const&, GUI::PaintEvent&) override; virtual void on_keydown(GUI::KeyEvent&) override; virtual GUI::Widget* get_properties_widget() override; + virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } private: RefPtr m_properties_widget; diff --git a/Userland/Applications/PixelPaint/MoveTool.cpp b/Userland/Applications/PixelPaint/MoveTool.cpp index 16dc056316..8c7a7203a6 100644 --- a/Userland/Applications/PixelPaint/MoveTool.cpp +++ b/Userland/Applications/PixelPaint/MoveTool.cpp @@ -32,7 +32,6 @@ void MoveTool::on_mousedown(Layer& layer, GUI::MouseEvent& event, GUI::MouseEven m_layer_being_moved = layer; m_event_origin = image_event.position(); m_layer_origin = layer.location(); - m_editor->window()->set_cursor(Gfx::StandardCursor::Move); } void MoveTool::on_mousemove(Layer&, GUI::MouseEvent&, GUI::MouseEvent& image_event) @@ -49,7 +48,6 @@ void MoveTool::on_mouseup(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&) if (event.button() != GUI::MouseButton::Left) return; m_layer_being_moved = nullptr; - m_editor->window()->set_cursor(Gfx::StandardCursor::None); m_editor->did_complete_action(); } diff --git a/Userland/Applications/PixelPaint/MoveTool.h b/Userland/Applications/PixelPaint/MoveTool.h index a0ac9c1115..0f4552ebf0 100644 --- a/Userland/Applications/PixelPaint/MoveTool.h +++ b/Userland/Applications/PixelPaint/MoveTool.h @@ -19,6 +19,7 @@ public: virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_keydown(GUI::KeyEvent&) override; + virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Move; } private: RefPtr m_layer_being_moved; diff --git a/Userland/Applications/PixelPaint/PenTool.h b/Userland/Applications/PixelPaint/PenTool.h index 8d4b8bea8f..da88e18204 100644 --- a/Userland/Applications/PixelPaint/PenTool.h +++ b/Userland/Applications/PixelPaint/PenTool.h @@ -21,6 +21,7 @@ public: virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual GUI::Widget* get_properties_widget() override; + virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } private: Gfx::IntPoint m_last_drawing_event_position { -1, -1 }; diff --git a/Userland/Applications/PixelPaint/PickerTool.h b/Userland/Applications/PixelPaint/PickerTool.h index d64c3a16ea..6b467d9a92 100644 --- a/Userland/Applications/PixelPaint/PickerTool.h +++ b/Userland/Applications/PixelPaint/PickerTool.h @@ -16,6 +16,7 @@ public: virtual ~PickerTool() override; virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; + virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } }; } diff --git a/Userland/Applications/PixelPaint/RectangleSelectTool.h b/Userland/Applications/PixelPaint/RectangleSelectTool.h index 866dc417fa..9a0a27cd91 100644 --- a/Userland/Applications/PixelPaint/RectangleSelectTool.h +++ b/Userland/Applications/PixelPaint/RectangleSelectTool.h @@ -26,6 +26,7 @@ public: virtual void on_keyup(GUI::KeyEvent&) override; virtual void on_second_paint(Layer const&, GUI::PaintEvent&) override; virtual GUI::Widget* get_properties_widget() override; + virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } private: enum class MovingMode { diff --git a/Userland/Applications/PixelPaint/RectangleTool.h b/Userland/Applications/PixelPaint/RectangleTool.h index 5395f73605..361698f1f3 100644 --- a/Userland/Applications/PixelPaint/RectangleTool.h +++ b/Userland/Applications/PixelPaint/RectangleTool.h @@ -23,6 +23,7 @@ public: virtual void on_second_paint(Layer const&, GUI::PaintEvent&) override; virtual void on_keydown(GUI::KeyEvent&) override; virtual GUI::Widget* get_properties_widget() override; + virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } private: enum class Mode { diff --git a/Userland/Applications/PixelPaint/SprayTool.h b/Userland/Applications/PixelPaint/SprayTool.h index 551056d06b..a8ed8da0ec 100644 --- a/Userland/Applications/PixelPaint/SprayTool.h +++ b/Userland/Applications/PixelPaint/SprayTool.h @@ -22,6 +22,7 @@ public: virtual void on_mouseup(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual void on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override; virtual GUI::Widget* get_properties_widget() override; + virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } private: void paint_it(); diff --git a/Userland/Applications/PixelPaint/Tool.h b/Userland/Applications/PixelPaint/Tool.h index 17ec76fb56..2cb115481b 100644 --- a/Userland/Applications/PixelPaint/Tool.h +++ b/Userland/Applications/PixelPaint/Tool.h @@ -8,6 +8,7 @@ #include #include +#include namespace PixelPaint { @@ -27,6 +28,7 @@ public: virtual void on_keydown(GUI::KeyEvent&) { } virtual void on_keyup(GUI::KeyEvent&) { } virtual GUI::Widget* get_properties_widget() { return nullptr; } + virtual Gfx::StandardCursor cursor() { return Gfx::StandardCursor::None; } void clear() { m_editor = nullptr; } void setup(ImageEditor&);