diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-12 23:44:46 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-12 23:44:46 +0200 |
commit | 83d24dcb1d4d921c4d1c9f85ca97808b2a463b32 (patch) | |
tree | 6b2d88a0584d6dc4cccf718f3751f892a203f394 /Applications/PaintBrush/EraseTool.cpp | |
parent | 7dd8f1b921c5c63c21415a6ded179134a18e1ae2 (diff) | |
download | serenity-83d24dcb1d4d921c4d1c9f85ca97808b2a463b32.zip |
PaintBrush: Port all the existing toolbox tools to the Layer world :^)
Many tools are not working perfectly right yet, but we'll fix them!
Diffstat (limited to 'Applications/PaintBrush/EraseTool.cpp')
-rw-r--r-- | Applications/PaintBrush/EraseTool.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/Applications/PaintBrush/EraseTool.cpp b/Applications/PaintBrush/EraseTool.cpp index 6b21a36116..e1aa1c913c 100644 --- a/Applications/PaintBrush/EraseTool.cpp +++ b/Applications/PaintBrush/EraseTool.cpp @@ -25,12 +25,16 @@ */ #include "EraseTool.h" +#include "ImageEditor.h" +#include "Layer.h" #include "PaintableWidget.h" #include <LibGUI/Action.h> #include <LibGUI/Menu.h> #include <LibGUI/Painter.h> #include <LibGfx/Bitmap.h> +namespace PaintBrush { + EraseTool::EraseTool() { } @@ -49,26 +53,26 @@ Gfx::Rect EraseTool::build_rect(const Gfx::Point& pos, const Gfx::Rect& widget_r return Gfx::Rect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect); } -void EraseTool::on_mousedown(GUI::MouseEvent& event) +void EraseTool::on_mousedown(Layer& layer, GUI::MouseEvent& event) { if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; - Gfx::Rect r = build_rect(event.position(), m_widget->bitmap().rect()); - GUI::Painter painter(m_widget->bitmap()); + Gfx::Rect r = build_rect(event.position(), layer.rect()); + GUI::Painter painter(layer.bitmap()); painter.clear_rect(r, get_color()); - m_widget->update(); + m_editor->update(); } -void EraseTool::on_mousemove(GUI::MouseEvent& event) +void EraseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event) { - if (!m_widget->rect().contains(event.position())) + if (!m_editor->rect().contains(event.position())) return; if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) { - Gfx::Rect r = build_rect(event.position(), m_widget->bitmap().rect()); - GUI::Painter painter(m_widget->bitmap()); + Gfx::Rect r = build_rect(event.position(), layer.rect()); + GUI::Painter painter(layer.bitmap()); painter.clear_rect(r, get_color()); - m_widget->update(); + m_editor->update(); } } @@ -106,6 +110,8 @@ void EraseTool::on_contextmenu(GUI::ContextMenuEvent& event) Color EraseTool::get_color() const { if (m_use_secondary_color) - return m_widget->secondary_color(); + return PaintableWidget::the().secondary_color(); return Color(255, 255, 255, 0); } + +} |