1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:17:45 +00:00

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
This commit is contained in:
Fausto Tommasi 2022-10-13 21:32:23 -05:00 committed by Linus Groh
parent 66c039c66f
commit 813ca5ebbe
6 changed files with 40 additions and 18 deletions

View file

@ -16,25 +16,10 @@ namespace PixelPaint {
void PickerTool::on_mousedown(Layer* layer, MouseEvent& event)
{
auto& position = event.layer_event().position();
Color color;
if (m_sample_all_layers) {
color = m_editor->image().color_at(position);
} else {
if (!layer || !layer->rect().contains(position))
return;
color = layer->currently_edited_bitmap().get_pixel(position);
}
// We picked a transparent pixel, do nothing.
if (!color.alpha())
if (!layer)
return;
if (event.layer_event().button() == GUI::MouseButton::Primary)
m_editor->set_primary_color(color);
else if (event.layer_event().button() == GUI::MouseButton::Secondary)
m_editor->set_secondary_color(color);
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()