mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:07:45 +00:00
PixelPaint: Make Layer passed to tools a pointer
Some tools (e.g. ZoomTool) doesn't need layer to work. This commit makes mouse events fire even if there is no layer. This fixes a bug that ZoomTool didn't work when there is no layers.
This commit is contained in:
parent
0224dc2882
commit
3ad9df1522
28 changed files with 202 additions and 136 deletions
|
@ -70,18 +70,21 @@ static void flood_fill(Gfx::Bitmap& bitmap, Gfx::IntPoint const& start_position,
|
|||
}
|
||||
}
|
||||
|
||||
void BucketTool::on_mousedown(Layer& layer, MouseEvent& event)
|
||||
void BucketTool::on_mousedown(Layer* layer, MouseEvent& event)
|
||||
{
|
||||
auto& layer_event = event.layer_event();
|
||||
if (!layer.rect().contains(layer_event.position()))
|
||||
if (!layer)
|
||||
return;
|
||||
|
||||
GUI::Painter painter(layer.bitmap());
|
||||
auto target_color = layer.bitmap().get_pixel(layer_event.x(), layer_event.y());
|
||||
auto& layer_event = event.layer_event();
|
||||
if (!layer->rect().contains(layer_event.position()))
|
||||
return;
|
||||
|
||||
flood_fill(layer.bitmap(), layer_event.position(), target_color, m_editor->color_for(layer_event), m_threshold);
|
||||
GUI::Painter painter(layer->bitmap());
|
||||
auto target_color = layer->bitmap().get_pixel(layer_event.x(), layer_event.y());
|
||||
|
||||
layer.did_modify_bitmap();
|
||||
flood_fill(layer->bitmap(), layer_event.position(), target_color, m_editor->color_for(layer_event), m_threshold);
|
||||
|
||||
layer->did_modify_bitmap();
|
||||
m_editor->did_complete_action();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue