File indexing completed on 2024-05-12 05:46:53

0001 /*
0002  *  Copyright (c) 2008 Cyrille Berger <cberger@cberger.net>
0003  *
0004  *  This library is free software; you can redistribute it and/or modify
0005  *  it under the terms of the GNU Lesser General Public License as published by
0006  *  the Free Software Foundation; either version 2.1 of the License,
0007  *  or (at your option) any later version.
0008  *
0009  *  This library is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU Lesser General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU Lesser General Public License
0015  *  along with this program; if not, write to the Free Software
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0017  */
0018 
0019 #ifndef _KO_TRIANGLE_COLOR_SELECTOR_H_
0020 #define _KO_TRIANGLE_COLOR_SELECTOR_H_
0021 
0022 #include <QWidget>
0023 
0024 #include "kritawidgets_export.h"
0025 
0026 #include <KisColorSelectorInterface.h>
0027 
0028 class KoColor;
0029 class KoColorDisplayRendererInterface;
0030 
0031 
0032 class KRITAWIDGETS_EXPORT KoTriangleColorSelector : public KisColorSelectorInterface {
0033     Q_OBJECT
0034     public:
0035         explicit KoTriangleColorSelector(QWidget *parent);
0036         explicit KoTriangleColorSelector(const KoColorDisplayRendererInterface *displayRenderer, QWidget *parent);
0037         ~KoTriangleColorSelector() override;
0038     protected: // events
0039         void paintEvent( QPaintEvent * event ) override;
0040         void resizeEvent( QResizeEvent * event ) override;
0041         void mouseReleaseEvent( QMouseEvent * event ) override;
0042         void mousePressEvent( QMouseEvent * event ) override;
0043         void mouseMoveEvent( QMouseEvent * event ) override;
0044     public:
0045         int hue() const;
0046         int value() const;
0047         int saturation() const;
0048         KoColor getCurrentColor() const override;
0049     public Q_SLOTS:
0050         void setHue(int h);
0051         void setValue(int v);
0052         void setSaturation(int s);
0053         void setHSV(int h, int s, int v);
0054         void slotSetColor(const KoColor& ) override;
0055     Q_SIGNALS:
0056         void colorChanged(const QColor& );
0057         void requestCloseContainer();
0058     private Q_SLOTS:
0059         void configurationChanged();
0060     private:
0061         void tellColorChanged();
0062         void generateTriangle();
0063         void generateWheel();
0064         void updateTriangleCircleParameters();
0065         void selectColorAt(int x, int y, bool checkInWheel = true);
0066     private:
0067         struct Private;
0068         Private* const d;
0069 };
0070 
0071 #endif