~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/plugins/extensions/dockers/colorselectorng/kis_color_selector.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-10-27 17:52:57 UTC
  • mfrom: (0.12.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101027175257-s04zqqk5bs8ckm9o
Tags: 1:2.2.83-0ubuntu1
* Merge with Debian git remaining changes:
 - Add build-deps on librcps-dev, opengtl-dev, libqtgtl-dev, freetds-dev,
   create-resources, libspnav-dev
 - Remove needless build-dep on libwv2-dev
 - koffice-libs recommends create-resources
 - krita recommends pstoedit
 - Keep our patches
* New upstream release 2.3 beta 3
  - Remove debian/patches fixed by upstream
  - Update install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (c) 2010 Adam Celarek <kdedev at xibo dot at>
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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.
 
16
 */
 
17
 
 
18
#ifndef KIS_COLOR_SELECTOR_H
 
19
#define KIS_COLOR_SELECTOR_H
 
20
 
 
21
#include "kis_color_selector_base.h"
 
22
 
 
23
#include <QColor>
 
24
class KisColorSelectorTriangle;
 
25
class KisColorSelectorRing;
 
26
class KisColorSelectorComponent;
 
27
class KisColorSelectorSimple;
 
28
class KisColorSelectorWheel;
 
29
class QPushButton;
 
30
 
 
31
class KisColorSelector : public KisColorSelectorBase
 
32
{
 
33
    Q_OBJECT
 
34
public:
 
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 {
 
38
        Type mainType;
 
39
        Type subType;
 
40
        Parameters mainTypeParameter;
 
41
        Parameters subTypeParameter;
 
42
        Configuration(Type mainT = Triangle,
 
43
                              Type subT = Ring,
 
44
                              Parameters mainTP = SL,
 
45
                              Parameters subTP = H)
 
46
                                  : mainType(mainT),
 
47
                                  subType(subT),
 
48
                                  mainTypeParameter(mainTP),
 
49
                                  subTypeParameter(subTP)
 
50
        {}
 
51
        Configuration(QString string)
 
52
        {
 
53
            readString(string);
 
54
        }
 
55
 
 
56
        QString toString() const
 
57
        {
 
58
            return QString("%1|%2|%3|%4").arg(mainType).arg(subType).arg(mainTypeParameter).arg(subTypeParameter);
 
59
        }
 
60
        void readString(QString string)
 
61
        {
 
62
            QStringList strili = string.split('|');
 
63
            if(strili.length()!=4) return;
 
64
 
 
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();
 
69
 
 
70
            if(imt>Slider || ist>Slider || imtp>LH || istp>LH)
 
71
                return;
 
72
 
 
73
            mainType = Type(imt);
 
74
            subType = Type(ist);
 
75
            mainTypeParameter = Parameters(imtp);
 
76
            subTypeParameter = Parameters(istp);
 
77
        }
 
78
        static Configuration fromString(QString string)
 
79
        {
 
80
            Configuration ret;
 
81
            ret.readString(string);
 
82
            return ret;
 
83
        }
 
84
    };
 
85
 
 
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};
 
90
 
 
91
    KisColorSelector(Configuration conf, QWidget* parent = 0);
 
92
    KisColorSelector(QWidget* parent=0);
 
93
    KisColorSelectorBase* createPopup() const;
 
94
 
 
95
    void setConfiguration(Configuration conf);
 
96
    Configuration configuration() const;
 
97
    void setColor(const QColor& color);
 
98
 
 
99
public slots:
 
100
    void updateSettings();
 
101
 
 
102
signals:
 
103
    void settingsButtonClicked();
 
104
 
 
105
protected:
 
106
    void paintEvent(QPaintEvent*);
 
107
    void resizeEvent(QResizeEvent*);
 
108
    void mousePressEvent(QMouseEvent*);
 
109
    void mouseMoveEvent(QMouseEvent*);
 
110
    void mouseReleaseEvent(QMouseEvent*);
 
111
    bool displaySettingsButton();
 
112
 
 
113
 
 
114
private:
 
115
    void mouseEvent(QMouseEvent* e);
 
116
    void init();
 
117
 
 
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;
 
127
 
 
128
    QTimer* m_updateTimer;
 
129
 
 
130
    Configuration m_configuration;
 
131
 
 
132
    QColor m_lastColor;
 
133
    QColor m_currentColor;
 
134
    bool m_blipDisplay;
 
135
 
 
136
public:
 
137
    void setDisplayBlip(bool disp) {m_blipDisplay = disp;}
 
138
    bool displayBlip() const {return m_blipDisplay;}
 
139
};
 
140
 
 
141
#endif // KIS_COLSELNG_COLOR_SELECTOR_H