File indexing completed on 2024-05-12 16:02:00
0001 /* 0002 * SPDX-FileCopyrightText: 2008 Cyrille Berger <cberger@cberger.net> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef _KIS_COLOR_INPUT_H_ 0008 #define _KIS_COLOR_INPUT_H_ 0009 0010 #include <QWidget> 0011 0012 class KoChannelInfo; 0013 class KoColor; 0014 class QWidget; 0015 class QSpinBox; 0016 class QDoubleSpinBox; 0017 class KisIntParseSpinBox; 0018 class KisDoubleParseSpinBox; 0019 class KoColorSlider; 0020 class KisHsvColorSlider; 0021 class QLineEdit; 0022 class QLabel; 0023 0024 #include <KoColorDisplayRendererInterface.h> 0025 #include "kritawidgets_export.h" 0026 0027 class KRITAWIDGETS_EXPORT KisColorInput : public QWidget 0028 { 0029 Q_OBJECT 0030 public: 0031 KisColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false); 0032 inline bool usePercentage() const { 0033 return m_usePercentage; 0034 } 0035 virtual inline void setPercentageWise(bool val) { 0036 m_usePercentage = val; 0037 } 0038 0039 protected: 0040 void init(); 0041 virtual QWidget* createInput() = 0; 0042 Q_SIGNALS: 0043 void updated(); 0044 protected: 0045 const KoChannelInfo* m_channelInfo {nullptr}; 0046 KoColor* m_color {nullptr}; 0047 KoColorSlider* m_colorSlider {nullptr}; 0048 KoColorDisplayRendererInterface *m_displayRenderer {nullptr}; 0049 bool m_usePercentage {false}; 0050 }; 0051 0052 class KRITAWIDGETS_EXPORT KisIntegerColorInput : public KisColorInput 0053 { 0054 Q_OBJECT 0055 public: 0056 KisIntegerColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false); 0057 protected: 0058 QWidget* createInput() override; 0059 void setPercentageWise(bool val) override; 0060 public Q_SLOTS: 0061 void setValue(int); 0062 void update(); 0063 private Q_SLOTS: 0064 void onColorSliderChanged(int); 0065 void onNumInputChanged(int); 0066 private: 0067 KisIntParseSpinBox* m_intNumInput {nullptr}; 0068 }; 0069 0070 0071 class KRITAWIDGETS_EXPORT KisFloatColorInput : public KisColorInput 0072 { 0073 Q_OBJECT 0074 public: 0075 KisFloatColorInput(QWidget* parent, const KoChannelInfo*, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false); 0076 protected: 0077 QWidget* createInput() override; 0078 public Q_SLOTS: 0079 void setValue(double); 0080 void sliderChanged(int); 0081 void update(); 0082 private: 0083 KisDoubleParseSpinBox* m_dblNumInput {nullptr}; 0084 qreal m_minValue {0.0}; 0085 qreal m_maxValue {0.0}; 0086 }; 0087 0088 class KRITAWIDGETS_EXPORT KisHexColorInput : public KisColorInput 0089 { 0090 Q_OBJECT 0091 public: 0092 KisHexColorInput(QWidget* parent, KoColor* color, KoColorDisplayRendererInterface *displayRenderer = KoDumbColorDisplayRenderer::instance(), bool usePercentage = false, bool usePreview = false); 0093 protected: 0094 QWidget* createInput() override; 0095 public Q_SLOTS: 0096 void setValue(); 0097 void update(); 0098 private: 0099 QLineEdit* m_hexInput {nullptr}; 0100 QLabel* m_colorPreview=nullptr; 0101 }; 0102 0103 class KRITAWIDGETS_EXPORT KisHsvColorInput : public QWidget 0104 { 0105 Q_OBJECT 0106 0107 public: 0108 KisHsvColorInput(QWidget* parent, KoColor* color); 0109 0110 public Q_SLOTS: 0111 void setHue(double); 0112 void setSaturation(double); 0113 void setValue(double); 0114 0115 void hueSliderChanged(int); 0116 void saturationSliderChanged(int); 0117 void valueSliderChanged(int); 0118 0119 void update(); 0120 0121 Q_SIGNALS: 0122 void updated(); 0123 0124 private: 0125 void sendUpdate(); 0126 void recolorSliders(); 0127 0128 KoColor* m_color; 0129 0130 KisHsvColorSlider* m_hSlider; 0131 KisHsvColorSlider* m_sSlider; 0132 KisHsvColorSlider* m_vSlider; 0133 0134 KisDoubleParseSpinBox* m_hInput; 0135 KisDoubleParseSpinBox* m_sInput; 0136 KisDoubleParseSpinBox* m_vInput; 0137 0138 qreal m_h; 0139 qreal m_s; 0140 qreal m_v; 0141 }; 0142 0143 #endif