1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 16:55:07 +00:00
serenity/Userland/Applications/PixelPaint/Tools/PickerTool.cpp
Fausto Tommasi 813ca5ebbe PixelPaint: Make Alt-Clicking with all tool act like the PickerTool
Refactored PickerTool functionality to the ImageEditor level and added a
flag to Tool Base Class to allow for tools to override Alt+Click
ColorPicker functionality
2022-10-17 09:39:57 +02:00

41 lines
1.1 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Mustafa Quraish <mustafa@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "PickerTool.h"
#include "../ImageEditor.h"
#include "../Layer.h"
#include <LibGUI/BoxLayout.h>
#include <LibGUI/CheckBox.h>
namespace PixelPaint {
void PickerTool::on_mousedown(Layer* layer, MouseEvent& event)
{
if (!layer)
return;
auto layer_event = event.layer_event();
m_editor->set_editor_color_to_color_at_mouse_position(layer_event, m_sample_all_layers);
}
GUI::Widget* PickerTool::get_properties_widget()
{
if (!m_properties_widget) {
m_properties_widget = GUI::Widget::construct();
m_properties_widget->set_layout<GUI::VerticalBoxLayout>();
auto& sample_checkbox = m_properties_widget->add<GUI::CheckBox>("Sample all layers");
sample_checkbox.set_checked(m_sample_all_layers);
sample_checkbox.on_checked = [&](bool value) {
m_sample_all_layers = value;
};
}
return m_properties_widget.ptr();
}
}