Changeset View
Changeset View
Standalone View
Standalone View
plugins/dockers/specificcolorselector/kis_color_input.cc
Show All 35 Lines | |||||
36 | 36 | | |||
37 | #include <klocalizedstring.h> | 37 | #include <klocalizedstring.h> | ||
38 | 38 | | |||
39 | #include <KoChannelInfo.h> | 39 | #include <KoChannelInfo.h> | ||
40 | #include <KoColor.h> | 40 | #include <KoColor.h> | ||
41 | #include <KoColorSlider.h> | 41 | #include <KoColorSlider.h> | ||
42 | #include <KoColorSpace.h> | 42 | #include <KoColorSpace.h> | ||
43 | 43 | | |||
44 | #include "kis_double_parse_spin_box.h" | ||||
45 | #include "kis_int_parse_spin_box.h" | ||||
46 | | ||||
44 | KisColorInput::KisColorInput(QWidget* parent, const KoChannelInfo* channelInfo, KoColor* color, KoColorDisplayRendererInterface *displayRenderer) : QWidget(parent), m_channelInfo(channelInfo), m_color(color), m_displayRenderer(displayRenderer) | 47 | KisColorInput::KisColorInput(QWidget* parent, const KoChannelInfo* channelInfo, KoColor* color, KoColorDisplayRendererInterface *displayRenderer) : QWidget(parent), m_channelInfo(channelInfo), m_color(color), m_displayRenderer(displayRenderer) | ||
45 | { | 48 | { | ||
46 | } | 49 | } | ||
47 | 50 | | |||
48 | void KisColorInput::init() | 51 | void KisColorInput::init() | ||
49 | { | 52 | { | ||
50 | QHBoxLayout* m_layout = new QHBoxLayout(this); | 53 | QHBoxLayout* m_layout = new QHBoxLayout(this); | ||
51 | m_layout->setContentsMargins(0,0,0,0); | 54 | m_layout->setContentsMargins(0,0,0,0); | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 94 | { | |||
116 | default: | 119 | default: | ||
117 | Q_ASSERT(false); | 120 | Q_ASSERT(false); | ||
118 | } | 121 | } | ||
119 | m_colorSlider->setColors(min, max); | 122 | m_colorSlider->setColors(min, max); | ||
120 | } | 123 | } | ||
121 | 124 | | |||
122 | QWidget* KisIntegerColorInput::createInput() | 125 | QWidget* KisIntegerColorInput::createInput() | ||
123 | { | 126 | { | ||
124 | m_intNumInput = new QSpinBox(this); | 127 | m_intNumInput = new KisIntParseSpinBox(this); | ||
125 | m_intNumInput->setMinimum(0); | 128 | m_intNumInput->setMinimum(0); | ||
126 | m_colorSlider->setMaximum(0); | 129 | m_colorSlider->setMinimum(0); | ||
127 | switch (m_channelInfo->channelValueType()) { | 130 | switch (m_channelInfo->channelValueType()) { | ||
128 | case KoChannelInfo::UINT8: | 131 | case KoChannelInfo::UINT8: | ||
129 | m_intNumInput->setMaximum(0xFF); | 132 | m_intNumInput->setMaximum(0xFF); | ||
130 | m_colorSlider->setMaximum(0xFF); | 133 | m_colorSlider->setMaximum(0xFF); | ||
131 | break; | 134 | break; | ||
132 | case KoChannelInfo::UINT16: | 135 | case KoChannelInfo::UINT16: | ||
133 | m_intNumInput->setMaximum(0xFFFF); | 136 | m_intNumInput->setMaximum(0xFFFF); | ||
134 | m_colorSlider->setMaximum(0xFFFF); | 137 | m_colorSlider->setMaximum(0xFFFF); | ||
Show All 31 Lines | 165 | #endif | |||
166 | default: | 169 | default: | ||
167 | Q_ASSERT(false); | 170 | Q_ASSERT(false); | ||
168 | } | 171 | } | ||
169 | emit(updated()); | 172 | emit(updated()); | ||
170 | } | 173 | } | ||
171 | 174 | | |||
172 | QWidget* KisFloatColorInput::createInput() | 175 | QWidget* KisFloatColorInput::createInput() | ||
173 | { | 176 | { | ||
174 | m_dblNumInput = new QDoubleSpinBox(this); | 177 | m_dblNumInput = new KisDoubleParseSpinBox(this); | ||
175 | m_dblNumInput->setMinimum(0); | 178 | m_dblNumInput->setMinimum(0); | ||
176 | m_dblNumInput->setMaximum(1.0); | 179 | m_dblNumInput->setMaximum(1.0); | ||
177 | connect(m_colorSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged(int))); | 180 | connect(m_colorSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged(int))); | ||
178 | connect(m_dblNumInput, SIGNAL(valueChanged(double)), this, SLOT(setValue(double))); | 181 | connect(m_dblNumInput, SIGNAL(valueChanged(double)), this, SLOT(setValue(double))); | ||
182 | m_dblNumInput->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); | ||||
183 | m_dblNumInput->setMinimumWidth(60); | ||||
184 | m_dblNumInput->setMaximumWidth(60); | ||||
179 | return m_dblNumInput; | 185 | return m_dblNumInput; | ||
180 | } | 186 | } | ||
181 | 187 | | |||
182 | void KisFloatColorInput::sliderChanged(int i) | 188 | void KisFloatColorInput::sliderChanged(int i) | ||
183 | { | 189 | { | ||
184 | const qreal floatRange = m_maxValue - m_minValue; | 190 | const qreal floatRange = m_maxValue - m_minValue; | ||
185 | m_dblNumInput->setValue(m_minValue + (i / 255.0) * floatRange); | 191 | m_dblNumInput->setValue(m_minValue + (i / 255.0) * floatRange); | ||
186 | } | 192 | } | ||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |