1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 02:07:35 +00:00

PixelPaint: Add Tool::tool_name() as a single-point-of-truth

Let the tools know what their names are.
This commit is contained in:
Andreas Kling 2022-08-21 20:25:52 +02:00
parent c45f99f735
commit 101eb53de5
16 changed files with 46 additions and 16 deletions

View file

@ -36,6 +36,8 @@ public:
}
protected:
virtual StringView tool_name() const override { return "Brush Tool"sv; }
virtual Color color_for(GUI::MouseEvent const& event);
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point);
virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end);

View file

@ -21,6 +21,8 @@ public:
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> 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 };

View file

@ -29,6 +29,8 @@ protected:
virtual void on_keyup(GUI::KeyEvent&) override;
private:
virtual StringView tool_name() const override { return "Clone Tool"sv; }
RefPtr<GUI::Widget> m_properties_widget;
Optional<Gfx::IntPoint> m_sample_location;

View file

@ -29,6 +29,8 @@ public:
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; }
private:
virtual StringView tool_name() const override { return "Ellipse Tool"sv; }
enum class FillMode {
Outline,
Fill

View file

@ -27,6 +27,8 @@ protected:
virtual void draw_point(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& point) override;
private:
virtual StringView tool_name() const override { return "Erase Tool"sv; }
RefPtr<GUI::Widget> m_properties_widget;
enum class DrawMode {

View file

@ -31,6 +31,8 @@ public:
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; }
private:
virtual StringView tool_name() const override { return "Guide Tool"sv; }
RefPtr<Guide> closest_guide(Gfx::IntPoint const&);
RefPtr<GUI::Widget> m_properties_widget;

View file

@ -29,6 +29,8 @@ public:
void draw_using(GUI::Painter&, Gfx::IntPoint const& start_position, Gfx::IntPoint const& end_position, Color color, int thickness);
private:
virtual StringView tool_name() const override { return "Line Tool"sv; }
RefPtr<GUI::Widget> m_properties_widget;
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };

View file

@ -24,6 +24,8 @@ public:
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Move; }
private:
virtual StringView tool_name() const override { return "Move Tool"sv; }
RefPtr<Layer> m_layer_being_moved;
Gfx::IntPoint m_event_origin;
Gfx::IntPoint m_layer_origin;

View file

@ -26,6 +26,8 @@ protected:
virtual void draw_line(Gfx::Bitmap& bitmap, Gfx::Color const& color, Gfx::IntPoint const& start, Gfx::IntPoint const& end) override;
private:
virtual StringView tool_name() const override { return "Pen Tool"sv; }
RefPtr<GUI::Widget> m_properties_widget;
};

View file

@ -23,6 +23,8 @@ public:
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Eyedropper; }
private:
virtual StringView tool_name() const override { return "Picker Tool"sv; }
RefPtr<GUI::Widget> m_properties_widget;
bool m_sample_all_layers { false };
};

View file

@ -30,6 +30,8 @@ public:
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; }
private:
virtual StringView tool_name() const override { return "Rectangle Select Tool"sv; }
enum class MovingMode {
MovingOrigin,
AroundCenter,

View file

@ -28,6 +28,8 @@ public:
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; }
private:
virtual StringView tool_name() const override { return "Rectangle Tool"sv; }
enum class FillMode {
Outline,
Fill,

View file

@ -26,6 +26,8 @@ public:
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Crosshair; }
private:
virtual StringView tool_name() const override { return "Spray Tool"sv; }
void paint_it();
RefPtr<GUI::Widget> m_properties_widget;

View file

@ -74,6 +74,8 @@ public:
GUI::Action* action() { return m_action; }
void set_action(GUI::Action*);
virtual StringView tool_name() const = 0;
protected:
Tool() = default;
WeakPtr<ImageEditor> m_editor;

View file

@ -22,6 +22,8 @@ public:
virtual Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor() override { return Gfx::StandardCursor::Zoom; }
private:
virtual StringView tool_name() const override { return "Zoom Tool"sv; }
RefPtr<GUI::Widget> m_properties_widget;
double m_sensitivity { 0.5 };
};