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.

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