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:
parent
41613e4303
commit
25fd847ef2
8 changed files with 71 additions and 2 deletions
22
Applications/PaintBrush/PickerTool.cpp
Normal file
22
Applications/PaintBrush/PickerTool.cpp
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue