Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Tusooa Zhu
Krita
Commits
d9a09cc9
Commit
d9a09cc9
authored
Aug 20, 2015
by
Dmitry Kazakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEATURE] Make color picking with shortcuts work in Wrap Around mode
CC:kimageshop@kde.org BUG:336122
parent
9c6d0f17
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
4 deletions
+44
-4
krita/plugins/tools/defaulttools/kis_tool_colorpicker.cc
krita/plugins/tools/defaulttools/kis_tool_colorpicker.cc
+19
-3
krita/ui/tool/kis_tool_paint.cc
krita/ui/tool/kis_tool_paint.cc
+1
-1
krita/ui/tool/kis_tool_utils.cpp
krita/ui/tool/kis_tool_utils.cpp
+17
-0
krita/ui/tool/kis_tool_utils.h
krita/ui/tool/kis_tool_utils.h
+7
-0
No files found.
krita/plugins/tools/defaulttools/kis_tool_colorpicker.cc
View file @
d9a09cc9
...
...
@@ -52,6 +52,9 @@
#include <KoChannelInfo.h>
#include <KoMixColorsOp.h>
#include "kis_wrapped_rect.h"
namespace
{
// The location of the sample all visible layers in the combobox
...
...
@@ -177,7 +180,12 @@ void KisToolColorPicker::pickColor(const QPointF& pos)
}
if
(
m_config
.
radius
==
1
)
{
dev
->
pixel
(
pos
.
x
(),
pos
.
y
(),
&
m_pickedColor
);
QPoint
realPos
=
pos
.
toPoint
();
if
(
currentImage
()
->
wrapAroundModePermitted
())
{
realPos
=
KisWrappedRect
::
ptToWrappedPt
(
realPos
,
currentImage
()
->
bounds
());
}
dev
->
pixel
(
realPos
.
x
(),
realPos
.
y
(),
&
m_pickedColor
);
}
else
{
...
...
@@ -193,7 +201,14 @@ void KisToolColorPicker::pickColor(const QPointF& pos)
for
(
int
y
=
-
m_config
.
radius
;
y
<=
m_config
.
radius
;
y
++
)
{
for
(
int
x
=
-
m_config
.
radius
;
x
<=
m_config
.
radius
;
x
++
)
{
if
(((
x
*
x
)
+
(
y
*
y
))
<
m_config
.
radius
*
m_config
.
radius
)
{
accessor
->
moveTo
(
pos
.
x
()
+
x
,
pos
.
y
()
+
y
);
QPoint
realPos
(
pos
.
x
()
+
x
,
pos
.
y
()
+
y
);
if
(
currentImage
()
->
wrapAroundModePermitted
())
{
realPos
=
KisWrappedRect
::
ptToWrappedPt
(
realPos
,
currentImage
()
->
bounds
());
}
accessor
->
moveTo
(
realPos
.
x
(),
realPos
.
y
());
pixels
<<
accessor
->
oldRawData
();
}
}
...
...
@@ -248,7 +263,8 @@ void KisToolColorPicker::beginPrimaryAction(KoPointerEvent *event)
QPoint
pos
=
convertToIntPixelCoord
(
event
);
// the color picking has to start in the visible part of the layer
if
(
!
currentImage
()
->
bounds
().
contains
(
pos
))
{
if
(
!
currentImage
()
->
bounds
().
contains
(
pos
)
&&
!
currentImage
()
->
wrapAroundModePermitted
())
{
event
->
ignore
();
return
;
}
...
...
krita/ui/tool/kis_tool_paint.cc
View file @
d9a09cc9
...
...
@@ -395,7 +395,7 @@ bool KisToolPaint::pickColor(const QPointF &documentPixel,
KoColor
color
;
QColor
previewColor
;
if
(
KisToolUtils
::
pick
(
device
,
imagePoint
,
&
color
))
{
if
(
KisToolUtils
::
pick
Wrapped
(
device
,
imagePoint
,
&
color
,
image
()
))
{
canvas
()
->
resourceManager
()
->
setResource
(
resource
,
color
);
KisCanvas2
*
kisCanvas
=
dynamic_cast
<
KisCanvas2
*>
(
canvas
());
...
...
krita/ui/tool/kis_tool_utils.cpp
View file @
d9a09cc9
...
...
@@ -21,9 +21,26 @@
#include <kis_paint_device.h>
#include <kis_layer.h>
#include <kis_group_layer.h>
#include <kis_wrapped_rect.h>
#include <kis_image.h>
namespace
KisToolUtils
{
bool
pickWrapped
(
KisPaintDeviceSP
dev
,
QPoint
pos
,
KoColor
*
color
,
KisImageSP
image
)
{
if
(
!
image
->
tryBarrierLock
())
return
false
;
if
(
image
->
wrapAroundModePermitted
())
{
pos
=
KisWrappedRect
::
ptToWrappedPt
(
pos
,
image
->
bounds
());
}
bool
result
=
pick
(
dev
,
pos
,
color
);
image
->
unlock
();
return
result
;
}
bool
pick
(
KisPaintDeviceSP
dev
,
const
QPoint
&
pos
,
KoColor
*
color
)
{
KIS_ASSERT
(
dev
);
...
...
krita/ui/tool/kis_tool_utils.h
View file @
d9a09cc9
...
...
@@ -26,6 +26,13 @@
namespace
KisToolUtils
{
/**
* return the color at the given position on the given paint device.
* NOTE: the function takes wraparound mode and image locking into account
*/
bool
pickWrapped
(
KisPaintDeviceSP
dev
,
QPoint
pos
,
KoColor
*
color
,
KisImageSP
image
);
/**
* return the color at the given position on the given paint device.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment