1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:27:35 +00:00

PaintBrush: Add a color picker tool.

This commit is contained in:
Andreas Kling 2019-06-22 12:05:35 +02:00
parent 41613e4303
commit 25fd847ef2
8 changed files with 71 additions and 2 deletions

View file

@ -0,0 +1,22 @@
#include "PickerTool.h"
#include <SharedGraphics/GraphicsBitmap.h>
PickerTool::PickerTool()
{
}
PickerTool::~PickerTool()
{
}
void PickerTool::on_mousedown(GMouseEvent& event)
{
ASSERT(m_widget);
if (!m_widget->bitmap().rect().contains(event.position()))
return;
auto color = m_widget->bitmap().get_pixel(event.position());
if (event.button() == GMouseButton::Left)
m_widget->set_primary_color(color);
else if (event.button() == GMouseButton::Right)
m_widget->set_secondary_color(color);
}