diff options
author | Marco Cutecchia <marco.cutecchia@outlook.it> | 2021-10-17 21:07:12 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-31 12:37:49 +0100 |
commit | 0f24678eafef9a10de796f5ed82360b941555def (patch) | |
tree | 505d1e6b9c39249e2393e2518dadc1eb957a2386 /Userland/Applications | |
parent | 116bb4888fb7c7f5c80091caca6f3cdf68ef6383 (diff) | |
download | serenity-0f24678eafef9a10de796f5ed82360b941555def.zip |
PixelPaint: Support using a bitmap as a tool's cursor
Diffstat (limited to 'Userland/Applications')
14 files changed, 16 insertions, 14 deletions
diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h index 92b08f6a34..7c4a20de2b 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.h +++ b/Userland/Applications/PixelPaint/ImageEditor.h @@ -11,6 +11,7 @@ #include "Guide.h" #include "Image.h" #include "Selection.h" +#include <AK/Variant.h> #include <LibGUI/Frame.h> #include <LibGUI/UndoStack.h> #include <LibGfx/Point.h> @@ -163,7 +164,7 @@ private: float m_pixel_grid_threshold { 15.0f }; - Gfx::StandardCursor m_active_cursor { Gfx::StandardCursor::None }; + Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> m_active_cursor { Gfx::StandardCursor::None }; Selection m_selection; }; diff --git a/Userland/Applications/PixelPaint/Tools/BrushTool.h b/Userland/Applications/PixelPaint/Tools/BrushTool.h index c4cca0a04c..846707424e 100644 --- a/Userland/Applications/PixelPaint/Tools/BrushTool.h +++ b/Userland/Applications/PixelPaint/Tools/BrushTool.h @@ -20,7 +20,7 @@ public: virtual void on_mousemove(Layer*, MouseEvent&) override; virtual void on_mouseup(Layer*, MouseEvent&) override; virtual GUI::Widget* get_properties_widget() override; - virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } void set_size(int size) { m_size = size; } int size() const { return m_size; } diff --git a/Userland/Applications/PixelPaint/Tools/CloneTool.cpp b/Userland/Applications/PixelPaint/Tools/CloneTool.cpp index 3e64180c58..b1e6d816f6 100644 --- a/Userland/Applications/PixelPaint/Tools/CloneTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/CloneTool.cpp @@ -52,7 +52,7 @@ void CloneTool::draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::Int BrushTool::draw_line(bitmap, color, start, end); } -Gfx::StandardCursor CloneTool::cursor() +Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> CloneTool::cursor() { if (m_is_selecting_location) return Gfx::StandardCursor::Eyedropper; diff --git a/Userland/Applications/PixelPaint/Tools/CloneTool.h b/Userland/Applications/PixelPaint/Tools/CloneTool.h index 100ac1aec9..b86dd7d4f2 100644 --- a/Userland/Applications/PixelPaint/Tools/CloneTool.h +++ b/Userland/Applications/PixelPaint/Tools/CloneTool.h @@ -16,7 +16,7 @@ public: virtual ~CloneTool() override = default; virtual GUI::Widget* get_properties_widget() override; - virtual Gfx::StandardCursor cursor() override; + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override; protected: virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) override; diff --git a/Userland/Applications/PixelPaint/Tools/EllipseTool.h b/Userland/Applications/PixelPaint/Tools/EllipseTool.h index 885ca2e781..7cc8722a66 100644 --- a/Userland/Applications/PixelPaint/Tools/EllipseTool.h +++ b/Userland/Applications/PixelPaint/Tools/EllipseTool.h @@ -24,7 +24,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; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } private: enum class FillMode { diff --git a/Userland/Applications/PixelPaint/Tools/GuideTool.h b/Userland/Applications/PixelPaint/Tools/GuideTool.h index 33faae84a4..fab699aedf 100644 --- a/Userland/Applications/PixelPaint/Tools/GuideTool.h +++ b/Userland/Applications/PixelPaint/Tools/GuideTool.h @@ -26,7 +26,7 @@ public: virtual void on_tool_activation() override; virtual GUI::Widget* get_properties_widget() override; - virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } private: RefPtr<Guide> closest_guide(Gfx::IntPoint const&); diff --git a/Userland/Applications/PixelPaint/Tools/LineTool.h b/Userland/Applications/PixelPaint/Tools/LineTool.h index fc99d07b1b..874c3b5ddd 100644 --- a/Userland/Applications/PixelPaint/Tools/LineTool.h +++ b/Userland/Applications/PixelPaint/Tools/LineTool.h @@ -23,7 +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; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } private: RefPtr<GUI::Widget> m_properties_widget; diff --git a/Userland/Applications/PixelPaint/Tools/MoveTool.h b/Userland/Applications/PixelPaint/Tools/MoveTool.h index 93631ff077..4fa391b7c5 100644 --- a/Userland/Applications/PixelPaint/Tools/MoveTool.h +++ b/Userland/Applications/PixelPaint/Tools/MoveTool.h @@ -19,7 +19,7 @@ public: virtual void on_mousemove(Layer*, MouseEvent&) override; virtual void on_mouseup(Layer*, MouseEvent&) override; virtual void on_keydown(GUI::KeyEvent&) override; - virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Move; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Move; } private: RefPtr<Layer> m_layer_being_moved; diff --git a/Userland/Applications/PixelPaint/Tools/PickerTool.h b/Userland/Applications/PixelPaint/Tools/PickerTool.h index 5a558bfbc9..564632e7dd 100644 --- a/Userland/Applications/PixelPaint/Tools/PickerTool.h +++ b/Userland/Applications/PixelPaint/Tools/PickerTool.h @@ -19,7 +19,7 @@ public: virtual void on_mousedown(Layer*, MouseEvent&) override; virtual GUI::Widget* get_properties_widget() override; - virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Eyedropper; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Eyedropper; } private: RefPtr<GUI::Widget> m_properties_widget; diff --git a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h index 94705d7b7b..9216db6705 100644 --- a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h +++ b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h @@ -26,7 +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; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } private: enum class MovingMode { diff --git a/Userland/Applications/PixelPaint/Tools/RectangleTool.h b/Userland/Applications/PixelPaint/Tools/RectangleTool.h index 6ff2bb1e12..410893da0c 100644 --- a/Userland/Applications/PixelPaint/Tools/RectangleTool.h +++ b/Userland/Applications/PixelPaint/Tools/RectangleTool.h @@ -24,7 +24,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; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } private: enum class FillMode { diff --git a/Userland/Applications/PixelPaint/Tools/SprayTool.h b/Userland/Applications/PixelPaint/Tools/SprayTool.h index 9f08bdfb44..1b492433f9 100644 --- a/Userland/Applications/PixelPaint/Tools/SprayTool.h +++ b/Userland/Applications/PixelPaint/Tools/SprayTool.h @@ -22,7 +22,7 @@ public: virtual void on_mouseup(Layer*, MouseEvent&) override; virtual void on_mousemove(Layer*, MouseEvent&) override; virtual GUI::Widget* get_properties_widget() override; - virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } private: void paint_it(); diff --git a/Userland/Applications/PixelPaint/Tools/Tool.h b/Userland/Applications/PixelPaint/Tools/Tool.h index 82b6508c5b..f72f06d2fc 100644 --- a/Userland/Applications/PixelPaint/Tools/Tool.h +++ b/Userland/Applications/PixelPaint/Tools/Tool.h @@ -7,6 +7,7 @@ #pragma once +#include <AK/Variant.h> #include <LibGUI/Event.h> #include <LibGUI/Forward.h> #include <LibGUI/ValueSlider.h> @@ -60,7 +61,7 @@ public: virtual void on_keyup(GUI::KeyEvent&) { } virtual void on_tool_activation() { } virtual GUI::Widget* get_properties_widget() { return nullptr; } - virtual Gfx::StandardCursor cursor() { return Gfx::StandardCursor::None; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() { return Gfx::StandardCursor::None; } void clear() { m_editor = nullptr; } void setup(ImageEditor&); diff --git a/Userland/Applications/PixelPaint/Tools/ZoomTool.h b/Userland/Applications/PixelPaint/Tools/ZoomTool.h index c9ca019aae..be1a3558fb 100644 --- a/Userland/Applications/PixelPaint/Tools/ZoomTool.h +++ b/Userland/Applications/PixelPaint/Tools/ZoomTool.h @@ -19,7 +19,7 @@ public: virtual void on_mousedown(Layer*, MouseEvent&) override; virtual GUI::Widget* get_properties_widget() override; - virtual Gfx::StandardCursor cursor() override { return Gfx::StandardCursor::Zoom; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Zoom; } private: RefPtr<GUI::Widget> m_properties_widget; |