summaryrefslogtreecommitdiff
path: root/Applications/PaintBrush/EllipseTool.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-12 23:44:46 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-12 23:44:46 +0200
commit83d24dcb1d4d921c4d1c9f85ca97808b2a463b32 (patch)
tree6b2d88a0584d6dc4cccf718f3751f892a203f394 /Applications/PaintBrush/EllipseTool.cpp
parent7dd8f1b921c5c63c21415a6ded179134a18e1ae2 (diff)
downloadserenity-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/EllipseTool.cpp')
-rw-r--r--Applications/PaintBrush/EllipseTool.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/Applications/PaintBrush/EllipseTool.cpp b/Applications/PaintBrush/EllipseTool.cpp
index b0f5f80b5a..661005bf2f 100644
--- a/Applications/PaintBrush/EllipseTool.cpp
+++ b/Applications/PaintBrush/EllipseTool.cpp
@@ -25,6 +25,8 @@
*/
#include "EllipseTool.h"
+#include "ImageEditor.h"
+#include "Layer.h"
#include "PaintableWidget.h"
#include <LibGUI/Action.h>
#include <LibGUI/Menu.h>
@@ -32,6 +34,8 @@
#include <LibGfx/Rect.h>
#include <LibM/math.h>
+namespace PaintBrush {
+
EllipseTool::EllipseTool()
{
}
@@ -45,14 +49,14 @@ void EllipseTool::draw_using(GUI::Painter& painter)
auto ellipse_intersecting_rect = Gfx::Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position);
switch (m_mode) {
case Mode::Outline:
- painter.draw_ellipse_intersecting(ellipse_intersecting_rect, m_widget->color_for(m_drawing_button), m_thickness);
+ painter.draw_ellipse_intersecting(ellipse_intersecting_rect, PaintableWidget::the().color_for(m_drawing_button), m_thickness);
break;
default:
ASSERT_NOT_REACHED();
}
}
-void EllipseTool::on_mousedown(GUI::MouseEvent& event)
+void EllipseTool::on_mousedown(Layer&, GUI::MouseEvent& event)
{
if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right)
return;
@@ -63,29 +67,29 @@ void EllipseTool::on_mousedown(GUI::MouseEvent& event)
m_drawing_button = event.button();
m_ellipse_start_position = event.position();
m_ellipse_end_position = event.position();
- m_widget->update();
+ m_editor->update();
}
-void EllipseTool::on_mouseup(GUI::MouseEvent& event)
+void EllipseTool::on_mouseup(Layer& layer, GUI::MouseEvent& event)
{
if (event.button() == m_drawing_button) {
- GUI::Painter painter(m_widget->bitmap());
+ GUI::Painter painter(layer.bitmap());
draw_using(painter);
m_drawing_button = GUI::MouseButton::None;
- m_widget->update();
+ m_editor->update();
}
}
-void EllipseTool::on_mousemove(GUI::MouseEvent& event)
+void EllipseTool::on_mousemove(Layer& layer, GUI::MouseEvent& event)
{
if (m_drawing_button == GUI::MouseButton::None)
return;
- if (!m_widget->rect().contains(event.position()))
+ if (!layer.rect().contains(event.position()))
return;
m_ellipse_end_position = event.position();
- m_widget->update();
+ m_editor->update();
}
void EllipseTool::on_second_paint(GUI::PaintEvent& event)
@@ -93,7 +97,7 @@ void EllipseTool::on_second_paint(GUI::PaintEvent& event)
if (m_drawing_button == GUI::MouseButton::None)
return;
- GUI::Painter painter(*m_widget);
+ GUI::Painter painter(*m_editor);
painter.add_clip_rect(event.rect());
draw_using(painter);
}
@@ -102,7 +106,7 @@ void EllipseTool::on_keydown(GUI::KeyEvent& event)
{
if (event.key() == Key_Escape && m_drawing_button != GUI::MouseButton::None) {
m_drawing_button = GUI::MouseButton::None;
- m_widget->update();
+ m_editor->update();
event.accept();
}
}
@@ -131,3 +135,5 @@ void EllipseTool::on_contextmenu(GUI::ContextMenuEvent& event)
}
m_context_menu->popup(event.screen_position());
}
+
+}