1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

Add a simple spray fill tool

Could do with some more tweaking no doubt, and it'd be nice to have a
circular spray, but this is better than nothing.
This commit is contained in:
Robin Burchell 2019-06-16 11:33:20 +02:00 committed by Andreas Kling
parent 940eb1bbeb
commit 502c54e39a
11 changed files with 143 additions and 32 deletions

View file

@ -32,6 +32,20 @@ void PaintableWidget::paint_event(GPaintEvent& event)
painter.blit({ 0, 0 }, *m_bitmap, m_bitmap->rect());
}
void PaintableWidget::set_tool(Tool* tool)
{
if (m_tool)
m_tool->clear();
m_tool = tool;
if (m_tool)
m_tool->setup(*this);
}
Tool* PaintableWidget::tool()
{
return m_tool;
}
Color PaintableWidget::color_for(const GMouseEvent& event)
{
if (event.buttons() & GMouseButton::Left)
@ -44,17 +58,17 @@ Color PaintableWidget::color_for(const GMouseEvent& event)
void PaintableWidget::mousedown_event(GMouseEvent& event)
{
if (m_tool)
m_tool->on_mousedown(*this, event);
m_tool->on_mousedown(event);
}
void PaintableWidget::mouseup_event(GMouseEvent& event)
{
if (m_tool)
m_tool->on_mouseup(*this, event);
m_tool->on_mouseup(event);
}
void PaintableWidget::mousemove_event(GMouseEvent& event)
{
if (m_tool)
m_tool->on_mousemove(*this, event);
m_tool->on_mousemove(event);
}