mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-23 19:42:53 +00:00
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.
36 lines
768 B
C++
36 lines
768 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "PickerTool.h"
|
|
#include "ImageEditor.h"
|
|
#include "Layer.h"
|
|
|
|
namespace PixelPaint {
|
|
|
|
PickerTool::PickerTool()
|
|
{
|
|
}
|
|
|
|
PickerTool::~PickerTool()
|
|
{
|
|
}
|
|
|
|
void PickerTool::on_mousedown(Layer* layer, MouseEvent& event)
|
|
{
|
|
if (!layer)
|
|
return;
|
|
|
|
auto& layer_event = event.layer_event();
|
|
if (!layer->rect().contains(layer_event.position()))
|
|
return;
|
|
auto color = layer->bitmap().get_pixel(layer_event.position());
|
|
if (layer_event.button() == GUI::MouseButton::Left)
|
|
m_editor->set_primary_color(color);
|
|
else if (layer_event.button() == GUI::MouseButton::Right)
|
|
m_editor->set_secondary_color(color);
|
|
}
|
|
|
|
}
|