PaintBrush: Make the line, rectangle and ellipsis preview work again

You can now see what you're drawing before committing to it. This works
by passing the second_paint_event from the ImageEditor to the tool.
We also pass the active layer which makes it easier for the tool to
keep his logic in layer-relative coordinates even while drawing preview
states directly into the ImageEditor backing bitmap.
This commit is contained in:
Andreas Kling 2020-05-13 13:41:12 +02:00
commit 96d03546ef
Notes: sideshowbarker 2024-07-19 06:40:51 +09:00
9 changed files with 20 additions and 17 deletions

View file

@ -96,18 +96,15 @@ void LineTool::on_mousemove(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)
m_editor->update();
}
void LineTool::on_second_paint(GUI::PaintEvent& event)
void LineTool::on_second_paint(const Layer& layer, GUI::PaintEvent& event)
{
if (m_drawing_button == GUI::MouseButton::None)
return;
(void)event;
#if 0
GUI::Painter painter(*m_widget);
GUI::Painter painter(*m_editor);
painter.add_clip_rect(event.rect());
painter.translate(layer.location());
painter.draw_line(m_line_start_position, m_line_end_position, m_editor->color_for(m_drawing_button), m_thickness);
#endif
}
void LineTool::on_keydown(GUI::KeyEvent& event)