Krita Source Code Documentation
Loading...
Searching...
No Matches
KisColorSelector Class Reference

#include <kis_color_selector.h>

+ Inheritance diagram for KisColorSelector:

Classes

struct  ColorRing
 

Public Slots

void reset () override
 
void slotGamutMaskDeactivate ()
 
void slotGamutMaskPreviewUpdate ()
 
void slotGamutMaskSet (KoGamutMaskSP gamutMask)
 
void slotGamutMaskToggle (bool state)
 
void slotGamutMaskUnset ()
 
void updateSettings () override
 
- Public Slots inherited from KisColorSelectorBase
virtual void reset ()
 
virtual void showPopup (Move move=MoveToMousePosition)
 
virtual void updateSettings ()
 

Signals

void settingsButtonClicked ()
 
void sigBgColorChanged (const KisColor &color)
 
void sigFgColorChanged (const KisColor &color)
 

Public Member Functions

KisColorSelectorConfiguration configuration () const
 
KisColorSelectorBasecreatePopup () const override
 
bool displayBlip () const
 
bool enforceGamutMask () const
 
KoGamutMaskSP gamutMask ()
 
bool gamutMaskOn ()
 
KisColor::Type getColorSpace () const
 
quint32 getDefaultHueSteps () const
 
quint32 getDefaultSaturationSteps () const
 
quint32 getDefaultValueScaleSteps () const
 
qint32 getNumLightPieces () const
 
qint32 getNumPieces () const
 
qint32 getNumRings () const
 
bool getShowBgColor () const
 
bool getShowValueScaleNumbers () const
 
void hasAtLeastOneDocument (bool value)
 
bool isSaturationInverted () const
 
 KisColorSelector (KisColorSelectorConfiguration conf, QWidget *parent=0)
 
 KisColorSelector (QWidget *parent, KisColor::Type type=KisColor::HSL)
 
 KisColorSelector (QWidget *parent=0)
 
void loadSettings ()
 
qreal lumaB () const
 
qreal lumaG () const
 
qreal lumaGamma () const
 
qreal lumaR () const
 
void saveSettings ()
 
void selectColor (const KisColor &color)
 
void setBgColor (const KoColor &bgColor)
 
void setColor (const KoColor &color) override
 
void setColorConverter (KisDisplayColorConverter *colorConverter)
 
void setColorSpace (KisColor::Type type)
 
void setConfiguration (KisColorSelectorConfiguration conf)
 
void setDefaultHueSteps (int num)
 
void setDefaultSaturationSteps (int num)
 
void setDefaultValueScaleSteps (int num)
 
void setDirty ()
 
void setDisplayBlip (bool disp)
 
void setEnforceGamutMask (bool enforce)
 
void setFgColor (const KoColor &fgColor)
 
void setGamutMask (KoGamutMaskSP gamutMask)
 
void setGamutMaskOn (bool gamutMaskOn)
 
void setInverseSaturation (bool inverse)
 
void setLight (qreal light=0.0f)
 
void setLumaCoefficients (qreal lR, qreal lG, qreal lB, qreal lGamma)
 
void setNumLightPieces (int num)
 
void setNumPieces (int num)
 
void setNumRings (int num)
 
void setShowBgColor (bool value)
 
void setShowValueScaleNumbers (bool value)
 
void slotUpdateColorAndPreview (QPair< KisColor, Acs::ColorRole > color)
 
void updateIcons ()
 update icons when a theme update happens
 
- Public Member Functions inherited from KisColorSelectorBase
const KoColorSpacecolorSpace () const
 
KisDisplayColorConverterconverter () const
 
void enterEvent (QEnterEvent *e) override
 
 KisColorSelectorBase (QWidget *parent=0)
 
void leaveEvent (QEvent *e) override
 
void mousePressEvent (QMouseEvent *) override
 
void mouseReleaseEvent (QMouseEvent *) override
 
virtual void setCanvas (KisCanvas2 *canvas)
 
void setColorSpace (const KoColorSpace *colorSpace)
 
void setPopupBehaviour (bool onMouseOver, bool onMouseClick)
 
void showColorPreview ()
 
void slotUpdateColorAndPreview (QPair< KoColor, Acs::ColorRole > color)
 
void tryHideAllPopups ()
 
virtual void unsetCanvas ()
 
void updateBaseColorPreview (const KoColor &color)
 
void updateColor (const KoColor &color, Acs::ColorRole role, bool needsExplicitColorReset)
 
void updateColorPreview (const KoColor &color)
 
void updatePreviousColorPreview ()
 
 ~KisColorSelectorBase () override
 

Protected Member Functions

bool displaySettingsButton ()
 
void mouseMoveEvent (QMouseEvent *) override
 
void mousePressEvent (QMouseEvent *) override
 
void mouseReleaseEvent (QMouseEvent *) override
 
void paintEvent (QPaintEvent *) override
 
void resizeEvent (QResizeEvent *) override
 
- Protected Member Functions inherited from KisColorSelectorBase
void changeEvent (QEvent *event) override
 
void dragEnterEvent (QDragEnterEvent *) override
 
void dropEvent (QDropEvent *) override
 
bool isPopup () const
 
void keyPressEvent (QKeyEvent *) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void requestUpdateColorAndPreview (const KoColor &color, Acs::ColorRole role)
 
void setHidingTime (int time)
 
void showEvent (QShowEvent *event) override
 

Private Types

typedef KisSignalCompressorWithParam< QPair< KisColor, Acs::ColorRole > > ColorCompressorType
 
typedef KisRadian< qreal > Radian
 

Private Member Functions

bool colorIsClear (const KisColor &color)
 
bool colorIsClear (const QPointF &colorPoint)
 
void createRing (ColorRing &wheel, quint8 numPieces, qreal innerRadius, qreal outerRadius)
 
void drawBlip (QPainter &painter, const QRect &rect)
 
void drawColorPreview (QPainter &painter, const QRect &rect)
 
void drawGamutMaskShape (QPainter &painter, const QRect &rect)
 
void drawLightStrip (QPainter &painter, const QRect &rect)
 
void drawOutline (QPainter &painter, const QRect &rect)
 
void drawRing (QPainter &painter, ColorRing &wheel, const QRect &rect)
 
qreal getHue (int hueIdx, Radian shift=0.0f) const
 
qint8 getHueIndex (Radian hue) const
 
qreal getLight (const QPointF &pt) const
 
qint8 getLightIndex (const QPointF &pt) const
 
qint8 getLightIndex (qreal light) const
 
qreal getSaturation (int saturationIdx) const
 
qint8 getSaturationIndex (const QPointF &pt) const
 
qint8 getSaturationIndex (qreal saturation) const
 
void init ()
 
void leaveEvent (QEvent *e) override
 
QPointF mapColorToUnit (const KisColor &color, bool invertSaturation=true) const
 
Radian mapCoordToAngle (qreal x, qreal y) const
 
QPointF mapCoordToUnit (const QPointF &pt, const QRectF &viewRect) const
 
QPointF mapCoordToView (const QPointF &pt, const QRectF &viewRect) const
 
QPointF mapHueToAngle (qreal hue) const
 
void mouseEvent (QMouseEvent *e)
 
void mouseMoveEvent (QMouseEvent *event) override
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 
void paintEvent (QPaintEvent *event) override
 
void recalculateAreas (quint8 numLightPieces)
 
void recalculateRings (quint8 numRings, quint8 numPieces)
 
void requestUpdateColorAndPreview (const KisColor &color, Acs::ColorRole role)
 
void resizeEvent (QResizeEvent *event) override
 

Private Attributes

KisColor m_bgColor
 
bool m_blipDisplay
 
QToolButton * m_button
 
qint8 m_clickedRing
 
QPointF m_clickPos
 
KisDisplayColorConverterm_colorConverter
 
QImage m_colorPreviewBuffer
 
QVector< ColorRingm_colorRings
 
KisColor::Type m_colorSpace
 
KisColorSelectorConfiguration m_configuration
 
KoGamutMaskSP m_currentGamutMask
 
KoColor m_currentRealColor
 
quint8 m_defaultHueSteps
 
quint8 m_defaultSaturationSteps
 
quint8 m_defaultValueScaleSteps
 
bool m_enforceGamutMask
 
KisColor m_fgColor
 
bool m_gamutMaskOn
 
QTransform m_gamutMaskViewTransform
 
KisColorSelectorComponentm_grabbingComponent
 
bool m_hasAtLeastOneDocumentOpen = true
 
bool m_inverseSaturation
 
bool m_isDirtyColorPreview
 
bool m_isDirtyGamutMask
 
bool m_isDirtyLightStrip
 
bool m_isDirtyWheel
 
Acs::ColorRole m_lastColorRole
 
KoColor m_lastRealColor
 
QRect m_lightStripArea
 
QImage m_lightStripBuffer
 
qreal m_lumaB
 
qreal m_lumaG
 
qreal m_lumaGamma
 
qreal m_lumaR
 
KisColorSelectorComponentm_mainComponent
 
QImage m_maskBuffer
 
bool m_maskPreviewActive
 
bool m_mouseMoved
 
quint8 m_numLightPieces
 
quint8 m_numPieces
 
Qt::MouseButtons m_pressedButtons
 
QRect m_renderArea
 
QImage m_renderBuffer
 
KisColorSelectorRingm_ring
 
KisColor m_selectedColor
 
qint8 m_selectedLightPiece
 
qint8 m_selectedPiece
 
qint8 m_selectedRing
 
bool m_showBgColor {true}
 
bool m_showValueScaleNumbers {false}
 
KisSignalCompressorm_signalCompressor
 
KisColorSelectorSimplem_slider
 
KisColorSelectorSimplem_square
 
KisColorSelectorComponentm_subComponent
 
KisColorSelectorComponentm_triangle
 
QScopedPointer< ColorCompressorTypem_updateColorCompressor
 
KisColorSelectorWheelm_wheel
 
QRect m_widgetArea
 
bool m_widgetUpdatesSelf
 

Additional Inherited Members

- Public Types inherited from KisColorSelectorBase
enum  Move { MoveToMousePosition , DontMove }
 
- Protected Slots inherited from KisColorSelectorBase
virtual void canvasResourceChanged (int key, const QVariant &v)
 if you overwrite this, keep in mind, that you should set the color only, if m_colorUpdateAllowed is true
 
void hidePopup ()
 
void updateLastUsedColorPreview (const KoColor &color)
 
- Protected Attributes inherited from KisColorSelectorBase
QPointer< KisCanvas2m_canvas
 
bool m_colorUpdateAllowed
 
bool m_colorUpdateSelf
 
QWidget * m_parent
 
KisColorSelectorBasem_popup
 

Detailed Description

Definition at line 22 of file kis_color_selector.h.

Member Typedef Documentation

◆ ColorCompressorType

◆ Radian

typedef KisRadian<qreal> KisColorSelector::Radian
private

Definition at line 30 of file kis_color_selector.h.

Constructor & Destructor Documentation

◆ KisColorSelector() [1/3]

KisColorSelector::KisColorSelector ( KisColorSelectorConfiguration conf,
QWidget * parent = 0 )

Definition at line 38 of file kis_color_selector.cpp.

39 : KisColorSelectorBase(parent),
40 m_ring(0),
41 m_triangle(0),
42 m_slider(0),
43 m_square(0),
44 m_wheel(0),
48 m_blipDisplay(true)
49{
50 init();
52 setConfiguration(conf);
53}
KisColorSelectorBase(QWidget *parent=0)
KisColorSelectorComponent * m_triangle
void updateSettings() override
KisColorSelectorSimple * m_square
KisColorSelectorSimple * m_slider
KisColorSelectorWheel * m_wheel
KisColorSelectorComponent * m_subComponent
KisColorSelectorComponent * m_mainComponent
KisColorSelectorRing * m_ring
void setConfiguration(KisColorSelectorConfiguration conf)
KisColorSelectorComponent * m_grabbingComponent

References init(), setConfiguration(), and updateSettings().

◆ KisColorSelector() [2/3]

KisColorSelector::KisColorSelector ( QWidget * parent = 0)

Definition at line 55 of file kis_color_selector.cpp.

56 : KisColorSelectorBase(parent),
57 m_ring(0),
58 m_triangle(0),
59 m_slider(0),
60 m_square(0),
61 m_wheel(0),
62 m_button(0),
66 m_blipDisplay(true)
67{
68 init();
70}
QToolButton * m_button

References init(), and updateSettings().

◆ KisColorSelector() [3/3]

KisColorSelector::KisColorSelector ( QWidget * parent,
KisColor::Type type = KisColor::HSL )

Definition at line 28 of file kis_color_selector.cpp.

29 : QWidget(parent)
31 , m_colorSpace(type)
32 , m_inverseSaturation(false)
36 , m_clickedRing(-1)
37 , m_gamutMaskOn(false)
38 , m_currentGamutMask(nullptr)
40 , m_gamutMaskViewTransform(QTransform())
41 , m_widgetUpdatesSelf(false)
42 , m_isDirtyWheel(false)
43 , m_isDirtyLightStrip(false)
44 , m_isDirtyGamutMask(false)
46{
47// m_viewConverter = new KisGamutMaskViewConverter();
48
50
54
55 using namespace std::placeholders; // For _1 placeholder
56 auto function = std::bind(&KisColorSelector::slotUpdateColorAndPreview, this, _1);
57 m_updateColorCompressor.reset(new ColorCompressorType(25 /* ms */, function));
58}
KisSignalCompressorWithParam< QPair< KisColor, Acs::ColorRole > > ColorCompressorType
void recalculateRings(quint8 numRings, quint8 numPieces)
KoGamutMaskSP m_currentGamutMask
void recalculateAreas(quint8 numLightPieces)
QScopedPointer< ColorCompressorType > m_updateColorCompressor
QTransform m_gamutMaskViewTransform
void setLumaCoefficients(qreal lR, qreal lG, qreal lB, qreal lGamma)
KisColor::Type m_colorSpace
void selectColor(const KisColor &color)
void slotUpdateColorAndPreview(QPair< KisColor, Acs::ColorRole > color)
KisDisplayColorConverter * m_colorConverter
static KisDisplayColorConverter * dumbConverterInstance()
static const qreal DEFAULT_LUMA_R
static const int DEFAULT_VALUE_SCALE_STEPS
static const int DEFAULT_SATURATION_STEPS
static const qreal DEFAULT_LUMA_GAMMA
static const qreal DEFAULT_LUMA_B
static const int DEFAULT_HUE_STEPS
static const qreal DEFAULT_LUMA_G

References DEFAULT_HUE_STEPS, DEFAULT_LUMA_B, DEFAULT_LUMA_G, DEFAULT_LUMA_GAMMA, DEFAULT_LUMA_R, DEFAULT_SATURATION_STEPS, DEFAULT_VALUE_SCALE_STEPS, KisColor::HSY, m_colorConverter, m_lumaB, m_lumaG, m_lumaGamma, m_lumaR, m_updateColorCompressor, recalculateAreas(), recalculateRings(), selectColor(), setLumaCoefficients(), and slotUpdateColorAndPreview().

Member Function Documentation

◆ colorIsClear() [1/2]

bool KisColorSelector::colorIsClear ( const KisColor & color)
private

Definition at line 489 of file kis_color_selector.cpp.

490{
492
493 QPointF colorCoord = mapCoordToView(mapColorToUnit(color, false), m_renderArea);
494
495 QPointF translatedPoint = m_currentGamutMask->viewToMaskTransform(m_renderArea.width()).map(colorCoord);
496 bool isClear = m_currentGamutMask->coordIsClear(translatedPoint, m_maskPreviewActive);
497
498 if (isClear) {
499 return true;
500 } else {
501 return false;
502 }
503
504 } else {
505 return true;
506 }
507
508 return false;
509}
QPointF mapCoordToView(const QPointF &pt, const QRectF &viewRect) const
QPointF mapColorToUnit(const KisColor &color, bool invertSaturation=true) const

References m_currentGamutMask, m_gamutMaskOn, m_maskPreviewActive, m_renderArea, mapColorToUnit(), and mapCoordToView().

◆ colorIsClear() [2/2]

bool KisColorSelector::colorIsClear ( const QPointF & colorPoint)
private

◆ configuration()

KisColorSelectorConfiguration KisColorSelector::configuration ( ) const

Definition at line 136 of file kis_color_selector.cpp.

137{
138 return m_configuration;
139}
KisColorSelectorConfiguration m_configuration

References m_configuration.

◆ createPopup()

KisColorSelectorBase * KisColorSelector::createPopup ( ) const
overridevirtual

Implements KisColorSelectorBase.

Definition at line 72 of file kis_color_selector.cpp.

73{
76 return popup;
77}
Base class for all color selectors, that should support color management and zooming.
virtual void setColor(const KoColor &color)
KisColorSelector(KisColorSelectorConfiguration conf, QWidget *parent=0)

References KisColorSelector(), m_lastRealColor, and KisColorSelectorBase::setColor().

◆ createRing()

void KisColorSelector::createRing ( ColorRing & wheel,
quint8 numPieces,
qreal innerRadius,
qreal outerRadius )
private

Definition at line 463 of file kis_color_selector.cpp.

464{
465 int numParts = qMax<int>(numPieces, 1);
466
467 ring.innerRadius = innerRadius;
468 ring.outerRadius = outerRadius;
469 ring.pieced.resize(numParts);
470
471 qreal partSize = 360.0 / qreal(numParts);
472 QRectF outerRect(-outerRadius, -outerRadius, outerRadius*2.0, outerRadius*2.0);
473 QRectF innerRect(-innerRadius, -innerRadius, innerRadius*2.0, innerRadius*2.0);
474
475 for(int i=0; i<numParts; ++i) {
476 qreal aBeg = partSize*i;
477 qreal aEnd = aBeg + partSize;
478
479 aBeg -= partSize / 2.0;
480 aEnd -= partSize / 2.0;
481
482 ring.pieced[i] = QPainterPath();
483 ring.pieced[i].arcMoveTo(innerRect, aBeg);
484 ring.pieced[i].arcTo(outerRect, aBeg, partSize);
485 ring.pieced[i].arcTo(innerRect, aEnd,-partSize);
486 }
487}

References KisColorSelector::ColorRing::innerRadius, KisColorSelector::ColorRing::outerRadius, and KisColorSelector::ColorRing::pieced.

◆ displayBlip()

bool KisColorSelector::displayBlip ( ) const
inline

Definition at line 92 of file kis_color_selector.h.

92{return m_blipDisplay;}

References m_blipDisplay.

◆ displaySettingsButton()

bool KisColorSelector::displaySettingsButton ( )
protected

Definition at line 362 of file kis_color_selector.cpp.

363{
364 return dynamic_cast<KisColorSelectorContainer*>(parent());
365}
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327

◆ drawBlip()

void KisColorSelector::drawBlip ( QPainter & painter,
const QRect & rect )
private

Definition at line 812 of file kis_color_selector.cpp.

813{
814 painter.save();
815
816 painter.setRenderHint(QPainter::Antialiasing, true);
817 painter.resetTransform();
818 painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
819 painter.scale(rect.width()/2, rect.height()/2);
820
821 QPointF fgColorPos = mapColorToUnit(m_fgColor);
822
823#ifdef DEBUG_ARC_SELECTOR
824 dbgPlugins << "KisColorSelector::drawBlip: "
825 << "colorPoint H:" << m_fgColor.getH() << " S:" << m_fgColor.getS()
826 << "-> coord X:" << fgColorPos.x() << " Y:" << fgColorPos.y();
827#endif
828
829 painter.setPen(QPen(QBrush(COLOR_SELECTED_DARK), 0.01));
830 painter.drawEllipse(fgColorPos, 0.05, 0.05);
831
832 painter.setPen(QPen(QBrush(COLOR_SELECTED_LIGHT), 0.01));
833 painter.drawEllipse(fgColorPos, 0.04, 0.04);
834
835 painter.restore();
836}
qreal getS() const
Definition kis_color.h:50
qreal getH() const
Definition kis_color.h:49
static const QColor COLOR_SELECTED_LIGHT
static const QColor COLOR_SELECTED_DARK
#define dbgPlugins
Definition kis_debug.h:51

References COLOR_SELECTED_DARK, COLOR_SELECTED_LIGHT, dbgPlugins, KisColor::getH(), KisColor::getS(), m_fgColor, and mapColorToUnit().

◆ drawColorPreview()

void KisColorSelector::drawColorPreview ( QPainter & painter,
const QRect & rect )
private

Definition at line 863 of file kis_color_selector.cpp.

864{
865 painter.save();
866 painter.setRenderHint(QPainter::Antialiasing, true);
867
868 painter.fillRect(rect, m_fgColor.toQColor());
869
870 int bgSide = qMin(rect.width()*0.15,rect.height()*0.15);
871
872 if (m_showBgColor) {
873 QPointF bgPolyPoints[3] = {
874 QPointF(rect.width(), rect.height()),
875 QPointF(rect.width()-bgSide, rect.height()),
876 QPointF(rect.width(), rect.height()-bgSide)
877 };
878
879 painter.setBrush(m_bgColor.toQColor());
880 painter.setPen(m_bgColor.toQColor());
881 painter.drawPolygon(bgPolyPoints, 3);
882 }
883
884 painter.restore();
885}
QColor toQColor() const
Definition kis_color.cpp:95

References m_bgColor, m_fgColor, m_showBgColor, and KisColor::toQColor().

◆ drawGamutMaskShape()

void KisColorSelector::drawGamutMaskShape ( QPainter & painter,
const QRect & rect )
private

Definition at line 838 of file kis_color_selector.cpp.

839{
840 painter.save();
841 painter.setRenderHint(QPainter::Antialiasing, true);
842
843 painter.resetTransform();
844 painter.translate(rect.width()/2, rect.height()/2);
845 painter.scale(rect.width()/2, rect.height()/2);
846
847 painter.setPen(Qt::NoPen);
848 painter.setBrush(COLOR_MASK_FILL);
849
850 painter.drawEllipse(QPointF(0,0), 1.0, 1.0);
851
852 painter.setWorldTransform(m_gamutMaskViewTransform);
853
854 painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
856
857 painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
858 m_currentGamutMask->paintStroke(painter, m_maskPreviewActive);
859
860 painter.restore();
861}
static const QColor COLOR_MASK_FILL

References COLOR_MASK_FILL, m_currentGamutMask, m_gamutMaskViewTransform, and m_maskPreviewActive.

◆ drawLightStrip()

void KisColorSelector::drawLightStrip ( QPainter & painter,
const QRect & rect )
private

Definition at line 680 of file kis_color_selector.cpp.

681{
682 qreal penSize = qreal(qMin(QWidget::width(), QWidget::height())) / 200.0;
683 qreal penSizeSmall = penSize / 1.2;
684 QPen selectedPen;
685
688 int rectSize = rect.height();
689
690 painter.save();
691 painter.resetTransform();
692 painter.setRenderHint(QPainter::Antialiasing, true);
693
694 QTransform matrix;
695 matrix.translate(rect.x(), rect.y());
696 matrix.scale(rect.width(), rect.height());
697
698 qreal rectColorLeftX;
699 qreal rectColorWidth;
700
702 rectColorLeftX = 0.6;
703 rectColorWidth = 0.4;
704 } else {
705 rectColorLeftX = 0.0;
706 rectColorWidth = 1.0;
707 }
708
709 if (getNumLightPieces() > 1) {
710 for(int i=0; i<getNumLightPieces(); ++i) {
711 qreal t1 = qreal(i) / qreal(getNumLightPieces());
712 qreal t2 = qreal(i+1) / qreal(getNumLightPieces());
713 qreal light = 1.0 - (qreal(i) / qreal(getNumLightPieces()-1));
714 qreal diff = t2 - t1;// + 0.001;
715
716 QRectF rectColor = QRectF(rectColorLeftX, t1, rectColorWidth, diff);
717 rectColor = matrix.mapRect(rectColor);
718
719 valueScaleColor.setX(light);
720 painter.fillRect(rectColor, valueScaleColor.toQColor());
721
722 if (i == m_selectedLightPiece) {
723 if (light < 0.55) {
724 selectedPen = QPen(QBrush(COLOR_SELECTED_LIGHT), penSize);
725 } else {
726 selectedPen = QPen(QBrush(COLOR_SELECTED_DARK), penSize);
727 }
728
729 painter.setPen(selectedPen);
730 painter.drawRect(rectColor);
731 }
732 }
733 } else {
734 painter.setRenderHint(QPainter::Antialiasing, false);
735
736 for(int i=0; i<rectSize; ++i) {
737 int y = rect.y() + i;
738 qreal light = 1.0 - (qreal(i) / qreal(rectSize-1));
739 valueScaleColor.setX(light);
740 painter.setPen(QPen(QBrush(valueScaleColor.toQColor()), penSize));
741 painter.drawLine(rect.left(), y, rect.right(), y);
742 }
743 }
744
745 // draw color blip
746 painter.setRenderHint(QPainter::Antialiasing, false);
747 // draw position of fg color value on the strip
748 qreal fgColorValue = 1.0 - m_fgColor.getX();
749
750 int y = rect.y() + int(rectSize * fgColorValue);
751 painter.setPen(QPen(QBrush(COLOR_SELECTED_LIGHT), penSizeSmall));
752 painter.drawLine(rect.left(), y, rect.right(), y);
753 painter.setPen(QPen(QBrush(COLOR_SELECTED_DARK), penSizeSmall));
754 painter.drawLine(rect.left(), y+2*penSizeSmall, rect.right(), y+2*penSizeSmall);
755 // draw color blip
756
758 painter.setRenderHint(QPainter::Antialiasing, true);
759
760 int valueScalePieces = getNumLightPieces();
761 if (getNumLightPieces() == 1) {
762 valueScalePieces = 11;
763 }
764
765 QFont font = painter.font();
766 QFontMetrics fm = painter.fontMetrics();
767 int retries = 10; // limit number of font size searches to prevent endless cycles
768 while ((retries > 0) && (fm.boundingRect("100%").width() > rect.width()*rectColorLeftX)) {
769 font.setPointSize(font.pointSize() - 1);
770 painter.setFont(font);
771 fm = painter.fontMetrics();
772 retries--;
773 }
774
775 for(int i=0; i<valueScalePieces; ++i) {
776 qreal t1 = qreal(i) / qreal(valueScalePieces);
777 qreal t2 = qreal(i+1) / qreal(valueScalePieces);
778 qreal light = 1.0 - (qreal(i) / qreal(valueScalePieces-1));
779 qreal diff = t2 - t1;// + 0.001;
780
781 grayScaleColor.setX(light);
782
783 QRectF rectValue = QRectF(0.0, t1, rectColorLeftX, diff);
784 rectValue = matrix.mapRect(rectValue);
785
786 painter.fillRect(rectValue, grayScaleColor.toQColor());
787
788 // if the right font size was not found in time,
789 // skip drawing the numbers
790 if (retries > 0) {
791 int valueNumber = 0;
793 valueNumber = 100 - round(pow(pow(grayScaleColor.getX(), m_lumaGamma), 1.0/2.2)*100);
794 } else {
795 valueNumber = 100 - grayScaleColor.getX()*100;
796 }
797
798 if (valueNumber < 55) {
799 painter.setPen(QPen(QBrush(COLOR_DARK), penSize));
800 } else {
801 painter.setPen(QPen(QBrush(COLOR_LIGHT), penSize));
802 }
803
804 painter.drawText(rectValue, Qt::AlignRight|Qt::AlignBottom, QString("%1%").arg(QString::number(valueNumber)));
805 }
806 }
807 }
808
809 painter.restore();
810}
qint32 getNumLightPieces() const
qreal getX() const
Definition kis_color.h:51
static const QColor COLOR_DARK
static const QColor COLOR_LIGHT

References COLOR_DARK, COLOR_LIGHT, COLOR_SELECTED_DARK, COLOR_SELECTED_LIGHT, getNumLightPieces(), KisColor::getX(), KisColor::HSY, m_colorConverter, m_colorSpace, m_fgColor, m_lumaB, m_lumaG, m_lumaGamma, m_lumaR, m_selectedColor, m_selectedLightPiece, m_showValueScaleNumbers, KisColor::setX(), and KisColor::toQColor().

◆ drawOutline()

void KisColorSelector::drawOutline ( QPainter & painter,
const QRect & rect )
private

Definition at line 619 of file kis_color_selector.cpp.

620{
621 painter.save();
622
623 painter.setRenderHint(QPainter::Antialiasing, true);
624 painter.resetTransform();
625 painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
626 painter.scale(rect.width()/2, rect.height()/2);
627
628 QPen normalPen = QPen(QBrush(COLOR_NORMAL_OUTLINE), 0.005);
629 QPen selectedPen;
630
631 painter.setPen(normalPen);
632
633 if (getNumPieces() > 1) {
634 if (m_selectedRing >= 0 && m_selectedPiece >= 0) {
635 painter.resetTransform();
636 painter.translate(rect.x() + rect.width()/2, rect.y() + rect.height()/2);
637 QTransform mirror;
638 mirror.rotate(180, Qt::YAxis);
639 painter.setTransform(mirror, true);
640 painter.scale(rect.width()/2, rect.height()/2);
641
642 if (m_selectedColor.getX() < 0.55) {
643 selectedPen = QPen(QBrush(COLOR_SELECTED_LIGHT), 0.007);
644 } else {
645 selectedPen = QPen(QBrush(COLOR_SELECTED_DARK), 0.007);
646 }
647
648 painter.setPen(selectedPen);
649 painter.drawPath(m_colorRings[m_selectedRing].pieced[m_selectedPiece]);
650 }
651 }
652 else {
653 for(int i=0; i<getNumRings(); ++i) {
654 qreal rad = m_colorRings[i].outerRadius;
655 painter.drawEllipse(QRectF(-rad, -rad, rad*2.0, rad*2.0));
656 }
657
658 if (m_selectedRing >= 0) {
659 qreal iRad = m_colorRings[m_selectedRing].innerRadius;
660 qreal oRad = m_colorRings[m_selectedRing].outerRadius;
661
662 if (m_selectedColor.getX() < 0.55) {
663 selectedPen = QPen(QBrush(COLOR_SELECTED_LIGHT), 0.005);
664 } else {
665 selectedPen = QPen(QBrush(COLOR_SELECTED_DARK), 0.005);
666 }
667
668 painter.setPen(selectedPen);
669 painter.drawEllipse(QRectF(-iRad, -iRad, iRad*2.0, iRad*2.0));
670 painter.drawEllipse(QRectF(-oRad, -oRad, oRad*2.0, oRad*2.0));
671
672 QPointF lineCoords = mapHueToAngle(m_selectedColor.getH());
673 painter.drawLine(QPointF(lineCoords.x()*iRad, lineCoords.y()*iRad), QPointF(lineCoords.x()*oRad, lineCoords.y()*oRad));
674 }
675 }
676
677 painter.restore();
678}
QVector< ColorRing > m_colorRings
QPointF mapHueToAngle(qreal hue) const
qint32 getNumRings() const
qint32 getNumPieces() const
static const QColor COLOR_NORMAL_OUTLINE

References COLOR_NORMAL_OUTLINE, COLOR_SELECTED_DARK, COLOR_SELECTED_LIGHT, KisColor::getH(), getNumPieces(), getNumRings(), KisColor::getX(), m_colorRings, m_selectedColor, m_selectedPiece, m_selectedRing, and mapHueToAngle().

◆ drawRing()

void KisColorSelector::drawRing ( QPainter & painter,
KisColorSelector::ColorRing & ring,
const QRect & rect )
private

Definition at line 551 of file kis_color_selector.cpp.

552{
553 painter.save();
554 painter.setRenderHint(QPainter::Antialiasing, true);
555 painter.resetTransform();
556 painter.translate(rect.width()/2, rect.height()/2);
557
558 if (ring.pieced.size() > 1) {
559 QTransform mirror;
560 mirror.rotate(180, Qt::YAxis);
561 painter.setTransform(mirror, true);
562 painter.scale(rect.width()/2, rect.height()/2);
563 QPen normalPen = QPen(QBrush(COLOR_NORMAL_OUTLINE), 0.005);
564 QPen clearMaskPen = QPen(QBrush(COLOR_MASK_CLEAR), 0.005);
565 QBrush brush(Qt::SolidPattern);
566
567 for(int i=0; i<ring.pieced.size(); ++i) {
568 qreal hue = qreal(i) / qreal(ring.pieced.size());
569 hue = (hue >= 1.0) ? (hue - 1.0) : hue;
570 hue = (hue < 0.0) ? (hue + 1.0) : hue;
571
573 color.setS(ring.saturation);
574 color.setX(m_selectedColor.getX());
575
577 painter.setPen(clearMaskPen);
578 } else {
579 painter.setPen(normalPen);
580 }
581
582 if ((m_enforceGamutMask) && (!colorIsClear(color))) {
583 brush.setColor(COLOR_MASK_FILL);
584 } else {
585 brush.setColor(color.toQColor());
586 }
587 painter.setBrush(brush);
588
589 painter.drawPath(ring.pieced[i]);
590 }
591 }
592 else {
593 KisColor colors[7] = {
601 };
602
603 QConicalGradient gradient(0, 0, 0);
604
605 for(int i=0; i<=6; ++i) {
606 qreal hue = qreal(i) / 6.0;
607 colors[i].setS(ring.saturation);
608 colors[i].setX(m_selectedColor.getX());
609 gradient.setColorAt(hue, colors[i].toQColor());
610 }
611
612 painter.scale(rect.width()/2, rect.height()/2);
613 painter.fillPath(ring.pieced[0], QBrush(gradient));
614 }
615
616 painter.restore();
617}
bool colorIsClear(const KisColor &color)
void setS(qreal v)
Definition kis_color.h:58
void setX(qreal v)
Definition kis_color.h:59
static const QColor COLOR_MASK_CLEAR
QVector< QPainterPath > pieced

References COLOR_MASK_CLEAR, COLOR_MASK_FILL, COLOR_NORMAL_OUTLINE, colorIsClear(), KisColor::getX(), m_colorConverter, m_colorSpace, m_enforceGamutMask, m_gamutMaskOn, m_lumaB, m_lumaG, m_lumaGamma, m_lumaR, m_selectedColor, KisColorSelector::ColorRing::pieced, KisColorSelector::ColorRing::saturation, KisColor::setS(), KisColor::setX(), and KisColor::toQColor().

◆ enforceGamutMask()

bool KisColorSelector::enforceGamutMask ( ) const
inline

Definition at line 94 of file kis_color_selector.h.

94{ return m_enforceGamutMask; }

References m_enforceGamutMask.

◆ gamutMask()

KoGamutMaskSP KisColorSelector::gamutMask ( )

Definition at line 238 of file kis_color_selector.cpp.

239{
240 return m_currentGamutMask;
241}

References m_currentGamutMask.

◆ gamutMaskOn()

bool KisColorSelector::gamutMaskOn ( )

Definition at line 243 of file kis_color_selector.cpp.

244{
245 return m_gamutMaskOn;
246}

References m_gamutMaskOn.

◆ getColorSpace()

KisColor::Type KisColorSelector::getColorSpace ( ) const
inline

Definition at line 83 of file kis_color_selector.h.

83{ return m_colorSpace; }

References m_colorSpace.

◆ getDefaultHueSteps()

quint32 KisColorSelector::getDefaultHueSteps ( ) const
inline

Definition at line 89 of file kis_color_selector.h.

89{ return m_defaultHueSteps; }

References m_defaultHueSteps.

◆ getDefaultSaturationSteps()

quint32 KisColorSelector::getDefaultSaturationSteps ( ) const
inline

Definition at line 90 of file kis_color_selector.h.

References m_defaultSaturationSteps.

◆ getDefaultValueScaleSteps()

quint32 KisColorSelector::getDefaultValueScaleSteps ( ) const
inline

Definition at line 91 of file kis_color_selector.h.

References m_defaultValueScaleSteps.

◆ getHue()

qreal KisColorSelector::getHue ( int hueIdx,
Radian shift = 0.0f ) const
private

Definition at line 368 of file kis_color_selector.cpp.

369{
370 Radian hue = (qreal(hueIdx) / qreal(getNumPieces())) * PI2;
371 hue += shift;
372 return hue.scaled(0.0, 1.0);
373}
KisRadian< qreal > Radian
#define PI2
Definition kis_radian.h:13

References getNumPieces(), PI2, and KisRadian< TReal >::scaled().

◆ getHueIndex()

qint8 KisColorSelector::getHueIndex ( Radian hue) const
private

Definition at line 362 of file kis_color_selector.cpp.

363{
364 qreal partSize = 1.0 / qreal(getNumPieces());
365 return qint8(qRound(hue.scaled(0.0, 1.0) / partSize) % getNumPieces());
366}

References getNumPieces(), and KisRadian< TReal >::scaled().

◆ getLight()

qreal KisColorSelector::getLight ( const QPointF & pt) const
private

Definition at line 348 of file kis_color_selector.cpp.

349{
350 qint8 clickedLightPiece = getLightIndex(pt);
351
352 if (clickedLightPiece >= 0) {
353 if (getNumLightPieces() > 1) {
354 return 1.0 - (qreal(clickedLightPiece) / qreal(getNumLightPieces()-1));
355 }
356 return 1.0 - (qreal(pt.y()) / qreal(m_lightStripArea.height()));
357 }
358
359 return qreal(0);
360}
qint8 getLightIndex(const QPointF &pt) const

References getLightIndex(), getNumLightPieces(), and m_lightStripArea.

◆ getLightIndex() [1/2]

qint8 KisColorSelector::getLightIndex ( const QPointF & pt) const
private

Definition at line 332 of file kis_color_selector.cpp.

333{
334 if (m_lightStripArea.contains(pt.toPoint(), true)) {
335 qreal t = (pt.y() - m_lightStripArea.y()) / qreal(m_lightStripArea.height());
336 return qint8(t * getNumLightPieces());
337 }
338
339 return -1;
340}

References getNumLightPieces(), and m_lightStripArea.

◆ getLightIndex() [2/2]

qint8 KisColorSelector::getLightIndex ( qreal light) const
private

Definition at line 342 of file kis_color_selector.cpp.

343{
344 light = qreal(1) - qBound(qreal(0), light, qreal(1));
345 return qint8(qRound(light * (getNumLightPieces()-1)));
346}

References getNumLightPieces().

◆ getNumLightPieces()

qint32 KisColorSelector::getNumLightPieces ( ) const
inline

Definition at line 86 of file kis_color_selector.h.

86{ return m_numLightPieces; }

References m_numLightPieces.

◆ getNumPieces()

qint32 KisColorSelector::getNumPieces ( ) const
inline

Definition at line 85 of file kis_color_selector.h.

85{ return m_numPieces; }

References m_numPieces.

◆ getNumRings()

qint32 KisColorSelector::getNumRings ( ) const
inline

Definition at line 84 of file kis_color_selector.h.

84{ return m_colorRings.size(); }

References m_colorRings.

◆ getSaturation()

qreal KisColorSelector::getSaturation ( int saturationIdx) const
private

Definition at line 394 of file kis_color_selector.cpp.

395{
396 qreal sat = qreal(saturationIdx) / qreal(getNumRings()-1);
397 return m_inverseSaturation ? (1.0 - sat) : sat;
398}

References getNumRings(), and m_inverseSaturation.

◆ getSaturationIndex() [1/2]

qint8 KisColorSelector::getSaturationIndex ( const QPointF & pt) const
private

Definition at line 382 of file kis_color_selector.cpp.

383{
384 qreal length = std::sqrt(pt.x()*pt.x() + pt.y()*pt.y());
385
386 for(int i=0; i<m_colorRings.size(); ++i) {
387 if (length >= m_colorRings[i].innerRadius && length < m_colorRings[i].outerRadius)
388 return qint8(i);
389 }
390
391 return -1;
392}
qreal length(const QPointF &vec)
Definition Ellipse.cc:82

References length(), and m_colorRings.

◆ getSaturationIndex() [2/2]

qint8 KisColorSelector::getSaturationIndex ( qreal saturation) const
private

Definition at line 375 of file kis_color_selector.cpp.

376{
377 saturation = qBound(qreal(0), saturation, qreal(1));
378 saturation = m_inverseSaturation ? (qreal(1) - saturation) : saturation;
379 return qint8(saturation * qreal(getNumRings() - 1));
380}

References getNumRings(), and m_inverseSaturation.

◆ getShowBgColor()

bool KisColorSelector::getShowBgColor ( ) const
inline

Definition at line 92 of file kis_color_selector.h.

92{ return m_showBgColor; }

References m_showBgColor.

◆ getShowValueScaleNumbers()

bool KisColorSelector::getShowValueScaleNumbers ( ) const
inline

Definition at line 93 of file kis_color_selector.h.

References m_showValueScaleNumbers.

◆ hasAtLeastOneDocument()

void KisColorSelector::hasAtLeastOneDocument ( bool value)

Definition at line 201 of file kis_color_selector.cpp.

202{
204}
float value(const T *src, size_t ch)

References m_hasAtLeastOneDocumentOpen, and value().

◆ init()

void KisColorSelector::init ( )
private

Definition at line 390 of file kis_color_selector.cpp.

391{
392 setAcceptDrops(true);
393
395 m_ring = new KisColorSelectorRing(this);
399 m_wheel = new KisColorSelectorWheel(this);
400
402 m_button = new QToolButton(this);
403 m_button->setIcon(KisIconUtils::loadIcon("configure-thicker"));
404 m_button->setAutoRaise(true);
405 connect(m_button, SIGNAL(clicked()), SIGNAL(settingsButtonClicked()));
406 }
407
408 // a tablet can send many more signals, than a mouse
409 // this causes many repaints, if updating after every signal.
411 connect(m_signalCompressor, SIGNAL(timeout()), SLOT(update()));
412
413 setMinimumSize(40, 40);
414}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
Acs::ColorRole m_lastColorRole
void settingsButtonClicked()
KisSignalCompressor * m_signalCompressor
@ Foreground
QIcon loadIcon(const QString &name)
bool update(QSpinBox *spinBox)

References connect(), displaySettingsButton(), KisSignalCompressor::FIRST_INACTIVE, Acs::Foreground, KisIconUtils::loadIcon(), m_button, m_lastColorRole, m_ring, m_signalCompressor, m_slider, m_square, m_triangle, m_wheel, and settingsButtonClicked().

◆ isSaturationInverted()

bool KisColorSelector::isSaturationInverted ( ) const
inline

Definition at line 87 of file kis_color_selector.h.

87{ return m_inverseSaturation; }

References m_inverseSaturation.

◆ leaveEvent()

void KisColorSelector::leaveEvent ( QEvent * e)
overrideprivate

Definition at line 1073 of file kis_color_selector.cpp.

1074{
1075 m_widgetUpdatesSelf = false;
1076#ifdef DEBUG_ARC_SELECTOR
1077 dbgPlugins << "KisColorSelector::leaveEvent: m_widgetUpdatesSelf = false";
1078#endif
1079}

References dbgPlugins, and m_widgetUpdatesSelf.

◆ loadSettings()

void KisColorSelector::loadSettings ( )

Definition at line 1111 of file kis_color_selector.cpp.

1112{
1113 KisConfig cfg(true);
1114
1115 m_defaultHueSteps = cfg.readEntry("ArtColorSel.defaultHueSteps", DEFAULT_HUE_STEPS);
1116 m_defaultSaturationSteps = cfg.readEntry("ArtColorSel.defaultSaturationSteps", DEFAULT_SATURATION_STEPS);
1117 m_defaultValueScaleSteps = cfg.readEntry("ArtColorSel.defaultValueScaleSteps", DEFAULT_VALUE_SCALE_STEPS);
1118
1119 setNumLightPieces(cfg.readEntry("ArtColorSel.LightPieces", DEFAULT_VALUE_SCALE_STEPS));
1120
1121 KisColor::Type colorSpace = KisColor::Type(cfg.readEntry<qint32>("ArtColorSel.ColorSpace" , KisColor::HSY));
1122
1124
1125 setLumaCoefficients(cfg.readEntry("ArtColorSel.lumaR", DEFAULT_LUMA_R),
1126 cfg.readEntry("ArtColorSel.lumaG", DEFAULT_LUMA_G),
1127 cfg.readEntry("ArtColorSel.lumaB", DEFAULT_LUMA_B),
1128 cfg.readEntry("ArtColorSel.lumaGamma", DEFAULT_LUMA_GAMMA));
1129
1130 m_selectedColor.setH(cfg.readEntry<qreal>("ArtColorSel.SelColorH", 0.0));
1131 m_selectedColor.setS(cfg.readEntry<qreal>("ArtColorSel.SelColorS", 0.0));
1132 m_selectedColor.setX(cfg.readEntry<qreal>("ArtColorSel.SelColorX", 0.0));
1133
1134 setInverseSaturation(cfg.readEntry<bool>("ArtColorSel.InversedSaturation", false));
1135 setLight(cfg.readEntry<qreal>("ArtColorSel.Light", 0.5f));
1136
1137 setNumRings(cfg.readEntry("ArtColorSel.NumRings", DEFAULT_SATURATION_STEPS));
1138 setNumPieces(cfg.readEntry("ArtColorSel.RingPieces", DEFAULT_HUE_STEPS));
1139
1140 m_showBgColor = cfg.readEntry("ArtColorSel.showBgColor", true);
1141 m_showValueScaleNumbers = cfg.readEntry("ArtColorSel.showValueScale", false);
1142 m_enforceGamutMask = cfg.readEntry("ArtColorSel.enforceGamutMask", false);
1143
1145 update();
1146}
const KoColorSpace * colorSpace() const
void setNumLightPieces(int num)
void setColorSpace(KisColor::Type type)
void setInverseSaturation(bool inverse)
void setNumPieces(int num)
void setLight(qreal light=0.0f)
void setH(qreal v)
Definition kis_color.h:57

References KisColorSelectorBase::colorSpace(), DEFAULT_HUE_STEPS, DEFAULT_LUMA_B, DEFAULT_LUMA_G, DEFAULT_LUMA_GAMMA, DEFAULT_LUMA_R, DEFAULT_SATURATION_STEPS, DEFAULT_VALUE_SCALE_STEPS, KisColor::HSY, m_defaultHueSteps, m_defaultSaturationSteps, m_defaultValueScaleSteps, m_enforceGamutMask, m_selectedColor, m_showBgColor, m_showValueScaleNumbers, KisConfig::readEntry(), selectColor(), setColorSpace(), KisColor::setH(), setInverseSaturation(), setLight(), setLumaCoefficients(), setNumLightPieces(), setNumPieces(), setNumRings(), KisColor::setS(), and KisColor::setX().

◆ lumaB()

qreal KisColorSelector::lumaB ( ) const
inline

Definition at line 60 of file kis_color_selector.h.

60{ return m_lumaB; }

References m_lumaB.

◆ lumaG()

qreal KisColorSelector::lumaG ( ) const
inline

Definition at line 59 of file kis_color_selector.h.

59{ return m_lumaG; }

References m_lumaG.

◆ lumaGamma()

qreal KisColorSelector::lumaGamma ( ) const
inline

Definition at line 61 of file kis_color_selector.h.

61{ return m_lumaGamma; }

References m_lumaGamma.

◆ lumaR()

qreal KisColorSelector::lumaR ( ) const
inline

Definition at line 58 of file kis_color_selector.h.

58{ return m_lumaR; }

References m_lumaR.

◆ mapColorToUnit()

QPointF KisColorSelector::mapColorToUnit ( const KisColor & color,
bool invertSaturation = true ) const
private

Definition at line 292 of file kis_color_selector.cpp.

293{
294 qreal radius;
295 if (invertSaturation && m_inverseSaturation) {
296 radius = 1.0 - color.getS();
297 } else {
298 radius = color.getS();
299 }
300
301 QPointF hueCoord = mapHueToAngle(color.getH());
302 qreal x = hueCoord.x()*radius;
303 qreal y = hueCoord.y()*radius;
304
305 return QPointF(x,y);
306}

References KisColor::getH(), KisColor::getS(), m_inverseSaturation, and mapHueToAngle().

◆ mapCoordToAngle()

KisColorSelector::Radian KisColorSelector::mapCoordToAngle ( qreal x,
qreal y ) const
private

Definition at line 308 of file kis_color_selector.cpp.

309{
310 qreal angle = std::atan2(-y, -x);
311
312#ifdef DEBUG_ARC_SELECTOR
313 dbgPlugins << "KisColorSelector::mapCoordToAngle: "
314 << "X:" << x
315 << "Y:" << y
316 << "angle:" << angle;
317#endif
318
319 return angle;
320}

References dbgPlugins.

◆ mapCoordToUnit()

QPointF KisColorSelector::mapCoordToUnit ( const QPointF & pt,
const QRectF & viewRect ) const
private

Definition at line 283 of file kis_color_selector.cpp.

284{
285 qreal w = viewRect.width() / 2.0;
286 qreal h = viewRect.height() / 2.0;
287 qreal x = pt.x() - (viewRect.x() + w);
288 qreal y = pt.y() - (viewRect.y() + h);
289 return QPointF(x/w, y/h);
290}

◆ mapCoordToView()

QPointF KisColorSelector::mapCoordToView ( const QPointF & pt,
const QRectF & viewRect ) const
private

Definition at line 272 of file kis_color_selector.cpp.

273{
274 qreal w = viewRect.width() / 2.0;
275 qreal h = viewRect.height() / 2.0;
276
277 qreal x = pt.x() + 1.0;
278 qreal y = (pt.y()) + 1.0;
279
280 return QPointF(x*w, y*h);
281}

◆ mapHueToAngle()

QPointF KisColorSelector::mapHueToAngle ( qreal hue) const
private

Definition at line 322 of file kis_color_selector.cpp.

323{
324 qreal angle = hue * 2.0 * M_PI - M_PI;
325 qreal x = std::cos(angle);
326 qreal y = std::sin(angle);
327
328 return QPointF(x,y);
329}
#define M_PI
Definition kis_global.h:111

References M_PI.

◆ mouseEvent()

void KisColorSelector::mouseEvent ( QMouseEvent * e)
private

Definition at line 376 of file kis_color_selector.cpp.

377{
378 if (m_grabbingComponent && (e->buttons() & Qt::LeftButton || e->buttons() & Qt::RightButton)) {
379
380 m_grabbingComponent->mouseEvent(e->x(), e->y());
381
383 Acs::ColorRole role = Acs::buttonsToRole(e->button(), e->buttons());
384 m_currentRealColor = color;
385
386 requestUpdateColorAndPreview(color, role);
387 }
388}
virtual void mouseEvent(int x, int y)
saves the mouse position, so that a blip can be created.
KoColor currentColor()
return the color, that was selected by calling mouseEvent
void requestUpdateColorAndPreview(const KisColor &color, Acs::ColorRole role)
ColorRole buttonsToRole(Qt::MouseButton button, Qt::MouseButtons buttons)

References Acs::buttonsToRole(), KisColorSelectorComponent::currentColor(), m_currentRealColor, m_grabbingComponent, m_mainComponent, KisColorSelectorComponent::mouseEvent(), and requestUpdateColorAndPreview().

◆ mouseMoveEvent() [1/2]

void KisColorSelector::mouseMoveEvent ( QMouseEvent * e)
overrideprotected

Definition at line 335 of file kis_color_selector.cpp.

336{
338
339 mouseEvent(e);
340 e->accept();
341}
void mouseMoveEvent(QMouseEvent *event) override
void mouseEvent(QMouseEvent *e)

References mouseEvent(), and KisColorSelectorBase::mouseMoveEvent().

◆ mouseMoveEvent() [2/2]

void KisColorSelector::mouseMoveEvent ( QMouseEvent * event)
overrideprivate

◆ mousePressEvent() [1/2]

void KisColorSelector::mousePressEvent ( QMouseEvent * e)
overrideprotected

Definition at line 318 of file kis_color_selector.cpp.

319{
320 e->setAccepted(false);
322
323 if(!e->isAccepted()) {
324 if(m_mainComponent->wantsGrab(e->x(), e->y()))
326 else if(m_subComponent->wantsGrab(e->x(), e->y()))
328
329 mouseEvent(e);
331 e->accept();
332 }
333}
void mousePressEvent(QMouseEvent *) override
bool wantsGrab(int x, int y)
returns true, if this component wants to grab the mouse (normally true, if containsPoint returns true...

References m_grabbingComponent, m_mainComponent, m_subComponent, mouseEvent(), KisColorSelectorBase::mousePressEvent(), KisColorSelectorBase::updatePreviousColorPreview(), and KisColorSelectorComponent::wantsGrab().

◆ mousePressEvent() [2/2]

void KisColorSelector::mousePressEvent ( QMouseEvent * event)
overrideprivate

◆ mouseReleaseEvent() [1/2]

void KisColorSelector::mouseReleaseEvent ( QMouseEvent * e)
overrideprotected

Definition at line 343 of file kis_color_selector.cpp.

344{
345 e->setAccepted(false);
347
348 if(!e->isAccepted() &&
350
352 m_lastColorRole = Acs::buttonToRole(e->button());
353
356 e->accept();
357 }
358
360}
void mouseReleaseEvent(QMouseEvent *) override
void updateBaseColorPreview(const KoColor &color)
void updateColor(const KoColor &color, Acs::ColorRole role, bool needsExplicitColorReset)
ColorRole buttonToRole(Qt::MouseButton button)

References Acs::buttonToRole(), m_currentRealColor, m_grabbingComponent, m_lastColorRole, m_lastRealColor, KisColorSelectorBase::mouseReleaseEvent(), KisColorSelectorBase::updateBaseColorPreview(), and KisColorSelectorBase::updateColor().

◆ mouseReleaseEvent() [2/2]

void KisColorSelector::mouseReleaseEvent ( QMouseEvent * event)
overrideprivate

◆ paintEvent() [1/2]

void KisColorSelector::paintEvent ( QPaintEvent * e)
overrideprotected

Definition at line 219 of file kis_color_selector.cpp.

220{
221 Q_UNUSED(e);
222 QPainter p(this);
223 KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector");
224
225 // If checked, use theme colors for background of selector
226 if (cfg.readEntry("useCustomColorForBackground", false)) {
227 p.fillRect(0,0,width(), height(), cfg.readEntry("customSelectorBackgroundColor", QColor(Qt::gray)));
228 } else {
229 p.fillRect(0,0,width(), height(), qApp->palette().window().color());
230 }
231
232 p.setRenderHint(QPainter::Antialiasing);
233
234 // this variable name isn't entirely accurate to what always happens. see definition in header file to understand it better
236 p.setOpacity(0.2);
237 }
238
241
242 p.setOpacity(1.0);
243}
const Params2D p

References m_hasAtLeastOneDocumentOpen, m_mainComponent, m_subComponent, p, and KisColorSelectorComponent::paintEvent().

◆ paintEvent() [2/2]

void KisColorSelector::paintEvent ( QPaintEvent * event)
overrideprivate

◆ recalculateAreas()

void KisColorSelector::recalculateAreas ( quint8 numLightPieces)
private

Definition at line 400 of file kis_color_selector.cpp.

401{
402 qreal LIGHT_STRIP_RATIO = 0.075;
403
405 LIGHT_STRIP_RATIO = 0.25;
406 }
407
408 int width = QWidget::width();
409 int height = QWidget::height();
410 int size = qMin(width, height);
411 int stripThick = int(size * LIGHT_STRIP_RATIO);
412
413 width -= stripThick;
414
415 size = qMin(width, height);
416
417 int x = (width - size) / 2;
418 int y = (height - size) / 2;
419
420 m_widgetArea = QRect(0, 0, QWidget::width(), QWidget::height());
421 m_renderArea = QRect(x+stripThick, y, size, size);
422 m_lightStripArea = QRect(0, 0, stripThick, QWidget::height());
423
424 m_renderBuffer = QImage(size*devicePixelRatioF(), size*devicePixelRatioF(), QImage::Format_ARGB32_Premultiplied);
425 m_colorPreviewBuffer = QImage(QWidget::width()*devicePixelRatioF(), QWidget::height()*devicePixelRatioF(), QImage::Format_ARGB32_Premultiplied);
426 m_maskBuffer = QImage(size*devicePixelRatioF(), size*devicePixelRatioF(), QImage::Format_ARGB32_Premultiplied);
427 m_lightStripBuffer = QImage(stripThick*devicePixelRatioF(), QWidget::height()*devicePixelRatioF(), QImage::Format_ARGB32_Premultiplied);
428
429 m_renderBuffer.setDevicePixelRatio(devicePixelRatioF());
430 m_colorPreviewBuffer.setDevicePixelRatio(devicePixelRatioF());
431 m_maskBuffer.setDevicePixelRatio(devicePixelRatioF());
432 m_lightStripBuffer.setDevicePixelRatio(devicePixelRatioF());
433
434 m_numLightPieces = numLightPieces;
435
436 if (m_currentGamutMask) {
437 m_gamutMaskViewTransform = m_currentGamutMask->maskToViewTransform(m_renderArea.width());
438 }
439
440 m_isDirtyGamutMask = true;
441 m_isDirtyLightStrip = true;
442 m_isDirtyWheel = true;
444}
int size(const Forest< T > &forest)
Definition KisForest.h:1232

References m_colorPreviewBuffer, m_currentGamutMask, m_gamutMaskViewTransform, m_isDirtyColorPreview, m_isDirtyGamutMask, m_isDirtyLightStrip, m_isDirtyWheel, m_lightStripArea, m_lightStripBuffer, m_maskBuffer, m_numLightPieces, m_renderArea, m_renderBuffer, m_showValueScaleNumbers, and m_widgetArea.

◆ recalculateRings()

void KisColorSelector::recalculateRings ( quint8 numRings,
quint8 numPieces )
private

Definition at line 446 of file kis_color_selector.cpp.

447{
448 m_colorRings.resize(numRings);
449 m_numPieces = numPieces;
450
451 for(int i=0; i<numRings; ++i) {
452 qreal innerRadius = qreal(i) / qreal(numRings);
453 qreal outerRadius = qreal(i+1) / qreal(numRings);
454 qreal saturation = qreal(i) / qreal(numRings-1);
455
456 createRing(m_colorRings[i], numPieces, innerRadius, outerRadius+0.001);
457 m_colorRings[i].saturation = m_inverseSaturation ? (1.0 - saturation) : saturation;
458 }
459
460 m_isDirtyWheel = true;
461}
void createRing(ColorRing &wheel, quint8 numPieces, qreal innerRadius, qreal outerRadius)

References createRing(), m_colorRings, m_inverseSaturation, m_isDirtyWheel, and m_numPieces.

◆ requestUpdateColorAndPreview()

void KisColorSelector::requestUpdateColorAndPreview ( const KisColor & color,
Acs::ColorRole role )
private

Definition at line 512 of file kis_color_selector.cpp.

513{
514#ifdef DEBUG_ARC_SELECTOR
515 dbgPlugins << "KisColorSelector::requestUpdateColorAndPreview: requesting update to: "
516 << "H:" << color.getH()
517 << "S:" << color.getS()
518 << "X:" << color.getX();
519#endif
520
521 m_updateColorCompressor->start(qMakePair(color, role));
522}

References dbgPlugins, KisColor::getH(), KisColor::getS(), KisColor::getX(), and m_updateColorCompressor.

◆ reset

void KisColorSelector::reset ( )
overrideslot

Definition at line 206 of file kis_color_selector.cpp.

207{
208 if (m_mainComponent) {
210 }
211
212 if (m_subComponent) {
214 }
215
217}
void setDirty()
force subsequent redraw of the component

References m_mainComponent, m_subComponent, KisColorSelectorBase::reset(), and KisColorSelectorComponent::setDirty().

◆ resizeEvent() [1/2]

void KisColorSelector::resizeEvent ( QResizeEvent * e)
overrideprotected

Definition at line 258 of file kis_color_selector.cpp.

258 {
260
261 m_ring->setGeometry(0,0,width(), height());
262
263 if (displaySettingsButton()) {
264 int size = iconSize(width(), height());
265 m_button->setGeometry(0, 0, size, size);
266 }
267
270 height()/2-m_ring->innerRadius(),
271 m_ring->innerRadius()*2,
272 m_ring->innerRadius()*2);
273 }
274 else {
275 int size = m_ring->innerRadius()*2/sqrt(2.);
276 m_square->setGeometry(width()/2-size/2,
277 height()/2-size/2,
278 size,
279 size);
280 }
281 }
282 else {
283 // type wheel and square
286 int size = iconSize(width(), height()*0.9);
287 m_button->setGeometry(0, height()*0.1, size, size);
288 }
289 m_mainComponent->setGeometry(0, height()*0.1, width(), height()*0.9);
290 m_subComponent->setGeometry( 0, 0, width(), height()*0.1);
291 }
292 else {
293 int buttonSize = 0;
295 buttonSize = qBound(20, int(0.1*height()), 32);
296 m_button->setGeometry(0, 0, buttonSize, buttonSize);
297 }
298
299 if(height()>width()) {
300 int selectorHeight=height()-buttonSize;
301 m_mainComponent->setGeometry(0, buttonSize+selectorHeight*0.1, width(), selectorHeight*0.9);
302 m_subComponent->setGeometry( 0, buttonSize, width(), selectorHeight*0.1);
303 }
304 else {
305 int selectorWidth=width()-buttonSize;
306 m_mainComponent->setGeometry(buttonSize, height()*0.1, selectorWidth, height()*0.9);
307 m_subComponent->setGeometry( buttonSize, 0, selectorWidth, height()*0.1);
308 }
309 }
310 }
311
312 // reset the correct color after resizing the widget
314
315 KisColorSelectorBase::resizeEvent(e);
316}
static int buttonSize(int screen)
Definition KoToolBox.cpp:41
int iconSize(qreal width, qreal height)
void setGeometry(int x, int y, int width, int height)
void setColor(const KoColor &color) override

References buttonSize(), displaySettingsButton(), iconSize(), KisColorSelectorRing::innerRadius(), m_button, m_configuration, m_lastRealColor, m_mainComponent, m_ring, m_square, m_subComponent, m_triangle, KisColorSelectorConfiguration::mainType, KisColorSelectorConfiguration::Ring, setColor(), KisColorSelectorComponent::setGeometry(), KisColorSelectorConfiguration::subType, KisColorSelectorConfiguration::Triangle, and KisColorSelectorConfiguration::Wheel.

◆ resizeEvent() [2/2]

void KisColorSelector::resizeEvent ( QResizeEvent * event)
overrideprivate

◆ saveSettings()

void KisColorSelector::saveSettings ( )

Definition at line 1081 of file kis_color_selector.cpp.

1082{
1083 KisConfig cfg(false);
1084 cfg.writeEntry("ArtColorSel.ColorSpace" , qint32(m_colorSpace));
1085
1086 cfg.writeEntry("ArtColorSel.lumaR", qreal(m_lumaR));
1087 cfg.writeEntry("ArtColorSel.lumaG", qreal(m_lumaG));
1088 cfg.writeEntry("ArtColorSel.lumaB", qreal(m_lumaB));
1089 cfg.writeEntry("ArtColorSel.lumaGamma", qreal(m_lumaGamma));
1090
1091 cfg.writeEntry("ArtColorSel.NumRings" , m_colorRings.size());
1092 cfg.writeEntry("ArtColorSel.RingPieces" , qint32(m_numPieces));
1093 cfg.writeEntry("ArtColorSel.LightPieces", qint32(m_numLightPieces));
1094
1095 cfg.writeEntry("ArtColorSel.InversedSaturation", m_inverseSaturation);
1096 cfg.writeEntry("ArtColorSel.Light" , m_selectedColor.getX());
1097
1098 cfg.writeEntry("ArtColorSel.SelColorH", m_selectedColor.getH());
1099 cfg.writeEntry("ArtColorSel.SelColorS", m_selectedColor.getS());
1100 cfg.writeEntry("ArtColorSel.SelColorX", m_selectedColor.getX());
1101
1102 cfg.writeEntry("ArtColorSel.defaultHueSteps", quint32(m_defaultHueSteps));
1103 cfg.writeEntry("ArtColorSel.defaultSaturationSteps", quint32(m_defaultSaturationSteps));
1104 cfg.writeEntry("ArtColorSel.defaultValueScaleSteps", quint32(m_defaultValueScaleSteps));
1105
1106 cfg.writeEntry("ArtColorSel.showBgColor", m_showBgColor);
1107 cfg.writeEntry("ArtColorSel.showValueScale", m_showValueScaleNumbers);
1108 cfg.writeEntry("ArtColorSel.enforceGamutMask", m_enforceGamutMask);
1109}

References KisColor::getH(), KisColor::getS(), KisColor::getX(), m_colorRings, m_colorSpace, m_defaultHueSteps, m_defaultSaturationSteps, m_defaultValueScaleSteps, m_enforceGamutMask, m_inverseSaturation, m_lumaB, m_lumaG, m_lumaGamma, m_lumaR, m_numLightPieces, m_numPieces, m_selectedColor, m_showBgColor, m_showValueScaleNumbers, and KisConfig::writeEntry().

◆ selectColor()

◆ setBgColor()

void KisColorSelector::setBgColor ( const KoColor & bgColor)

Definition at line 155 of file kis_color_selector.cpp.

156{
157 if (!m_widgetUpdatesSelf) {
159
161
162#ifdef DEBUG_ARC_SELECTOR
163 dbgPlugins << "KisColorSelector::setBgColor: m_bgColor set to:"
164 << "H:" << m_bgColor.getH()
165 << "S:" << m_bgColor.getS()
166 << "X:" << m_bgColor.getX();
167#endif
168 update();
169 }
170}

References dbgPlugins, KisColor::getH(), KisColor::getS(), KisColor::getX(), m_bgColor, m_colorConverter, m_colorSpace, m_isDirtyColorPreview, m_lumaB, m_lumaG, m_lumaGamma, m_lumaR, and m_widgetUpdatesSelf.

◆ setColor()

void KisColorSelector::setColor ( const KoColor & color)
overridevirtual

◆ setColorConverter()

◆ setColorSpace()

void KisColorSelector::setColorSpace ( KisColor::Type type)

Definition at line 60 of file kis_color_selector.cpp.

61{
62 m_colorSpace = type;
64
66 m_isDirtyWheel = true;
67
68#ifdef DEBUG_ARC_SELECTOR
69 dbgPlugins << "KisColorSelector::setColorSpace: set to:" << m_colorSpace;
70#endif
71
72 update();
73}

References dbgPlugins, m_colorConverter, m_colorSpace, m_isDirtyLightStrip, m_isDirtyWheel, m_lumaB, m_lumaG, m_lumaGamma, m_lumaR, and m_selectedColor.

◆ setConfiguration()

void KisColorSelector::setConfiguration ( KisColorSelectorConfiguration conf)

Definition at line 79 of file kis_color_selector.cpp.

80{
81 m_configuration = conf;
82
83 if(m_mainComponent!=0) {
84 Q_ASSERT(m_subComponent!=0);
85 m_mainComponent->setGeometry(0, 0, 0, 0);
86 m_subComponent->setGeometry(0, 0, 0, 0);
87
88 m_mainComponent->disconnect();
89 m_subComponent->disconnect();
90 }
91
92 switch (m_configuration.mainType) {
95 break;
98 break;
101 break;
102 default:
103 Q_ASSERT(false);
104 }
105
106 switch (m_configuration.subType) {
109 break;
112 break;
113 default:
114 Q_ASSERT(false);
115 }
116
117 connect(m_mainComponent, SIGNAL(paramChanged(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)),
118 m_subComponent, SLOT(setParam(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)), Qt::UniqueConnection);
119 connect(m_subComponent, SIGNAL(paramChanged(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)),
120 m_mainComponent, SLOT(setParam(qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal,qreal)), Qt::UniqueConnection);
121
122 connect(m_mainComponent, SIGNAL(update()), m_signalCompressor, SLOT(start()), Qt::UniqueConnection);
123 connect(m_subComponent, SIGNAL(update()), m_signalCompressor, SLOT(start()), Qt::UniqueConnection);
124
126
127 // Use Hluma as subType when the main type uses hsy'.
130
132 QResizeEvent event(QSize(width(), height()), QSize());
133 resizeEvent(&event);
134}
void setConfiguration(Parameter param, Type type)
setConfiguration can be ignored (for instance ring and triangle, as they can have only one config)
void resizeEvent(QResizeEvent *) override

References connect(), KisColorSelectorConfiguration::Hluma, m_configuration, m_mainComponent, m_ring, m_signalCompressor, m_slider, m_square, m_subComponent, m_triangle, m_wheel, KisColorSelectorConfiguration::mainType, KisColorSelectorConfiguration::mainTypeParameter, resizeEvent(), KisColorSelectorConfiguration::Ring, KisColorSelectorComponent::setConfiguration(), KisColorSelectorComponent::setGeometry(), KisColorSelectorConfiguration::Slider, KisColorSelectorConfiguration::Square, KisColorSelectorConfiguration::subType, KisColorSelectorConfiguration::subTypeParameter, KisColorSelectorConfiguration::SY, KisColorSelectorConfiguration::Triangle, and KisColorSelectorConfiguration::Wheel.

◆ setDefaultHueSteps()

void KisColorSelector::setDefaultHueSteps ( int num)

Definition at line 1148 of file kis_color_selector.cpp.

1149{
1150 num = qBound(MIN_NUM_HUE_PIECES, num, MAX_NUM_HUE_PIECES);
1151 m_defaultHueSteps = num;
1152}
static const int MAX_NUM_HUE_PIECES
static const int MIN_NUM_HUE_PIECES

References m_defaultHueSteps, MAX_NUM_HUE_PIECES, and MIN_NUM_HUE_PIECES.

◆ setDefaultSaturationSteps()

void KisColorSelector::setDefaultSaturationSteps ( int num)

Definition at line 1154 of file kis_color_selector.cpp.

1155{
1158}
static const int MIN_NUM_SATURATION_RINGS
static const int MAX_NUM_SATURATION_RINGS

References m_defaultSaturationSteps, MAX_NUM_SATURATION_RINGS, and MIN_NUM_SATURATION_RINGS.

◆ setDefaultValueScaleSteps()

void KisColorSelector::setDefaultValueScaleSteps ( int num)

Definition at line 1160 of file kis_color_selector.cpp.

1161{
1162 num = qBound(MIN_NUM_LIGHT_PIECES, num, MAX_NUM_LIGHT_PIECES);
1164}
static const int MAX_NUM_LIGHT_PIECES
static const int MIN_NUM_LIGHT_PIECES

References m_defaultValueScaleSteps, MAX_NUM_LIGHT_PIECES, and MIN_NUM_LIGHT_PIECES.

◆ setDirty()

void KisColorSelector::setDirty ( )

Definition at line 228 of file kis_color_selector.cpp.

229{
230 m_isDirtyWheel = true;
231 m_isDirtyLightStrip = true;
232 m_isDirtyGamutMask = true;
234
235 update();
236}

References m_isDirtyColorPreview, m_isDirtyGamutMask, m_isDirtyLightStrip, and m_isDirtyWheel.

◆ setDisplayBlip()

void KisColorSelector::setDisplayBlip ( bool disp)
inline

Definition at line 91 of file kis_color_selector.h.

91{m_blipDisplay = disp;}

References m_blipDisplay.

◆ setEnforceGamutMask()

void KisColorSelector::setEnforceGamutMask ( bool enforce)

Definition at line 264 of file kis_color_selector.cpp.

265{
266 m_enforceGamutMask = enforce;
267 m_isDirtyGamutMask = true;
268 m_isDirtyWheel = true;
269 update();
270}

References m_enforceGamutMask, m_isDirtyGamutMask, and m_isDirtyWheel.

◆ setFgColor()

void KisColorSelector::setFgColor ( const KoColor & fgColor)

Definition at line 131 of file kis_color_selector.cpp.

132{
133 if (!m_widgetUpdatesSelf) {
136
137 m_isDirtyWheel = true;
138 m_isDirtyLightStrip = true;
140#ifdef DEBUG_ARC_SELECTOR
141 dbgPlugins << "KisColorSelector::setFgColor: m_fgColor set to:"
142 << "H:" << m_fgColor.getH()
143 << "S:" << m_fgColor.getS()
144 << "X:" << m_fgColor.getX();
145
146 dbgPlugins << "KisColorSelector::setFgColor: m_selectedColor set to:"
147 << "H:" << m_selectedColor.getH()
148 << "S:" << m_selectedColor.getS()
149 << "X:" << m_selectedColor.getX();
150#endif
151 update();
152 }
153}

References dbgPlugins, KisColor::getH(), KisColor::getS(), KisColor::getX(), m_colorConverter, m_colorSpace, m_fgColor, m_isDirtyColorPreview, m_isDirtyLightStrip, m_isDirtyWheel, m_lumaB, m_lumaG, m_lumaGamma, m_lumaR, m_selectedColor, and m_widgetUpdatesSelf.

◆ setGamutMask()

void KisColorSelector::setGamutMask ( KoGamutMaskSP gamutMask)

Definition at line 210 of file kis_color_selector.cpp.

211{
212 if (!gamutMask) {
213 return;
214 }
215
217 m_gamutMaskViewTransform = m_currentGamutMask->maskToViewTransform(m_renderArea.width());
218
219 if (m_enforceGamutMask) {
220 m_isDirtyWheel = true;
221 } else {
222 m_isDirtyGamutMask = true;
223 }
224
225 update();
226}
KoGamutMaskSP gamutMask()

References gamutMask(), m_currentGamutMask, m_enforceGamutMask, m_gamutMaskViewTransform, m_isDirtyGamutMask, m_isDirtyWheel, and m_renderArea.

◆ setGamutMaskOn()

void KisColorSelector::setGamutMaskOn ( bool gamutMaskOn)

Definition at line 249 of file kis_color_selector.cpp.

250{
251 if (m_currentGamutMask) {
253
254 if (m_enforceGamutMask) {
255 m_isDirtyWheel = true;
256 } else {
257 m_isDirtyGamutMask = true;
258 }
259
260 update();
261 }
262}

References gamutMaskOn(), m_currentGamutMask, m_enforceGamutMask, m_gamutMaskOn, m_isDirtyGamutMask, and m_isDirtyWheel.

◆ setInverseSaturation()

void KisColorSelector::setInverseSaturation ( bool inverse)

Definition at line 200 of file kis_color_selector.cpp.

201{
202 if (m_inverseSaturation != inverse) {
204 m_inverseSaturation = inverse;
205 recalculateRings(quint8(getNumRings()), quint8(getNumPieces()));
206 update();
207 }
208}

References getNumPieces(), getNumRings(), m_inverseSaturation, m_selectedRing, and recalculateRings().

◆ setLight()

void KisColorSelector::setLight ( qreal light = 0.0f)

◆ setLumaCoefficients()

void KisColorSelector::setLumaCoefficients ( qreal lR,
qreal lG,
qreal lB,
qreal lGamma )

Definition at line 180 of file kis_color_selector.cpp.

181{
182 m_lumaR = lR;
183 m_lumaG = lG;
184 m_lumaB = lB;
185 m_lumaGamma = lGamma;
186
188
189 m_isDirtyLightStrip = true;
190 m_isDirtyWheel = true;
191
192#ifdef DEBUG_ARC_SELECTOR
193 dbgPlugins << "KisColorSelector::setLumaCoefficients: " << m_lumaR
194 << " " << m_lumaG << " " << m_lumaB << " " << m_lumaGamma;
195#endif
196
197 update();
198}

References dbgPlugins, m_colorConverter, m_colorSpace, m_isDirtyLightStrip, m_isDirtyWheel, m_lumaB, m_lumaG, m_lumaGamma, m_lumaR, and m_selectedColor.

◆ setNumLightPieces()

void KisColorSelector::setNumLightPieces ( int num)

◆ setNumPieces()

void KisColorSelector::setNumPieces ( int num)

◆ setNumRings()

void KisColorSelector::setNumRings ( int num)

◆ setShowBgColor()

void KisColorSelector::setShowBgColor ( bool value)

Definition at line 1166 of file kis_color_selector.cpp.

1167{
1169 m_isDirtyColorPreview = true;
1170 update();
1171}

References m_isDirtyColorPreview, m_showBgColor, and value().

◆ setShowValueScaleNumbers()

void KisColorSelector::setShowValueScaleNumbers ( bool value)

◆ settingsButtonClicked

void KisColorSelector::settingsButtonClicked ( )
signal

◆ sigBgColorChanged

void KisColorSelector::sigBgColorChanged ( const KisColor & color)
signal

◆ sigFgColorChanged

void KisColorSelector::sigFgColorChanged ( const KisColor & color)
signal

◆ slotGamutMaskDeactivate

void KisColorSelector::slotGamutMaskDeactivate ( )
slot

Definition at line 184 of file kis_color_selector.cpp.

185{
186 slotGamutMaskToggle(false);
187}
void slotGamutMaskToggle(bool state)

References slotGamutMaskToggle().

◆ slotGamutMaskPreviewUpdate

void KisColorSelector::slotGamutMaskPreviewUpdate ( )
slot

◆ slotGamutMaskSet

void KisColorSelector::slotGamutMaskSet ( KoGamutMaskSP gamutMask)
slot

◆ slotGamutMaskToggle

void KisColorSelector::slotGamutMaskToggle ( bool state)
slot

◆ slotGamutMaskUnset

◆ slotUpdateColorAndPreview()

void KisColorSelector::slotUpdateColorAndPreview ( QPair< KisColor, Acs::ColorRole > color)

Definition at line 524 of file kis_color_selector.cpp.

525{
526 const bool selectAsFgColor = color.second == Acs::Foreground;
527
528 if (selectAsFgColor) {
530 } else {
532 }
533
535
536 m_isDirtyLightStrip = true;
538 m_isDirtyWheel = true;
539
540#ifdef DEBUG_ARC_SELECTOR
541 dbgPlugins << "KisColorSelector::slotUpdateColorAndPreview: m_selectedColor set to:"
542 << "H:" << m_selectedColor.getH()
543 << "S:" << m_selectedColor.getS()
544 << "X:" << m_selectedColor.getX();
545#endif
546
547 if (selectAsFgColor) { Q_EMIT sigFgColorChanged(m_selectedColor); }
548 else { Q_EMIT sigBgColorChanged(m_selectedColor); }
549}
void sigFgColorChanged(const KisColor &color)
void sigBgColorChanged(const KisColor &color)

References dbgPlugins, Acs::Foreground, KisColor::getH(), KisColor::getS(), KisColor::getX(), m_bgColor, m_colorConverter, m_colorSpace, m_fgColor, m_isDirtyColorPreview, m_isDirtyLightStrip, m_isDirtyWheel, m_lumaB, m_lumaG, m_lumaGamma, m_lumaR, m_selectedColor, sigBgColorChanged(), and sigFgColorChanged().

◆ updateIcons()

void KisColorSelector::updateIcons ( )

update icons when a theme update happens

Definition at line 195 of file kis_color_selector.cpp.

195 {
196 if (m_button) {
197 m_button->setIcon(KisIconUtils::loadIcon("configure"));
198 }
199}

References KisIconUtils::loadIcon(), and m_button.

◆ updateSettings

void KisColorSelector::updateSettings ( )
overrideslot

Definition at line 141 of file kis_color_selector.cpp.

142{
144 KConfigGroup cfg = KSharedConfig::openConfig()->group("advancedColorSelector");
145
147
148 if (m_canvas && m_canvas->viewManager() && m_canvas->viewManager()->canvasResourceProvider()) {
149 bool gamutMaskActive = m_canvas->viewManager()->canvasResourceProvider()->gamutMaskActive();
150
151 if (gamutMaskActive) {
152 KoGamutMaskSP currentMask = m_canvas->viewManager()->canvasResourceProvider()->currentGamutMask();
153 if (currentMask) {
154 slotGamutMaskSet(currentMask);
155 }
156 } else {
157 slotGamutMaskToggle(false);
158 }
159 }
160}
QPointer< KisCanvas2 > m_canvas
static KisColorSelectorConfiguration fromString(QString string)
void slotGamutMaskSet(KoGamutMaskSP gamutMask)
QString toString(const QString &value)

References KisColorSelectorConfiguration::fromString(), KisColorSelectorBase::m_canvas, setConfiguration(), slotGamutMaskSet(), slotGamutMaskToggle(), and KisColorSelectorBase::updateSettings().

Member Data Documentation

◆ m_bgColor

KisColor KisColorSelector::m_bgColor
private

Definition at line 154 of file kis_color_selector.h.

◆ m_blipDisplay

bool KisColorSelector::m_blipDisplay
private

Definition at line 80 of file kis_color_selector.h.

◆ m_button

QToolButton* KisColorSelector::m_button
private

Definition at line 69 of file kis_color_selector.h.

◆ m_clickedRing

qint8 KisColorSelector::m_clickedRing
private

Definition at line 164 of file kis_color_selector.h.

◆ m_clickPos

QPointF KisColorSelector::m_clickPos
private

Definition at line 163 of file kis_color_selector.h.

◆ m_colorConverter

KisDisplayColorConverter* KisColorSelector::m_colorConverter
private

Definition at line 144 of file kis_color_selector.h.

◆ m_colorPreviewBuffer

QImage KisColorSelector::m_colorPreviewBuffer
private

Definition at line 158 of file kis_color_selector.h.

◆ m_colorRings

QVector<ColorRing> KisColorSelector::m_colorRings
private

Definition at line 165 of file kis_color_selector.h.

◆ m_colorSpace

KisColor::Type KisColorSelector::m_colorSpace
private

Definition at line 145 of file kis_color_selector.h.

◆ m_configuration

KisColorSelectorConfiguration KisColorSelector::m_configuration
private

Definition at line 76 of file kis_color_selector.h.

◆ m_currentGamutMask

KoGamutMaskSP KisColorSelector::m_currentGamutMask
private

Definition at line 176 of file kis_color_selector.h.

◆ m_currentRealColor

KoColor KisColorSelector::m_currentRealColor
private

Definition at line 79 of file kis_color_selector.h.

◆ m_defaultHueSteps

quint8 KisColorSelector::m_defaultHueSteps
private

Definition at line 169 of file kis_color_selector.h.

◆ m_defaultSaturationSteps

quint8 KisColorSelector::m_defaultSaturationSteps
private

Definition at line 170 of file kis_color_selector.h.

◆ m_defaultValueScaleSteps

quint8 KisColorSelector::m_defaultValueScaleSteps
private

Definition at line 171 of file kis_color_selector.h.

◆ m_enforceGamutMask

bool KisColorSelector::m_enforceGamutMask
private

Definition at line 177 of file kis_color_selector.h.

◆ m_fgColor

KisColor KisColorSelector::m_fgColor
private

Definition at line 153 of file kis_color_selector.h.

◆ m_gamutMaskOn

bool KisColorSelector::m_gamutMaskOn
private

Definition at line 175 of file kis_color_selector.h.

◆ m_gamutMaskViewTransform

QTransform KisColorSelector::m_gamutMaskViewTransform
private

Definition at line 181 of file kis_color_selector.h.

◆ m_grabbingComponent

KisColorSelectorComponent* KisColorSelector::m_grabbingComponent
private

Definition at line 72 of file kis_color_selector.h.

◆ m_hasAtLeastOneDocumentOpen

bool KisColorSelector::m_hasAtLeastOneDocumentOpen = true
private

if Krita starts with a reference to this component that is attached to a canvas, it will call setCanvas() that check will be what ultimately decides whether this component will look enabled or disabled This color selector is sometimes not attached to the canvas, so we shouldn't disable it in that situation One instance of that is when you select the color wheel type from the settings.

Definition at line 88 of file kis_color_selector.h.

◆ m_inverseSaturation

bool KisColorSelector::m_inverseSaturation
private

Definition at line 148 of file kis_color_selector.h.

◆ m_isDirtyColorPreview

bool KisColorSelector::m_isDirtyColorPreview
private

Definition at line 187 of file kis_color_selector.h.

◆ m_isDirtyGamutMask

bool KisColorSelector::m_isDirtyGamutMask
private

Definition at line 186 of file kis_color_selector.h.

◆ m_isDirtyLightStrip

bool KisColorSelector::m_isDirtyLightStrip
private

Definition at line 185 of file kis_color_selector.h.

◆ m_isDirtyWheel

bool KisColorSelector::m_isDirtyWheel
private

Definition at line 184 of file kis_color_selector.h.

◆ m_lastColorRole

Acs::ColorRole KisColorSelector::m_lastColorRole
private

Definition at line 81 of file kis_color_selector.h.

◆ m_lastRealColor

KoColor KisColorSelector::m_lastRealColor
private

Definition at line 78 of file kis_color_selector.h.

◆ m_lightStripArea

QRect KisColorSelector::m_lightStripArea
private

Definition at line 161 of file kis_color_selector.h.

◆ m_lightStripBuffer

QImage KisColorSelector::m_lightStripBuffer
private

Definition at line 157 of file kis_color_selector.h.

◆ m_lumaB

qreal KisColorSelector::m_lumaB
private

Definition at line 191 of file kis_color_selector.h.

◆ m_lumaG

qreal KisColorSelector::m_lumaG
private

Definition at line 190 of file kis_color_selector.h.

◆ m_lumaGamma

qreal KisColorSelector::m_lumaGamma
private

Definition at line 192 of file kis_color_selector.h.

◆ m_lumaR

qreal KisColorSelector::m_lumaR
private

Definition at line 189 of file kis_color_selector.h.

◆ m_mainComponent

KisColorSelectorComponent* KisColorSelector::m_mainComponent
private

Definition at line 70 of file kis_color_selector.h.

◆ m_maskBuffer

QImage KisColorSelector::m_maskBuffer
private

Definition at line 156 of file kis_color_selector.h.

◆ m_maskPreviewActive

bool KisColorSelector::m_maskPreviewActive
private

Definition at line 179 of file kis_color_selector.h.

◆ m_mouseMoved

bool KisColorSelector::m_mouseMoved
private

Definition at line 162 of file kis_color_selector.h.

◆ m_numLightPieces

quint8 KisColorSelector::m_numLightPieces
private

Definition at line 147 of file kis_color_selector.h.

◆ m_numPieces

quint8 KisColorSelector::m_numPieces
private

Definition at line 146 of file kis_color_selector.h.

◆ m_pressedButtons

Qt::MouseButtons KisColorSelector::m_pressedButtons
private

Definition at line 166 of file kis_color_selector.h.

◆ m_renderArea

QRect KisColorSelector::m_renderArea
private

Definition at line 160 of file kis_color_selector.h.

◆ m_renderBuffer

QImage KisColorSelector::m_renderBuffer
private

Definition at line 155 of file kis_color_selector.h.

◆ m_ring

KisColorSelectorRing* KisColorSelector::m_ring
private

Definition at line 64 of file kis_color_selector.h.

◆ m_selectedColor

KisColor KisColorSelector::m_selectedColor
private

Definition at line 152 of file kis_color_selector.h.

◆ m_selectedLightPiece

qint8 KisColorSelector::m_selectedLightPiece
private

Definition at line 151 of file kis_color_selector.h.

◆ m_selectedPiece

qint8 KisColorSelector::m_selectedPiece
private

Definition at line 150 of file kis_color_selector.h.

◆ m_selectedRing

qint8 KisColorSelector::m_selectedRing
private

Definition at line 149 of file kis_color_selector.h.

◆ m_showBgColor

bool KisColorSelector::m_showBgColor {true}
private

Definition at line 173 of file kis_color_selector.h.

173{true};

◆ m_showValueScaleNumbers

bool KisColorSelector::m_showValueScaleNumbers {false}
private

Definition at line 172 of file kis_color_selector.h.

172{false};

◆ m_signalCompressor

KisSignalCompressor* KisColorSelector::m_signalCompressor
private

Definition at line 74 of file kis_color_selector.h.

◆ m_slider

KisColorSelectorSimple* KisColorSelector::m_slider
private

Definition at line 66 of file kis_color_selector.h.

◆ m_square

KisColorSelectorSimple* KisColorSelector::m_square
private

Definition at line 67 of file kis_color_selector.h.

◆ m_subComponent

KisColorSelectorComponent* KisColorSelector::m_subComponent
private

Definition at line 71 of file kis_color_selector.h.

◆ m_triangle

KisColorSelectorComponent* KisColorSelector::m_triangle
private

Definition at line 65 of file kis_color_selector.h.

◆ m_updateColorCompressor

QScopedPointer<ColorCompressorType> KisColorSelector::m_updateColorCompressor
private

Definition at line 195 of file kis_color_selector.h.

◆ m_wheel

KisColorSelectorWheel* KisColorSelector::m_wheel
private

Definition at line 68 of file kis_color_selector.h.

◆ m_widgetArea

QRect KisColorSelector::m_widgetArea
private

Definition at line 159 of file kis_color_selector.h.

◆ m_widgetUpdatesSelf

bool KisColorSelector::m_widgetUpdatesSelf
private

Definition at line 183 of file kis_color_selector.h.


The documentation for this class was generated from the following files: