File indexing completed on 2024-05-12 16:02:05

0001 /*
0002  * SPDX-FileCopyrightText: 2016 Wolthera van Hovell tot Westerflier <griffinvalley@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 #ifndef KIS_VISUAL_COLOR_SELECTOR_H
0007 #define KIS_VISUAL_COLOR_SELECTOR_H
0008 
0009 #include <QWidget>
0010 #include <QScopedPointer>
0011 
0012 #include <KoColor.h>
0013 
0014 #include "KisColorSelectorConfiguration.h"
0015 #include "KisColorSelectorInterface.h"
0016 #include "kritawidgets_export.h"
0017 
0018 class KoColorSpace;
0019 class KoColorDisplayRendererInterface;
0020 
0021 /**
0022  * @brief The KisVisualColorSelector class
0023  *
0024  * This gives a color selector box that draws gradients and everything.
0025  *
0026  * Unlike other color selectors, this one draws the full gamut of the given
0027  * colorspace.
0028  */
0029 class KRITAWIDGETS_EXPORT KisVisualColorSelector : public KisColorSelectorInterface
0030 {
0031     Q_OBJECT
0032 public:
0033     enum ColorModel { None, Channel, HSV, HSL, HSI, HSY, YUV };
0034 
0035     explicit KisVisualColorSelector(QWidget *parent = 0);
0036     ~KisVisualColorSelector() override;
0037 
0038     /**
0039      * @brief setConfig
0040      * @param forceCircular
0041      * Force circular is for space where you only have room for a circular selector.
0042      * @param forceSelfUpdate
0043      * ignored, can possibly be removed from parent class now
0044      */
0045     void setConfig(bool forceCircular, bool forceSelfUpdate) override;
0046     void setAcceptTabletEvents(bool on);
0047     KoColor getCurrentColor() const override;
0048     QVector4D getChannelValues() const;
0049     ColorModel getColorModel() const;
0050     bool isHSXModel() const;
0051     KoColor convertShapeCoordsToKoColor(const QVector4D &coordinates) const;
0052     QVector4D convertKoColorToShapeCoordinates(KoColor c) const;
0053 
0054 public Q_SLOTS:
0055 
0056     void slotSetColor(const KoColor &c) override;
0057     void slotSetColorSpace(const KoColorSpace *cs) override;
0058     void slotSetHSX(const QVector3D &hsx);
0059     void configurationChanged();
0060     void setDisplayRenderer (const KoColorDisplayRendererInterface *displayRenderer) override;
0061 
0062 private Q_SLOTS:
0063     void slotCursorMoved(QPointF pos);
0064     void slotDisplayConfigurationChanged();
0065     void slotRebuildSelectors();
0066 
0067 Q_SIGNALS:
0068     /**
0069      * @brief sigColorModelChanged is emitted whenever the selector's color model changes.
0070      *
0071      * This is mostly relevant for configuration changes where the same RGB model
0072      * gets represented in a different way like HSV, HSL etc. so the values of
0073      * sigHSXChanged() change meaning.
0074      *
0075      * @see getColorModel()
0076      */
0077     void sigColorModelChanged();
0078     void sigHSXChanged(const QVector3D &hsx);
0079 
0080 protected:
0081     void resizeEvent(QResizeEvent *) override;
0082 
0083 private:
0084     struct Private;
0085     const QScopedPointer<Private> m_d;
0086 
0087 };
0088 
0089 #endif