2
* Copyright (c) 2010 Adam Celarek <kdedev at xibo dot at>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 2 of the License.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
#ifndef KIS_COLOR_SELECTOR_H
19
#define KIS_COLOR_SELECTOR_H
21
#include "kis_color_selector_base.h"
24
class KisColorSelectorTriangle;
25
class KisColorSelectorRing;
26
class KisColorSelectorComponent;
27
class KisColorSelectorSimple;
28
class KisColorSelectorWheel;
31
class KisColorSelector : public KisColorSelectorBase
35
enum Type {Ring, Square, Wheel, Triangle, Slider};
36
enum Parameters {H, hsvS, V, hslS, L, SL, SV, hsvSH, hslSH, VH, LH};
37
struct Configuration {
40
Parameters mainTypeParameter;
41
Parameters subTypeParameter;
42
Configuration(Type mainT = Triangle,
44
Parameters mainTP = SL,
48
mainTypeParameter(mainTP),
49
subTypeParameter(subTP)
51
Configuration(QString string)
56
QString toString() const
58
return QString("%1|%2|%3|%4").arg(mainType).arg(subType).arg(mainTypeParameter).arg(subTypeParameter);
60
void readString(QString string)
62
QStringList strili = string.split('|');
63
if(strili.length()!=4) return;
65
int imt=strili.at(0).toInt();
66
int ist=strili.at(1).toInt();
67
int imtp=strili.at(2).toInt();
68
int istp=strili.at(3).toInt();
70
if(imt>Slider || ist>Slider || imtp>LH || istp>LH)
75
mainTypeParameter = Parameters(imtp);
76
subTypeParameter = Parameters(istp);
78
static Configuration fromString(QString string)
81
ret.readString(string);
86
// enum MainType {Ring, Square, Wheel};
87
// enum SubType {Triangle, Square, Slider};
88
// enum MainTypeParameter {SL, SV, SH, VH, LH, VSV/*experimental*/};
89
// enum SubTypeParameter {H, S, V, L};
91
KisColorSelector(Configuration conf, QWidget* parent = 0);
92
KisColorSelector(QWidget* parent=0);
93
KisColorSelectorBase* createPopup() const;
95
void setConfiguration(Configuration conf);
96
Configuration configuration() const;
97
void setColor(const QColor& color);
100
void updateSettings();
103
void settingsButtonClicked();
106
void paintEvent(QPaintEvent*);
107
void resizeEvent(QResizeEvent*);
108
void mousePressEvent(QMouseEvent*);
109
void mouseMoveEvent(QMouseEvent*);
110
void mouseReleaseEvent(QMouseEvent*);
111
bool displaySettingsButton();
115
void mouseEvent(QMouseEvent* e);
118
KisColorSelectorRing* m_ring;
119
KisColorSelectorComponent* m_triangle;
120
KisColorSelectorSimple* m_slider;
121
KisColorSelectorSimple* m_square;
122
KisColorSelectorWheel* m_wheel;
123
QPushButton* m_button;
124
KisColorSelectorComponent* m_mainComponent;
125
KisColorSelectorComponent* m_subComponent;
126
KisColorSelectorComponent* m_grabbingComponent;
128
QTimer* m_updateTimer;
130
Configuration m_configuration;
133
QColor m_currentColor;
137
void setDisplayBlip(bool disp) {m_blipDisplay = disp;}
138
bool displayBlip() const {return m_blipDisplay;}
141
#endif // KIS_COLSELNG_COLOR_SELECTOR_H