Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • app
  • src
colorslider.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17#ifndef COLORSLIDER_H
18#define COLORSLIDER_H
19
20#include <QWidget>
21
22
23class ColorSlider : public QWidget
24{
25 Q_OBJECT
26public:
27
28 enum ColorType {
29 HUE,
30 SAT,
31 VAL,
32 RED,
33 GREEN,
34 BLUE,
35 ALPHA
36 };
37 enum ColorSpecType {
38 RGB,
39 HSV,
40 HSL,
41 CMYK
42 };
43
44 explicit ColorSlider(QWidget* parent);
45 ~ColorSlider() override;
46
47 void init(ColorSpecType specType, ColorType type, const QColor &color, qreal min, qreal max);
48
49 QLinearGradient setColorSpec(const QColor &color);
50
51 QColor color() { return mColor; }
52
53 void setHsv(const QColor& hsv) { mColor.setHsv(hsv.hsvHue(),
54 hsv.hsvSaturation(),
55 hsv.value(),
56 hsv.alpha());
57 }
58
59 void setRgb(const QColor& rgb) { mColor.setRgb(rgb.red(),
60 rgb.green(),
61 rgb.blue(),
62 rgb.alpha());
63 }
64
65 void setColorSpecType(ColorSpecType newType) { this->mSpecType = newType; }
66 void setColorType(ColorType newType) { this->mColorType = newType; }
67
68 void setMin(qreal min) { mMin = min; }
69 void setMax(qreal max) { mMax = max; }
70
71 QSize sizeHint() const override;
72
73protected:
74 void paintEvent(QPaintEvent* event) override;
75 void mouseMoveEvent(QMouseEvent* event) override;
76 void mousePressEvent(QMouseEvent* event) override;
77
78signals:
79 void valueChanged(QColor color);
80
81private:
82
83 void drawColorBox(const QColor &color, QSize size);
84 void drawPicker(const QColor &color);
85 QLinearGradient hsvGradient(const QColor &color);
86 QLinearGradient rgbGradient(const QColor &color);
87
88 void colorPicked(QPoint point);
89
90 QPixmap mBoxPixmapSource;
91
92 QColor mColor;
93 qreal mMin = 0.0;
94 qreal mMax = 0.0;
95
96 ColorType mColorType = ColorType::HUE;
97 ColorSpecType mSpecType = ColorSpecType::RGB;
98
99 QLinearGradient mGradient;
100};
101
102#endif // COLORSLIDER_H
ColorSlider
Definition: colorslider.h:24
QColor
QColor::alpha
int alpha() const const
QColor::blue
int blue() const const
QColor::green
int green() const const
QColor::hsvHue
int hsvHue() const const
QColor::hsvSaturation
int hsvSaturation() const const
QColor::red
int red() const const
QColor::setHsv
void setHsv(int h, int s, int v, int a)
QColor::setRgb
void setRgb(int r, int g, int b, int a)
QColor::value
int value() const const
QLinearGradient
QMouseEvent
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QObject::parent
QObject * parent() const const
QPaintEvent
QPixmap
QPoint
QSize
QWidget
QWidget::event
virtual bool event(QEvent *event) override
QWidget::size
size
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39