mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
PixelPaint: Remove hand-rolled type information in favor of RTTI
This commit is contained in:
parent
ef5e9af6d3
commit
167906d02b
Notes:
sideshowbarker
2024-07-19 00:16:16 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/167906d02b3
12 changed files with 2 additions and 22 deletions
|
@ -47,7 +47,6 @@ private:
|
|||
bool m_was_drawing { false };
|
||||
Gfx::IntPoint m_last_position;
|
||||
|
||||
virtual const char* class_name() const override { return "BrushTool"; }
|
||||
void draw_line(Gfx::Bitmap& bitmap, const Gfx::Color& color, const Gfx::IntPoint& start, const Gfx::IntPoint& end);
|
||||
void draw_point(Gfx::Bitmap& bitmap, const Gfx::Color& color, const Gfx::IntPoint& point);
|
||||
};
|
||||
|
|
|
@ -39,8 +39,6 @@ public:
|
|||
virtual GUI::Widget* get_properties_widget() override;
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "BucketTool"; }
|
||||
|
||||
RefPtr<GUI::Widget> m_properties_widget;
|
||||
int m_threshold { 0 };
|
||||
};
|
||||
|
|
|
@ -50,7 +50,6 @@ private:
|
|||
// FIXME: Add Mode::Fill
|
||||
};
|
||||
|
||||
virtual const char* class_name() const override { return "EllipseTool"; }
|
||||
void draw_using(GUI::Painter&, const Gfx::IntRect&);
|
||||
|
||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||
|
|
|
@ -45,7 +45,6 @@ public:
|
|||
|
||||
private:
|
||||
Gfx::Color get_color() const;
|
||||
virtual const char* class_name() const override { return "EraseTool"; }
|
||||
Gfx::IntRect build_rect(const Gfx::IntPoint& pos, const Gfx::IntRect& widget_rect);
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "ImageEditor.h"
|
||||
#include "Image.h"
|
||||
#include "Layer.h"
|
||||
#include "MoveTool.h"
|
||||
#include "Tool.h"
|
||||
#include <LibGUI/Command.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
|
@ -203,7 +204,7 @@ void ImageEditor::mousedown_event(GUI::MouseEvent& event)
|
|||
if (!m_active_tool)
|
||||
return;
|
||||
|
||||
if (m_active_tool->is_move_tool()) {
|
||||
if (is<MoveTool>(*m_active_tool)) {
|
||||
if (auto* other_layer = layer_at_editor_position(event.position())) {
|
||||
set_active_layer(other_layer);
|
||||
}
|
||||
|
|
|
@ -46,8 +46,6 @@ public:
|
|||
virtual void on_keyup(GUI::KeyEvent&) override;
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "LineTool"; }
|
||||
|
||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||
Gfx::IntPoint m_line_start_position;
|
||||
Gfx::IntPoint m_line_end_position;
|
||||
|
|
|
@ -42,9 +42,6 @@ public:
|
|||
virtual void on_context_menu(Layer&, GUI::ContextMenuEvent&) override;
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "MoveTool"; }
|
||||
virtual bool is_move_tool() const override { return true; }
|
||||
|
||||
RefPtr<Layer> m_layer_being_moved;
|
||||
Gfx::IntPoint m_event_origin;
|
||||
Gfx::IntPoint m_layer_origin;
|
||||
|
|
|
@ -44,8 +44,6 @@ public:
|
|||
virtual GUI::Widget* get_properties_widget() override;
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "PenTool"; }
|
||||
|
||||
Gfx::IntPoint m_last_drawing_event_position { -1, -1 };
|
||||
RefPtr<GUI::Menu> m_context_menu;
|
||||
RefPtr<GUI::Widget> m_properties_widget;
|
||||
|
|
|
@ -36,9 +36,6 @@ public:
|
|||
virtual ~PickerTool() override;
|
||||
|
||||
virtual void on_mousedown(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEvent& image_event) override;
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "PickerTool"; }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,6 @@ private:
|
|||
Gradient,
|
||||
};
|
||||
|
||||
virtual const char* class_name() const override { return "RectangleTool"; }
|
||||
void draw_using(GUI::Painter&, const Gfx::IntRect&);
|
||||
|
||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||
|
|
|
@ -45,7 +45,6 @@ public:
|
|||
virtual GUI::Widget* get_properties_widget() override;
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "SprayTool"; }
|
||||
void paint_it();
|
||||
|
||||
RefPtr<GUI::Widget> m_properties_widget;
|
||||
|
|
|
@ -38,8 +38,6 @@ class Tool {
|
|||
public:
|
||||
virtual ~Tool();
|
||||
|
||||
virtual const char* class_name() const = 0;
|
||||
|
||||
virtual void on_mousedown(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) { }
|
||||
virtual void on_mousemove(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) { }
|
||||
virtual void on_mouseup(Layer&, GUI::MouseEvent&, GUI::MouseEvent&) { }
|
||||
|
@ -50,8 +48,6 @@ public:
|
|||
virtual void on_keyup(GUI::KeyEvent&) { }
|
||||
virtual GUI::Widget* get_properties_widget() { return nullptr; }
|
||||
|
||||
virtual bool is_move_tool() const { return false; }
|
||||
|
||||
void clear() { m_editor = nullptr; }
|
||||
void setup(ImageEditor&);
|
||||
|
||||
|
|
Loading…
Reference in a new issue