diff options
author | Andreas Kling <kling@serenityos.org> | 2023-02-19 23:23:37 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-21 00:54:04 +0100 |
commit | df07416171b08439b2b820c2d05a50e7d722a689 (patch) | |
tree | 3f722d9ab39a19da1d295dbe22abb1c76cf495b4 | |
parent | 65710bf3f7b49936639516155da2422dd471b76e (diff) | |
download | serenity-df07416171b08439b2b820c2d05a50e7d722a689.zip |
PixelPaint: Store tool cursors as NNRP<Gfx::Bitmap const>
24 files changed, 26 insertions, 26 deletions
diff --git a/Userland/Applications/PixelPaint/ImageEditor.h b/Userland/Applications/PixelPaint/ImageEditor.h index 9142ca67ee..2ea71b84ba 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.h +++ b/Userland/Applications/PixelPaint/ImageEditor.h @@ -187,7 +187,7 @@ private: float m_pixel_grid_threshold { 15.0f }; - Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> m_active_cursor { Gfx::StandardCursor::None }; + Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> m_active_cursor { Gfx::StandardCursor::None }; bool m_loaded_from_image { true }; diff --git a/Userland/Applications/PixelPaint/Tools/BrushTool.h b/Userland/Applications/PixelPaint/Tools/BrushTool.h index 646b6452b7..adb3f84398 100644 --- a/Userland/Applications/PixelPaint/Tools/BrushTool.h +++ b/Userland/Applications/PixelPaint/Tools/BrushTool.h @@ -23,7 +23,7 @@ public: virtual void on_mousemove(Layer*, MouseEvent&) override; virtual void on_mouseup(Layer*, MouseEvent&) override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { if (m_editor && m_editor->scale() != m_scale_last_created_cursor) refresh_editor_cursor(); @@ -59,7 +59,7 @@ private: bool m_was_drawing { false }; bool m_has_clicked { false }; Gfx::IntPoint m_last_position; - NonnullRefPtr<Gfx::Bitmap> m_cursor = build_cursor(); + NonnullRefPtr<Gfx::Bitmap const> m_cursor = build_cursor(); }; } diff --git a/Userland/Applications/PixelPaint/Tools/BucketTool.cpp b/Userland/Applications/PixelPaint/Tools/BucketTool.cpp index ee71fd15c2..4fc56ce9e1 100644 --- a/Userland/Applications/PixelPaint/Tools/BucketTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/BucketTool.cpp @@ -24,7 +24,7 @@ namespace PixelPaint { BucketTool::BucketTool() { - m_cursor = Gfx::Bitmap::load_from_file("/res/icons/pixelpaint/bucket.png"sv).release_value_but_fixme_should_propagate_errors(); + m_cursor = NonnullRefPtr<Gfx::Bitmap const> { Gfx::Bitmap::load_from_file("/res/icons/pixelpaint/bucket.png"sv).release_value_but_fixme_should_propagate_errors() }; } static void flood_fill(Gfx::Bitmap& bitmap, Gfx::IntPoint start_position, Color fill_color, int threshold) diff --git a/Userland/Applications/PixelPaint/Tools/BucketTool.h b/Userland/Applications/PixelPaint/Tools/BucketTool.h index a5c5dcddb3..09bf0d4c5f 100644 --- a/Userland/Applications/PixelPaint/Tools/BucketTool.h +++ b/Userland/Applications/PixelPaint/Tools/BucketTool.h @@ -18,14 +18,14 @@ public: virtual void on_mousedown(Layer*, MouseEvent&) override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return m_cursor; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return m_cursor; } private: virtual StringView tool_name() const override { return "Bucket Tool"sv; } RefPtr<GUI::Widget> m_properties_widget; int m_threshold { 0 }; - Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> m_cursor { Gfx::StandardCursor::Crosshair }; + Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> m_cursor { Gfx::StandardCursor::Crosshair }; }; } diff --git a/Userland/Applications/PixelPaint/Tools/CloneTool.cpp b/Userland/Applications/PixelPaint/Tools/CloneTool.cpp index f2872140b8..6f3a6d333b 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 color, Gfx::IntPoint s BrushTool::draw_line(bitmap, color, start, end); } -Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> CloneTool::cursor() +Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> 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 7785444878..5a8af4bf77 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 ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override; + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override; virtual bool is_overriding_alt() override { return true; } diff --git a/Userland/Applications/PixelPaint/Tools/EllipseTool.h b/Userland/Applications/PixelPaint/Tools/EllipseTool.h index cc3c6ccb26..0e0601ac50 100644 --- a/Userland/Applications/PixelPaint/Tools/EllipseTool.h +++ b/Userland/Applications/PixelPaint/Tools/EllipseTool.h @@ -26,7 +26,7 @@ public: virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override; virtual bool on_keydown(GUI::KeyEvent&) override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Crosshair; } private: virtual StringView tool_name() const override { return "Ellipse Tool"sv; } diff --git a/Userland/Applications/PixelPaint/Tools/GradientTool.cpp b/Userland/Applications/PixelPaint/Tools/GradientTool.cpp index 3f46f26f7f..b8f7181ecd 100644 --- a/Userland/Applications/PixelPaint/Tools/GradientTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/GradientTool.cpp @@ -24,7 +24,7 @@ namespace PixelPaint { -Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> GradientTool::cursor() +Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> GradientTool::cursor() { if (m_hover_over_drag_handle || m_hover_over_start_handle || m_hover_over_end_handle) return Gfx::StandardCursor::Hand; diff --git a/Userland/Applications/PixelPaint/Tools/GradientTool.h b/Userland/Applications/PixelPaint/Tools/GradientTool.h index eb48b479bc..0ced524a2a 100644 --- a/Userland/Applications/PixelPaint/Tools/GradientTool.h +++ b/Userland/Applications/PixelPaint/Tools/GradientTool.h @@ -25,7 +25,7 @@ public: virtual void on_tool_activation() override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override; + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override; virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override; protected: diff --git a/Userland/Applications/PixelPaint/Tools/GuideTool.h b/Userland/Applications/PixelPaint/Tools/GuideTool.h index 40ea2e194a..a87207699c 100644 --- a/Userland/Applications/PixelPaint/Tools/GuideTool.h +++ b/Userland/Applications/PixelPaint/Tools/GuideTool.h @@ -28,7 +28,7 @@ public: virtual void on_tool_activation() override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Crosshair; } private: virtual StringView tool_name() const override { return "Guide Tool"sv; } diff --git a/Userland/Applications/PixelPaint/Tools/LineTool.h b/Userland/Applications/PixelPaint/Tools/LineTool.h index 0f63006501..b362b0f971 100644 --- a/Userland/Applications/PixelPaint/Tools/LineTool.h +++ b/Userland/Applications/PixelPaint/Tools/LineTool.h @@ -24,7 +24,7 @@ public: virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override; virtual bool on_keydown(GUI::KeyEvent&) override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Crosshair; } void draw_using(GUI::Painter&, Gfx::IntPoint start_position, Gfx::IntPoint end_position, Color color, int thickness); diff --git a/Userland/Applications/PixelPaint/Tools/MoveTool.cpp b/Userland/Applications/PixelPaint/Tools/MoveTool.cpp index 835e4727e4..0dd4a902ef 100644 --- a/Userland/Applications/PixelPaint/Tools/MoveTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/MoveTool.cpp @@ -274,7 +274,7 @@ Optional<ResizeAnchorLocation const> MoveTool::resize_anchor_location_from_curso return {}; } -Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> MoveTool::cursor() +Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> MoveTool::cursor() { if (m_resize_anchor_location.has_value()) { switch (m_resize_anchor_location.value()) { diff --git a/Userland/Applications/PixelPaint/Tools/MoveTool.h b/Userland/Applications/PixelPaint/Tools/MoveTool.h index a5224c714e..456a7e17af 100644 --- a/Userland/Applications/PixelPaint/Tools/MoveTool.h +++ b/Userland/Applications/PixelPaint/Tools/MoveTool.h @@ -36,7 +36,7 @@ public: virtual void on_keyup(GUI::KeyEvent&) override; virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override; + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override; virtual bool is_overriding_alt() override { return true; } LayerSelectionMode layer_selection_mode() const { return m_layer_selection_mode; } diff --git a/Userland/Applications/PixelPaint/Tools/PenTool.h b/Userland/Applications/PixelPaint/Tools/PenTool.h index 4aa1a2986b..0452337209 100644 --- a/Userland/Applications/PixelPaint/Tools/PenTool.h +++ b/Userland/Applications/PixelPaint/Tools/PenTool.h @@ -18,7 +18,7 @@ class PenTool final : public BrushTool { public: PenTool(); virtual ~PenTool() override = default; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Crosshair; } virtual ErrorOr<GUI::Widget*> get_properties_widget() override; protected: diff --git a/Userland/Applications/PixelPaint/Tools/PickerTool.h b/Userland/Applications/PixelPaint/Tools/PickerTool.h index c6a87fb5af..1a82423fee 100644 --- a/Userland/Applications/PixelPaint/Tools/PickerTool.h +++ b/Userland/Applications/PixelPaint/Tools/PickerTool.h @@ -22,7 +22,7 @@ public: virtual void on_mousemove(Layer*, MouseEvent&) override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Eyedropper; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Eyedropper; } private: virtual StringView tool_name() const override { return "Picker Tool"sv; } diff --git a/Userland/Applications/PixelPaint/Tools/PolygonalSelectTool.h b/Userland/Applications/PixelPaint/Tools/PolygonalSelectTool.h index bcdca79c3f..68677a5e8a 100644 --- a/Userland/Applications/PixelPaint/Tools/PolygonalSelectTool.h +++ b/Userland/Applications/PixelPaint/Tools/PolygonalSelectTool.h @@ -23,7 +23,7 @@ public: virtual bool on_keydown(GUI::KeyEvent&) override; virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Crosshair; } virtual Gfx::IntPoint point_position_to_preferred_cell(Gfx::FloatPoint position) const override; private: diff --git a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h index 4ef9b28d9d..7bbb7eae96 100644 --- a/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h +++ b/Userland/Applications/PixelPaint/Tools/RectangleSelectTool.h @@ -27,7 +27,7 @@ public: virtual void on_keyup(GUI::KeyEvent&) override; virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Crosshair; } virtual Gfx::IntPoint point_position_to_preferred_cell(Gfx::FloatPoint position) const override; private: diff --git a/Userland/Applications/PixelPaint/Tools/RectangleTool.h b/Userland/Applications/PixelPaint/Tools/RectangleTool.h index eb042b3e87..11e4471865 100644 --- a/Userland/Applications/PixelPaint/Tools/RectangleTool.h +++ b/Userland/Applications/PixelPaint/Tools/RectangleTool.h @@ -25,7 +25,7 @@ public: virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override; virtual bool on_keydown(GUI::KeyEvent&) override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Crosshair; } private: virtual StringView tool_name() const override { return "Rectangle Tool"sv; } diff --git a/Userland/Applications/PixelPaint/Tools/SprayTool.h b/Userland/Applications/PixelPaint/Tools/SprayTool.h index 9a0c586eb6..19c0d704c0 100644 --- a/Userland/Applications/PixelPaint/Tools/SprayTool.h +++ b/Userland/Applications/PixelPaint/Tools/SprayTool.h @@ -23,7 +23,7 @@ public: virtual void on_mouseup(Layer*, MouseEvent&) override; virtual void on_mousemove(Layer*, MouseEvent&) override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Crosshair; } private: virtual StringView tool_name() const override { return "Spray Tool"sv; } diff --git a/Userland/Applications/PixelPaint/Tools/TextTool.cpp b/Userland/Applications/PixelPaint/Tools/TextTool.cpp index 4bad020fb4..3a030571df 100644 --- a/Userland/Applications/PixelPaint/Tools/TextTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/TextTool.cpp @@ -304,7 +304,7 @@ bool TextTool::on_keydown(GUI::KeyEvent& event) return true; } -Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> TextTool::cursor() +Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> TextTool::cursor() { if (m_mouse_is_over_text) return Gfx::StandardCursor::Move; diff --git a/Userland/Applications/PixelPaint/Tools/TextTool.h b/Userland/Applications/PixelPaint/Tools/TextTool.h index 1396290d30..bbf56bf9f5 100644 --- a/Userland/Applications/PixelPaint/Tools/TextTool.h +++ b/Userland/Applications/PixelPaint/Tools/TextTool.h @@ -40,7 +40,7 @@ public: virtual void on_second_paint(Layer const*, GUI::PaintEvent&) override; virtual void on_primary_color_change(Color) override; virtual void on_tool_deactivation() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override; + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; private: diff --git a/Userland/Applications/PixelPaint/Tools/Tool.h b/Userland/Applications/PixelPaint/Tools/Tool.h index 0d240b9656..745a7d6a22 100644 --- a/Userland/Applications/PixelPaint/Tools/Tool.h +++ b/Userland/Applications/PixelPaint/Tools/Tool.h @@ -68,7 +68,7 @@ public: virtual void on_tool_activation() { } virtual void on_tool_deactivation() { } virtual ErrorOr<GUI::Widget*> get_properties_widget() { return nullptr; } - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() { return Gfx::StandardCursor::None; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() { return Gfx::StandardCursor::None; } virtual Gfx::IntPoint point_position_to_preferred_cell(Gfx::FloatPoint position) const { return position.to_type<int>(); } void clear() { m_editor = nullptr; } diff --git a/Userland/Applications/PixelPaint/Tools/WandSelectTool.h b/Userland/Applications/PixelPaint/Tools/WandSelectTool.h index 5c4c8a5e37..e0241af396 100644 --- a/Userland/Applications/PixelPaint/Tools/WandSelectTool.h +++ b/Userland/Applications/PixelPaint/Tools/WandSelectTool.h @@ -24,7 +24,7 @@ public: virtual void on_mousedown(Layer*, MouseEvent& event) override; virtual bool on_keydown(GUI::KeyEvent&) override; virtual ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Crosshair; } private: virtual StringView tool_name() const override { return "Wand Select Tool"sv; } diff --git a/Userland/Applications/PixelPaint/Tools/ZoomTool.h b/Userland/Applications/PixelPaint/Tools/ZoomTool.h index 85fdcc02f0..867b305c09 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 ErrorOr<GUI::Widget*> get_properties_widget() override; - virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Zoom; } + virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor() override { return Gfx::StandardCursor::Zoom; } private: virtual StringView tool_name() const override { return "Zoom Tool"sv; } |