[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-kimageshop
Subject: Re: [calligra/calligra/2.9] krita/ui: [FEATURE] Add on-canvas preview of current color
From: Ramón_Miranda <mirandagraphic () gmail ! com>
Date: 2015-05-11 8:13:35
Message-ID: CAJ6UeULN85ZrRyMw2KbxXF2Ayo2nvhv=Nego3RFEttq59oMqTw () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Sounds cool. Thanks for the feature
2015-05-10 15:23 GMT+02:00 Dmitry Kazakov <dimula73@gmail.com>:
> Git commit 55d7eaebed3923da01150a38654df8a4fe3b199d by Dmitry Kazakov.
> Committed on 10/05/2015 at 13:23.
> Pushed by dkazakov into branch 'calligra/2.9'.
>
> [FEATURE] Add on-canvas preview of current color
>
> 1) Now when activating color picker in the brush tool
> with Ctrl or any other shortcut, currently selected color
> will be displayed near the cursor on screen.
>
> 2) If you start actual color-picking, the two colors will be
> compared side-by-side.
>
> BUG:338128
> Fixes task T206
> CC:kimageshop@kde.org
>
> M +10 -0 krita/ui/kis_config.cc
> M +3 -0 krita/ui/kis_config.h
> M +111 -8 krita/ui/tool/kis_tool_paint.cc
> M +14 -1 krita/ui/tool/kis_tool_paint.h
>
> http://commits.kde.org/calligra/55d7eaebed3923da01150a38654df8a4fe3b199d
>
> diff --git a/krita/ui/kis_config.cc b/krita/ui/kis_config.cc
> index f9f96c7..b409a3f 100644
> --- a/krita/ui/kis_config.cc
> +++ b/krita/ui/kis_config.cc
> @@ -324,6 +324,16 @@ void KisConfig::setNewOutlineStyle(OutlineStyle style)
> m_cfg.writeEntry("newOutlineStyle", (int)style);
> }
>
> +QRect KisConfig::colorPreviewRect() const
> +{
> + return m_cfg.readEntry("colorPreviewRect", QVariant(QRect(32, 32, 48,
> 48))).toRect();
> +}
> +
> +void KisConfig::setColorPreviewRect(const QRect &rect)
> +{
> + m_cfg.writeEntry("colorPreviewRect", QVariant(rect));
> +}
> +
> bool KisConfig::useDirtyPresets(bool defaultValue) const
> {
> return (defaultValue ? false :
> m_cfg.readEntry("useDirtyPresets",false));
> diff --git a/krita/ui/kis_config.h b/krita/ui/kis_config.h
> index f68f881..43f52f8 100644
> --- a/krita/ui/kis_config.h
> +++ b/krita/ui/kis_config.h
> @@ -105,6 +105,9 @@ public:
> OutlineStyle newOutlineStyle(bool defaultValue = false) const;
> void setNewOutlineStyle(OutlineStyle style);
>
> + QRect colorPreviewRect() const;
> + void setColorPreviewRect(const QRect &rect);
> +
> /// get the profile the user has selected for the given screen
> QString monitorProfile(int screen) const;
> void setMonitorProfile(int screen, const QString & monitorProfile,
> bool override) const;
> diff --git a/krita/ui/tool/kis_tool_paint.cc
> b/krita/ui/tool/kis_tool_paint.cc
> index 00aa2a1..0c6b528 100644
> --- a/krita/ui/tool/kis_tool_paint.cc
> +++ b/krita/ui/tool/kis_tool_paint.cc
> @@ -60,6 +60,7 @@
> #include <KisViewManager.h>
> #include <kis_canvas2.h>
> #include <kis_cubic_curve.h>
> +#include "kis_display_color_converter.h"
>
> #include "kis_config.h"
> #include "kis_config_notifier.h"
> @@ -74,7 +75,8 @@
>
> KisToolPaint::KisToolPaint(KoCanvasBase * canvas, const QCursor & cursor)
> : KisTool(canvas, cursor),
> - m_isOutlineEnabled(false)
> + m_showColorPreview(false),
> + m_colorPreviewShowComparePlate(false)
> {
> m_specialHoverModifier = false;
> m_optionsWidgetLayout = 0;
> @@ -208,6 +210,16 @@ void KisToolPaint::paint(QPainter &gc, const
> KoViewConverter &converter)
>
> QPainterPath path = tryFixBrushOutline(pixelToView(m_currentOutline));
> paintToolOutline(&gc, path);
> +
> + if (m_showColorPreview) {
> + QRectF viewRect = converter.documentToView(m_oldColorPreviewRect);
> + gc.fillRect(viewRect, m_colorPreviewCurrentColor);
> +
> + if (m_colorPreviewShowComparePlate) {
> + QRectF baseColorRect = viewRect.translated(viewRect.width(),
> 0);
> + gc.fillRect(baseColorRect, m_colorPreviewBaseColor);
> + }
> + }
> }
>
> void KisToolPaint::setMode(ToolMode mode)
> @@ -222,22 +234,62 @@ void KisToolPaint::setMode(ToolMode mode)
> KisTool::setMode(mode);
> }
>
> +void KisToolPaint::activatePickColor(AlternateAction action)
> +{
> + m_showColorPreview = true;
> +
> + requestUpdateOutline(m_outlineDocPoint, 0);
> +
> + int resource = colorPreviewResourceId(action);
> + KoColor color =
> canvas()->resourceManager()->koColorResource(resource);
> +
> + KisCanvas2 * kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
> + KIS_ASSERT_RECOVER_RETURN(kisCanvas);
> +
> + m_colorPreviewCurrentColor =
> kisCanvas->displayColorConverter()->toQColor(color);
> +
> + if (!m_colorPreviewBaseColor.isValid()) {
> + m_colorPreviewBaseColor = m_colorPreviewCurrentColor;
> + }
> +}
> +
> +void KisToolPaint::deactivatePickColor(AlternateAction action)
> +{
> + Q_UNUSED(action);
> +
> + m_showColorPreview = false;
> + m_oldColorPreviewRect = QRect();
> + m_oldColorPreviewUpdateRect = QRect();
> + m_colorPreviewCurrentColor = QColor();
> +}
> +
> +void KisToolPaint::pickColorWasOverridden()
> +{
> + m_colorPreviewShowComparePlate = false;
> + m_colorPreviewBaseColor = QColor();
> +}
> +
> void KisToolPaint::activateAlternateAction(AlternateAction action)
> {
> switch (action) {
> case PickFgNode:
> useCursor(KisCursor::pickerLayerForegroundCursor());
> + activatePickColor(action);
> break;
> case PickBgNode:
> useCursor(KisCursor::pickerLayerBackgroundCursor());
> + activatePickColor(action);
> break;
> case PickFgImage:
> useCursor(KisCursor::pickerImageForegroundCursor());
> + activatePickColor(action);
> break;
> case PickBgImage:
> useCursor(KisCursor::pickerImageBackgroundCursor());
> + activatePickColor(action);
> break;
> default:
> + pickColorWasOverridden();
> KisTool::activateAlternateAction(action);
> };
> }
> @@ -254,6 +306,7 @@ void
> KisToolPaint::deactivateAlternateAction(AlternateAction action)
> }
>
> resetCursorStyle();
> + deactivatePickColor(action);
> }
>
> void KisToolPaint::beginAlternateAction(KoPointerEvent *event,
> AlternateAction action)
> @@ -271,6 +324,8 @@ void
> KisToolPaint::continueAlternateAction(KoPointerEvent *event, AlternateActio
> {
> if (!pickColor(event->point, action)) {
> KisTool::continueAlternateAction(event, action);
> + } else {
> + requestUpdateOutline(event->point, event);
> }
> }
>
> @@ -284,6 +339,15 @@ void KisToolPaint::endAlternateAction(KoPointerEvent
> *event, AlternateAction act
> }
> }
>
> +int KisToolPaint::colorPreviewResourceId(AlternateAction action)
> +{
> + bool toForegroundColor = action == PickFgNode || action ==
> PickFgImage;
> + int resource = toForegroundColor ?
> + KoCanvasResourceManager::ForegroundColor :
> KoCanvasResourceManager::BackgroundColor;
> +
> + return resource;
> +}
> +
> bool KisToolPaint::pickColor(const QPointF &documentPixel,
> AlternateAction action)
> {
> @@ -295,11 +359,9 @@ bool KisToolPaint::pickColor(const QPointF
> &documentPixel,
> return false;
> }
>
> - bool toForegroundColor = action == PickFgNode || action ==
> PickFgImage;
> bool fromCurrentNode = action == PickFgNode || action == PickBgNode;
>
> - int resource = toForegroundColor ?
> - KoCanvasResourceManager::ForegroundColor :
> KoCanvasResourceManager::BackgroundColor;
> + int resource = colorPreviewResourceId(action);
>
> KisPaintDeviceSP device = fromCurrentNode ?
> currentNode()->projection() : image()->projection();
> @@ -307,10 +369,19 @@ bool KisToolPaint::pickColor(const QPointF
> &documentPixel,
> QPoint imagePoint = image()->documentToIntPixel(documentPixel);
>
> KoColor color;
> + QColor previewColor;
> +
> if (KisToolUtils::pick(device, imagePoint, &color)) {
> canvas()->resourceManager()->setResource(resource, color);
> +
> + KisCanvas2 * kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
> + KIS_ASSERT_RECOVER(kisCanvas) { return true; }
> + previewColor =
> kisCanvas->displayColorConverter()->toQColor(color);
> }
>
> + m_colorPreviewCurrentColor = previewColor;
> + m_colorPreviewShowComparePlate = true;
> +
> return true;
> }
>
> @@ -496,6 +567,7 @@ KisToolPaint::NodePaintAbility
> KisToolPaint::nodePaintAbility()
>
> void KisToolPaint::activatePrimaryAction()
> {
> + pickColorWasOverridden();
> setOutlineEnabled(true);
> }
>
> @@ -549,6 +621,18 @@ void KisToolPaint::decreaseBrushSize()
> requestUpdateOutline(m_outlineDocPoint, 0);
> }
>
> +QRectF KisToolPaint::colorPreviewDocRect(const QPointF &outlineDocPoint)
> +{
> + if (!m_showColorPreview) return QRect();
> +
> + KisConfig cfg;
> +
> + const QRectF colorPreviewViewRect = cfg.colorPreviewRect();
> + const QRectF colorPreviewDocumentRect =
> canvas()->viewConverter()->viewToDocument(colorPreviewViewRect);
> +
> + return colorPreviewDocumentRect.translated(outlineDocPoint);
> +}
> +
> void KisToolPaint::requestUpdateOutline(const QPointF &outlineDocPoint,
> const KoPointerEvent *event)
> {
> if (!m_supportOutline) return;
> @@ -583,17 +667,36 @@ void KisToolPaint::requestUpdateOutline(const
> QPointF &outlineDocPoint, const Ko
> canvas()->viewConverter()->zoom(&zoomX, &zoomY);
> qreal xoffset = 2.0/zoomX;
> qreal yoffset = 2.0/zoomY;
> - QRectF newOutlineRect =
> outlineDocRect.adjusted(-xoffset,-yoffset,xoffset,yoffset);
> +
> + if (!outlineDocRect.isEmpty()) {
> + outlineDocRect.adjust(-xoffset,-yoffset,xoffset,yoffset);
> + }
> +
> + QRectF colorPreviewDocRect =
> this->colorPreviewDocRect(m_outlineDocPoint);
> + QRectF colorPreviewDocUpdateRect;
> + if (!colorPreviewDocRect.isEmpty()) {
> +
> colorPreviewDocUpdateRect.adjust(-xoffset,-yoffset,xoffset,yoffset);
> + }
> +
> + if (!m_oldColorPreviewUpdateRect.isEmpty()) {
> + canvas()->updateCanvas(m_oldColorPreviewUpdateRect);
> + }
>
> if (!m_oldOutlineRect.isEmpty()) {
> canvas()->updateCanvas(m_oldOutlineRect);
> }
>
> - if (!newOutlineRect.isEmpty()) {
> - canvas()->updateCanvas(newOutlineRect);
> + if (!outlineDocRect.isEmpty()) {
> + canvas()->updateCanvas(outlineDocRect);
> + }
> +
> + if (!colorPreviewDocUpdateRect.isEmpty()) {
> + canvas()->updateCanvas(colorPreviewDocUpdateRect);
> }
>
> - m_oldOutlineRect = newOutlineRect;
> + m_oldOutlineRect = outlineDocRect;
> + m_oldColorPreviewRect = colorPreviewDocRect;
> + m_oldColorPreviewUpdateRect = colorPreviewDocUpdateRect;
> }
>
> QPainterPath KisToolPaint::getOutlinePath(const QPointF &documentPos,
> diff --git a/krita/ui/tool/kis_tool_paint.h
> b/krita/ui/tool/kis_tool_paint.h
> index b1c25da..48c1f35 100644
> --- a/krita/ui/tool/kis_tool_paint.h
> +++ b/krita/ui/tool/kis_tool_paint.h
> @@ -169,12 +169,25 @@ protected:
> QPointF m_outlineDocPoint;
> QPainterPath m_currentOutline;
> QRectF m_oldOutlineRect;
> - bool m_toForegroundColor;
> +
> + bool m_showColorPreview;
> + QRectF m_oldColorPreviewRect;
> + QRectF m_oldColorPreviewUpdateRect;
> + QColor m_colorPreviewCurrentColor;
> + bool m_colorPreviewShowComparePlate;
> + QColor m_colorPreviewBaseColor;
>
> private:
> QPainterPath tryFixBrushOutline(const QPainterPath &originalOutline);
> void setOpacity(qreal opacity);
>
> + void activatePickColor(AlternateAction action);
> + void deactivatePickColor(AlternateAction action);
> + void pickColorWasOverridden();
> +
> + int colorPreviewResourceId(AlternateAction action);
> + QRectF colorPreviewDocRect(const QPointF &outlineDocPoint);
> +
> private:
>
> bool m_specialHoverModifier;
> _______________________________________________
> Krita mailing list
> kimageshop@kde.org
> https://mail.kde.org/mailman/listinfo/kimageshop
>
--
_______________________________________
Ramón Miranda
www.ramonmiranda.com
@ramonmva
[Attachment #5 (text/html)]
<div dir="ltr">Sounds cool. Thanks for the feature<br></div><div \
class="gmail_extra"><br><div class="gmail_quote">2015-05-10 15:23 GMT+02:00 Dmitry \
Kazakov <span dir="ltr"><<a href="mailto:dimula73@gmail.com" \
target="_blank">dimula73@gmail.com</a>></span>:<br><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Git commit \
55d7eaebed3923da01150a38654df8a4fe3b199d by Dmitry Kazakov.<br> Committed on \
10/05/2015 at 13:23.<br> Pushed by dkazakov into branch 'calligra/2.9'.<br>
<br>
[FEATURE] Add on-canvas preview of current color<br>
<br>
1) Now when activating color picker in the brush tool<br>
with Ctrl or any other shortcut, currently selected color<br>
will be displayed near the cursor on screen.<br>
<br>
2) If you start actual color-picking, the two colors will be<br>
compared side-by-side.<br>
<br>
BUG:338128<br>
Fixes task T206<br>
<a href="mailto:CC%3Akimageshop@kde.org">CC:kimageshop@kde.org</a><br>
<br>
M +10 -0 krita/ui/kis_config.cc<br>
M +3 -0 krita/ui/kis_config.h<br>
M +111 -8 krita/ui/tool/kis_tool_paint.cc<br>
M +14 -1 krita/ui/tool/kis_tool_paint.h<br>
<br>
<a href="http://commits.kde.org/calligra/55d7eaebed3923da01150a38654df8a4fe3b199d" \
target="_blank">http://commits.kde.org/calligra/55d7eaebed3923da01150a38654df8a4fe3b199d</a><br>
<br>
diff --git a/krita/ui/kis_config.cc b/krita/ui/kis_config.cc<br>
index f9f96c7..b409a3f 100644<br>
--- a/krita/ui/kis_config.cc<br>
+++ b/krita/ui/kis_config.cc<br>
@@ -324,6 +324,16 @@ void KisConfig::setNewOutlineStyle(OutlineStyle style)<br>
m_cfg.writeEntry("newOutlineStyle", (int)style);<br>
}<br>
<br>
+QRect KisConfig::colorPreviewRect() const<br>
+{<br>
+ return m_cfg.readEntry("colorPreviewRect", QVariant(QRect(32, 32, \
48, 48))).toRect();<br> +}<br>
+<br>
+void KisConfig::setColorPreviewRect(const QRect &rect)<br>
+{<br>
+ m_cfg.writeEntry("colorPreviewRect", QVariant(rect));<br>
+}<br>
+<br>
bool KisConfig::useDirtyPresets(bool defaultValue) const<br>
{<br>
return (defaultValue ? false : \
m_cfg.readEntry("useDirtyPresets",false));<br>
diff --git a/krita/ui/kis_config.h b/krita/ui/kis_config.h<br>
index f68f881..43f52f8 100644<br>
--- a/krita/ui/kis_config.h<br>
+++ b/krita/ui/kis_config.h<br>
@@ -105,6 +105,9 @@ public:<br>
OutlineStyle newOutlineStyle(bool defaultValue = false) const;<br>
void setNewOutlineStyle(OutlineStyle style);<br>
<br>
+ QRect colorPreviewRect() const;<br>
+ void setColorPreviewRect(const QRect &rect);<br>
+<br>
/// get the profile the user has selected for the given screen<br>
QString monitorProfile(int screen) const;<br>
void setMonitorProfile(int screen, const QString & monitorProfile, bool \
override) const;<br>
diff --git a/krita/ui/tool/kis_tool_paint.cc b/krita/ui/tool/kis_tool_paint.cc<br>
index 00aa2a1..0c6b528 100644<br>
--- a/krita/ui/tool/kis_tool_paint.cc<br>
+++ b/krita/ui/tool/kis_tool_paint.cc<br>
@@ -60,6 +60,7 @@<br>
#include <KisViewManager.h><br>
#include <kis_canvas2.h><br>
#include <kis_cubic_curve.h><br>
+#include "kis_display_color_converter.h"<br>
<br>
#include "kis_config.h"<br>
#include "kis_config_notifier.h"<br>
@@ -74,7 +75,8 @@<br>
<br>
KisToolPaint::KisToolPaint(KoCanvasBase * canvas, const QCursor & cursor)<br>
: KisTool(canvas, cursor),<br>
- m_isOutlineEnabled(false)<br>
+ m_showColorPreview(false),<br>
+ m_colorPreviewShowComparePlate(false)<br>
{<br>
m_specialHoverModifier = false;<br>
m_optionsWidgetLayout = 0;<br>
@@ -208,6 +210,16 @@ void KisToolPaint::paint(QPainter &gc, const KoViewConverter \
&converter)<br> <br>
QPainterPath path = tryFixBrushOutline(pixelToView(m_currentOutline));<br>
paintToolOutline(&gc, path);<br>
+<br>
+ if (m_showColorPreview) {<br>
+ QRectF viewRect = converter.documentToView(m_oldColorPreviewRect);<br>
+ gc.fillRect(viewRect, m_colorPreviewCurrentColor);<br>
+<br>
+ if (m_colorPreviewShowComparePlate) {<br>
+ QRectF baseColorRect = viewRect.translated(viewRect.width(), \
0);<br> + gc.fillRect(baseColorRect, m_colorPreviewBaseColor);<br>
+ }<br>
+ }<br>
}<br>
<br>
void KisToolPaint::setMode(ToolMode mode)<br>
@@ -222,22 +234,62 @@ void KisToolPaint::setMode(ToolMode mode)<br>
KisTool::setMode(mode);<br>
}<br>
<br>
+void KisToolPaint::activatePickColor(AlternateAction action)<br>
+{<br>
+ m_showColorPreview = true;<br>
+<br>
+ requestUpdateOutline(m_outlineDocPoint, 0);<br>
+<br>
+ int resource = colorPreviewResourceId(action);<br>
+ KoColor color = \
canvas()->resourceManager()->koColorResource(resource);<br> +<br>
+ KisCanvas2 * kisCanvas = dynamic_cast<KisCanvas2*>(canvas());<br>
+ KIS_ASSERT_RECOVER_RETURN(kisCanvas);<br>
+<br>
+ m_colorPreviewCurrentColor = \
kisCanvas->displayColorConverter()->toQColor(color);<br> +<br>
+ if (!m_colorPreviewBaseColor.isValid()) {<br>
+ m_colorPreviewBaseColor = m_colorPreviewCurrentColor;<br>
+ }<br>
+}<br>
+<br>
+void KisToolPaint::deactivatePickColor(AlternateAction action)<br>
+{<br>
+ Q_UNUSED(action);<br>
+<br>
+ m_showColorPreview = false;<br>
+ m_oldColorPreviewRect = QRect();<br>
+ m_oldColorPreviewUpdateRect = QRect();<br>
+ m_colorPreviewCurrentColor = QColor();<br>
+}<br>
+<br>
+void KisToolPaint::pickColorWasOverridden()<br>
+{<br>
+ m_colorPreviewShowComparePlate = false;<br>
+ m_colorPreviewBaseColor = QColor();<br>
+}<br>
+<br>
void KisToolPaint::activateAlternateAction(AlternateAction action)<br>
{<br>
switch (action) {<br>
case PickFgNode:<br>
useCursor(KisCursor::pickerLayerForegroundCursor());<br>
+ activatePickColor(action);<br>
break;<br>
case PickBgNode:<br>
useCursor(KisCursor::pickerLayerBackgroundCursor());<br>
+ activatePickColor(action);<br>
break;<br>
case PickFgImage:<br>
useCursor(KisCursor::pickerImageForegroundCursor());<br>
+ activatePickColor(action);<br>
break;<br>
case PickBgImage:<br>
useCursor(KisCursor::pickerImageBackgroundCursor());<br>
+ activatePickColor(action);<br>
break;<br>
default:<br>
+ pickColorWasOverridden();<br>
KisTool::activateAlternateAction(action);<br>
};<br>
}<br>
@@ -254,6 +306,7 @@ void KisToolPaint::deactivateAlternateAction(AlternateAction \
action)<br> }<br>
<br>
resetCursorStyle();<br>
+ deactivatePickColor(action);<br>
}<br>
<br>
void KisToolPaint::beginAlternateAction(KoPointerEvent *event, AlternateAction \
action)<br> @@ -271,6 +324,8 @@ void \
KisToolPaint::continueAlternateAction(KoPointerEvent *event, AlternateActio<br> \
{<br> if (!pickColor(event->point, action)) {<br>
KisTool::continueAlternateAction(event, action);<br>
+ } else {<br>
+ requestUpdateOutline(event->point, event);<br>
}<br>
}<br>
<br>
@@ -284,6 +339,15 @@ void KisToolPaint::endAlternateAction(KoPointerEvent *event, \
AlternateAction act<br> }<br>
}<br>
<br>
+int KisToolPaint::colorPreviewResourceId(AlternateAction action)<br>
+{<br>
+ bool toForegroundColor = action == PickFgNode || action == PickFgImage;<br>
+ int resource = toForegroundColor ?<br>
+ KoCanvasResourceManager::ForegroundColor : \
KoCanvasResourceManager::BackgroundColor;<br> +<br>
+ return resource;<br>
+}<br>
+<br>
bool KisToolPaint::pickColor(const QPointF &documentPixel,<br>
AlternateAction action)<br>
{<br>
@@ -295,11 +359,9 @@ bool KisToolPaint::pickColor(const QPointF \
&documentPixel,<br> return false;<br>
}<br>
<br>
- bool toForegroundColor = action == PickFgNode || action == PickFgImage;<br>
bool fromCurrentNode = action == PickFgNode || action == PickBgNode;<br>
<br>
- int resource = toForegroundColor ?<br>
- KoCanvasResourceManager::ForegroundColor : \
KoCanvasResourceManager::BackgroundColor;<br> + int resource = \
colorPreviewResourceId(action);<br> <br>
KisPaintDeviceSP device = fromCurrentNode ?<br>
currentNode()->projection() : image()->projection();<br>
@@ -307,10 +369,19 @@ bool KisToolPaint::pickColor(const QPointF \
&documentPixel,<br>
QPoint imagePoint = image()->documentToIntPixel(documentPixel);<br>
<br>
KoColor color;<br>
+ QColor previewColor;<br>
+<br>
if (KisToolUtils::pick(device, imagePoint, &color)) {<br>
canvas()->resourceManager()->setResource(resource, color);<br>
+<br>
+ KisCanvas2 * kisCanvas = dynamic_cast<KisCanvas2*>(canvas());<br>
+ KIS_ASSERT_RECOVER(kisCanvas) { return true; }<br>
+ previewColor = \
kisCanvas->displayColorConverter()->toQColor(color);<br> }<br>
<br>
+ m_colorPreviewCurrentColor = previewColor;<br>
+ m_colorPreviewShowComparePlate = true;<br>
+<br>
return true;<br>
}<br>
<br>
@@ -496,6 +567,7 @@ KisToolPaint::NodePaintAbility \
KisToolPaint::nodePaintAbility()<br> <br>
void KisToolPaint::activatePrimaryAction()<br>
{<br>
+ pickColorWasOverridden();<br>
setOutlineEnabled(true);<br>
}<br>
<br>
@@ -549,6 +621,18 @@ void KisToolPaint::decreaseBrushSize()<br>
requestUpdateOutline(m_outlineDocPoint, 0);<br>
}<br>
<br>
+QRectF KisToolPaint::colorPreviewDocRect(const QPointF &outlineDocPoint)<br>
+{<br>
+ if (!m_showColorPreview) return QRect();<br>
+<br>
+ KisConfig cfg;<br>
+<br>
+ const QRectF colorPreviewViewRect = cfg.colorPreviewRect();<br>
+ const QRectF colorPreviewDocumentRect = \
canvas()->viewConverter()->viewToDocument(colorPreviewViewRect);<br> +<br>
+ return colorPreviewDocumentRect.translated(outlineDocPoint);<br>
+}<br>
+<br>
void KisToolPaint::requestUpdateOutline(const QPointF &outlineDocPoint, const \
KoPointerEvent *event)<br> {<br>
if (!m_supportOutline) return;<br>
@@ -583,17 +667,36 @@ void KisToolPaint::requestUpdateOutline(const QPointF \
&outlineDocPoint, const Ko<br> canvas()->viewConverter()->zoom(&zoomX, \
&zoomY);<br> qreal xoffset = 2.0/zoomX;<br>
qreal yoffset = 2.0/zoomY;<br>
- QRectF newOutlineRect = \
outlineDocRect.adjusted(-xoffset,-yoffset,xoffset,yoffset);<br> +<br>
+ if (!outlineDocRect.isEmpty()) {<br>
+ outlineDocRect.adjust(-xoffset,-yoffset,xoffset,yoffset);<br>
+ }<br>
+<br>
+ QRectF colorPreviewDocRect = \
this->colorPreviewDocRect(m_outlineDocPoint);<br> + QRectF \
colorPreviewDocUpdateRect;<br> + if (!colorPreviewDocRect.isEmpty()) {<br>
+ colorPreviewDocUpdateRect.adjust(-xoffset,-yoffset,xoffset,yoffset);<br>
+ }<br>
+<br>
+ if (!m_oldColorPreviewUpdateRect.isEmpty()) {<br>
+ canvas()->updateCanvas(m_oldColorPreviewUpdateRect);<br>
+ }<br>
<br>
if (!m_oldOutlineRect.isEmpty()) {<br>
canvas()->updateCanvas(m_oldOutlineRect);<br>
}<br>
<br>
- if (!newOutlineRect.isEmpty()) {<br>
- canvas()->updateCanvas(newOutlineRect);<br>
+ if (!outlineDocRect.isEmpty()) {<br>
+ canvas()->updateCanvas(outlineDocRect);<br>
+ }<br>
+<br>
+ if (!colorPreviewDocUpdateRect.isEmpty()) {<br>
+ canvas()->updateCanvas(colorPreviewDocUpdateRect);<br>
}<br>
<br>
- m_oldOutlineRect = newOutlineRect;<br>
+ m_oldOutlineRect = outlineDocRect;<br>
+ m_oldColorPreviewRect = colorPreviewDocRect;<br>
+ m_oldColorPreviewUpdateRect = colorPreviewDocUpdateRect;<br>
}<br>
<br>
QPainterPath KisToolPaint::getOutlinePath(const QPointF &documentPos,<br>
diff --git a/krita/ui/tool/kis_tool_paint.h b/krita/ui/tool/kis_tool_paint.h<br>
index b1c25da..48c1f35 100644<br>
--- a/krita/ui/tool/kis_tool_paint.h<br>
+++ b/krita/ui/tool/kis_tool_paint.h<br>
@@ -169,12 +169,25 @@ protected:<br>
QPointF m_outlineDocPoint;<br>
QPainterPath m_currentOutline;<br>
QRectF m_oldOutlineRect;<br>
- bool m_toForegroundColor;<br>
+<br>
+ bool m_showColorPreview;<br>
+ QRectF m_oldColorPreviewRect;<br>
+ QRectF m_oldColorPreviewUpdateRect;<br>
+ QColor m_colorPreviewCurrentColor;<br>
+ bool m_colorPreviewShowComparePlate;<br>
+ QColor m_colorPreviewBaseColor;<br>
<br>
private:<br>
QPainterPath tryFixBrushOutline(const QPainterPath &originalOutline);<br>
void setOpacity(qreal opacity);<br>
<br>
+ void activatePickColor(AlternateAction action);<br>
+ void deactivatePickColor(AlternateAction action);<br>
+ void pickColorWasOverridden();<br>
+<br>
+ int colorPreviewResourceId(AlternateAction action);<br>
+ QRectF colorPreviewDocRect(const QPointF &outlineDocPoint);<br>
+<br>
private:<br>
<br>
bool m_specialHoverModifier;<br>
_______________________________________________<br>
Krita mailing list<br>
<a href="mailto:kimageshop@kde.org">kimageshop@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/kimageshop" \
target="_blank">https://mail.kde.org/mailman/listinfo/kimageshop</a><br> \
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div \
dir="ltr"><div>_______________________________________<br>Ramón Miranda<br><a \
href="http://www.ramonmiranda.com" \
target="_blank">www.ramonmiranda.com</a><br></div>@ramonmva<br></div></div> </div>
[Attachment #6 (text/plain)]
_______________________________________________
Krita mailing list
kimageshop@kde.org
https://mail.kde.org/mailman/listinfo/kimageshop
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic