From 167906d02b3fd0e47fc7c81783f662ae95e8431d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 1 Jan 2021 15:55:48 +0100 Subject: [PATCH] PixelPaint: Remove hand-rolled type information in favor of RTTI --- Applications/PixelPaint/BrushTool.h | 1 - Applications/PixelPaint/BucketTool.h | 2 -- Applications/PixelPaint/EllipseTool.h | 1 - Applications/PixelPaint/EraseTool.h | 1 - Applications/PixelPaint/ImageEditor.cpp | 3 ++- Applications/PixelPaint/LineTool.h | 2 -- Applications/PixelPaint/MoveTool.h | 3 --- Applications/PixelPaint/PenTool.h | 2 -- Applications/PixelPaint/PickerTool.h | 3 --- Applications/PixelPaint/RectangleTool.h | 1 - Applications/PixelPaint/SprayTool.h | 1 - Applications/PixelPaint/Tool.h | 4 ---- 12 files changed, 2 insertions(+), 22 deletions(-) diff --git a/Applications/PixelPaint/BrushTool.h b/Applications/PixelPaint/BrushTool.h index 9c42932413c..939ccdeef4d 100644 --- a/Applications/PixelPaint/BrushTool.h +++ b/Applications/PixelPaint/BrushTool.h @@ -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); }; diff --git a/Applications/PixelPaint/BucketTool.h b/Applications/PixelPaint/BucketTool.h index 2760302c446..b4bf7008154 100644 --- a/Applications/PixelPaint/BucketTool.h +++ b/Applications/PixelPaint/BucketTool.h @@ -39,8 +39,6 @@ public: virtual GUI::Widget* get_properties_widget() override; private: - virtual const char* class_name() const override { return "BucketTool"; } - RefPtr m_properties_widget; int m_threshold { 0 }; }; diff --git a/Applications/PixelPaint/EllipseTool.h b/Applications/PixelPaint/EllipseTool.h index fb4a82b74a8..0b1c10c89ab 100644 --- a/Applications/PixelPaint/EllipseTool.h +++ b/Applications/PixelPaint/EllipseTool.h @@ -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 }; diff --git a/Applications/PixelPaint/EraseTool.h b/Applications/PixelPaint/EraseTool.h index b41f628a8fc..16241e87f04 100644 --- a/Applications/PixelPaint/EraseTool.h +++ b/Applications/PixelPaint/EraseTool.h @@ -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 m_context_menu; diff --git a/Applications/PixelPaint/ImageEditor.cpp b/Applications/PixelPaint/ImageEditor.cpp index 33b8b8b713a..f29551c0508 100644 --- a/Applications/PixelPaint/ImageEditor.cpp +++ b/Applications/PixelPaint/ImageEditor.cpp @@ -27,6 +27,7 @@ #include "ImageEditor.h" #include "Image.h" #include "Layer.h" +#include "MoveTool.h" #include "Tool.h" #include #include @@ -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(*m_active_tool)) { if (auto* other_layer = layer_at_editor_position(event.position())) { set_active_layer(other_layer); } diff --git a/Applications/PixelPaint/LineTool.h b/Applications/PixelPaint/LineTool.h index 9655a3b629d..aa8757655ce 100644 --- a/Applications/PixelPaint/LineTool.h +++ b/Applications/PixelPaint/LineTool.h @@ -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; diff --git a/Applications/PixelPaint/MoveTool.h b/Applications/PixelPaint/MoveTool.h index b680c71bc16..a0c16e52824 100644 --- a/Applications/PixelPaint/MoveTool.h +++ b/Applications/PixelPaint/MoveTool.h @@ -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 m_layer_being_moved; Gfx::IntPoint m_event_origin; Gfx::IntPoint m_layer_origin; diff --git a/Applications/PixelPaint/PenTool.h b/Applications/PixelPaint/PenTool.h index e5740993073..137e58251ea 100644 --- a/Applications/PixelPaint/PenTool.h +++ b/Applications/PixelPaint/PenTool.h @@ -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 m_context_menu; RefPtr m_properties_widget; diff --git a/Applications/PixelPaint/PickerTool.h b/Applications/PixelPaint/PickerTool.h index 327dfffcb27..163a0aeeee6 100644 --- a/Applications/PixelPaint/PickerTool.h +++ b/Applications/PixelPaint/PickerTool.h @@ -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"; } }; } diff --git a/Applications/PixelPaint/RectangleTool.h b/Applications/PixelPaint/RectangleTool.h index 4288c862351..f7d8c53273e 100644 --- a/Applications/PixelPaint/RectangleTool.h +++ b/Applications/PixelPaint/RectangleTool.h @@ -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 }; diff --git a/Applications/PixelPaint/SprayTool.h b/Applications/PixelPaint/SprayTool.h index 827832bc4cc..a3e55efd528 100644 --- a/Applications/PixelPaint/SprayTool.h +++ b/Applications/PixelPaint/SprayTool.h @@ -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 m_properties_widget; diff --git a/Applications/PixelPaint/Tool.h b/Applications/PixelPaint/Tool.h index 812e0edd2ab..e7deb5f1cb1 100644 --- a/Applications/PixelPaint/Tool.h +++ b/Applications/PixelPaint/Tool.h @@ -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&);