Source Code (Use browser search to find items of interest.)
Class Index
kimageshop'ColorPicker (./koffice/kimageshop/tools/kis_tool_colorpicker.h:29)
class ColorPicker : public KisTool
{
public:
ColorPicker(KisDoc *doc, KisView *view);
~ColorPicker();
QString toolName() { return QString("Color picker"); }
KisColor pick(int x, int y);
public slots:
virtual void mousePress(QMouseEvent*);
};
kimageshop'ColorPicker::ColorPicker() (./koffice/kimageshop/tools/kis_tool_colorpicker.cc:26)
ColorPicker::ColorPicker(KisDoc *doc, KisView *view)
: KisTool(doc, view)
{
m_Cursor = KisCursor::pickerCursor();
}
kimageshop'ColorPicker::~ColorPicker() (./koffice/kimageshop/tools/kis_tool_colorpicker.cc:32)
ColorPicker::~ColorPicker() {}
kimageshop'ColorPicker::pick() (./koffice/kimageshop/tools/kis_tool_colorpicker.cc:34)
KisColor ColorPicker::pick(int x, int y)
{
KisImage * img = m_pDoc->current();
KisLayer *lay = img->getCurrentLayer();
if (!img) return KisColor::white();
if (!lay) return KisColor::white();
// FIXME: Implement this for non-RGB modes.
if (!img->colorMode() == cm_RGB
&& !img->colorMode() == cm_RGBA)
return KisColor::white();
int r = lay->pixel(0, x, y);
int g = lay->pixel(1, x, y);
int b = lay->pixel(2, x, y);
return KisColor(r, g, b, cs_RGB);
}
kimageshop'ColorPicker::mousePress() (./koffice/kimageshop/tools/kis_tool_colorpicker.cc:52)
void ColorPicker::mousePress(QMouseEvent *e)
{
KisImage * img = m_pDoc->current();
if (!img)
return;
if (e->button() != QMouseEvent::LeftButton
&& e->button() != QMouseEvent::RightButton)
return;
if( !img->getCurrentLayer()->visible() )
return;
if( !img->getCurrentLayer()->imageExtents().contains( e->pos() ))
return;
if (e->button() == QMouseEvent::LeftButton)
m_pView->slotSetFGColor(pick(e->pos().x(), e->pos().y()));
else if (e->button() == QMouseEvent::RightButton)
m_pView->slotSetBGColor(pick(e->pos().x(), e->pos().y()));
}