Commit c67c1cf2 authored by Mathias Wein's avatar Mathias Wein

Include reference images in screen color picker

KisScreenColorPicker works directly on the krita canvas when
possible for full color gamut, but in contrast to the other
color picking tools was not taking reference images into account.

Also check against visibleRegion() instead of rect() to choose
the correct document subwindow when they overlap.

BUG:411816
parent 535ca1fc
......@@ -33,7 +33,9 @@
#include "kis_icon.h"
#include "kis_image.h"
#include "kis_wrapped_rect.h"
#include "KisDocument.h"
#include "KisPart.h"
#include "KisReferenceImagesLayer.h"
#include "KisScreenColorPicker.h"
#include "KisDlgInternalColorSelector.h"
......@@ -133,14 +135,25 @@ KoColor KisScreenColorPicker::grabScreenColor(const QPoint &p)
{
// First check whether we're clicking on a Krita window for some real color picking
Q_FOREACH(KisView *view, KisPart::instance()->views()) {
QWidget *canvasWidget = view->canvasBase()->canvasWidget();
const KisCanvas2 *canvas = view->canvasBase();
const QWidget *canvasWidget = canvas->canvasWidget();
QPoint widgetPoint = canvasWidget->mapFromGlobal(p);
if (canvasWidget->rect().contains(widgetPoint)) {
QPointF imagePoint = view->canvasBase()->coordinatesConverter()->widgetToImage(widgetPoint);
if (canvasWidget->visibleRegion().contains(widgetPoint)) {
KisImageWSP image = view->image();
if (image) {
QPointF imagePoint = canvas->coordinatesConverter()->widgetToImage(widgetPoint);
// pick from reference images first
KisSharedPtr<KisReferenceImagesLayer> referenceImageLayer = view->document()->referenceImagesLayer();
if (referenceImageLayer && canvas->referenceImagesDecoration()->visible()) {
QColor color = referenceImageLayer->getPixel(imagePoint);
if (color.isValid()) {
return KoColor(color, image->colorSpace());
}
}
if (image->wrapAroundModePermitted()) {
imagePoint = KisWrappedRect::ptToWrappedPt(imagePoint.toPoint(), image->bounds());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment