Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_color_input.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2008 Cyrille Berger <cberger@cberger.net>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef _KIS_COLOR_INPUT_H_
8#define _KIS_COLOR_INPUT_H_
9
10#include <QWidget>
11#include "KisHsvColorSlider.h"
12
13class KoChannelInfo;
14class KoColor;
15class QWidget;
16class QSpinBox;
17class QDoubleSpinBox;
20class KoColorSlider;
22class QLineEdit;
23class QLabel;
24
26#include "kritawidgets_export.h"
27
28class KRITAWIDGETS_EXPORT KisColorInput : public QWidget
29{
30 Q_OBJECT
31public:
32 KisColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false);
33 inline bool usePercentage() const {
34 return m_usePercentage;
35 }
36 virtual inline void setPercentageWise(bool val) {
37 m_usePercentage = val;
38 }
39
40protected:
41 void init();
42 virtual QWidget* createInput() = 0;
43Q_SIGNALS:
44 void updated();
45protected:
46 const KoChannelInfo* m_channelInfo {nullptr};
47 KoColor* m_color {nullptr};
48 KoColorSlider* m_colorSlider {nullptr};
49 KoColorDisplayRendererInterface *m_displayRenderer {nullptr};
50 bool m_usePercentage {false};
51};
52
53class KRITAWIDGETS_EXPORT KisIntegerColorInput : public KisColorInput
54{
55 Q_OBJECT
56public:
57 KisIntegerColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false);
58protected:
59 QWidget* createInput() override;
60 void updateMaximums();
61 void setPercentageWise(bool val) override;
62public Q_SLOTS:
63 void setValue(int);
64 void update();
65private Q_SLOTS:
66 void onColorSliderChanged(int);
67 void onNumInputChanged(int);
68private:
69 KisIntParseSpinBox* m_intNumInput {nullptr};
70};
71
72
73class KRITAWIDGETS_EXPORT KisFloatColorInput : public KisColorInput
74{
75 Q_OBJECT
76public:
77 KisFloatColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false);
78protected:
79 QWidget* createInput() override;
80public Q_SLOTS:
81 void setValue(double);
82 void sliderChanged(int);
83 void update();
84private:
85 KisDoubleParseSpinBox* m_dblNumInput {nullptr};
86 qreal m_minValue {0.0};
87 qreal m_maxValue {0.0};
88};
89
90class KRITAWIDGETS_EXPORT KisHexColorInput : public KisColorInput
91{
92 Q_OBJECT
93public:
94 KisHexColorInput(QWidget* parent, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false, bool usePreview = false);
95protected:
96 QWidget* createInput() override;
97public Q_SLOTS:
98 void setValue();
99 void textChanged(const QString &text);
100 void update();
101private:
102 QLineEdit* m_hexInput {nullptr};
103 QLabel* m_colorPreview=nullptr;
104};
105
106class KRITAWIDGETS_EXPORT KisHsvColorInput : public QWidget
107{
108 Q_OBJECT
109
110public:
111 KisHsvColorInput(QWidget* parent, KoColor* color);
112
113 void setMixMode(KisHsvColorSlider::MIX_MODE mixMode);
114
115public Q_SLOTS:
116 void setHue(double);
117 void setSaturation(double);
118 void setValue(double);
119
120 void hueSliderChanged(int);
121 void saturationSliderChanged(int);
122 void valueSliderChanged(int);
123
124 void update();
125
126Q_SIGNALS:
127 void updated();
128
129private:
130 void sendUpdate();
131 void recolorSliders();
132 void fillColor(QColor& color);
133 void fillColor(QColor& color, const qreal& h, const qreal& s, const qreal& x);
134 void getHsxF(const QColor& color, qreal* h, qreal* s, qreal* x);
135
137
138 QLabel* m_xLabel;
139
143
147
148 qreal m_h;
149 qreal m_s;
150 qreal m_x;
151
153};
154
155#endif
void setSaturation(TReal &r, TReal &g, TReal &b, TReal sat)
bool usePercentage() const
virtual void setPercentageWise(bool val)
virtual QWidget * createInput()=0
The KisDoubleParseSpinBox class is a cleverer doubleSpinBox, able to parse arithmetic expressions.
KisDoubleParseSpinBox * m_sInput
KisHsvColorSlider * m_xSlider
KisHsvColorSlider::MIX_MODE m_mixMode
KisHsvColorSlider * m_hSlider
KisDoubleParseSpinBox * m_xInput
KisHsvColorSlider * m_sSlider
KisDoubleParseSpinBox * m_hInput
The KisIntParseSpinBox class is a cleverer SpinBox, able to parse arithmetic expressions.
static KoColorDisplayRendererInterface * instance()