blob: 0fd91f9264570feff4684b3ad6c7f2587df0cc7e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
/*
* 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);
}
}
|