mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
PixelPaint: Support using a bitmap as a tool's cursor
This commit is contained in:
parent
116bb4888f
commit
0f24678eaf
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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&);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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&);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue