Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Added Bayer dithering option to Gradient Generator

Jakub Nowakowskib6eb00f2a804
diff --git a/libs/image/kis_gradient_painter.cc b/libs/image/kis_gradient_painter.cc
index d9fb0b6b04..8d1e567c05 100644
--- a/libs/image/kis_gradient_painter.cc
+++ b/libs/image/kis_gradient_painter.cc
@@ -409,17 +409,17 @@ class DitheredGradientStrategy : public KisGradientShapeStrategy
{
public:
- DitheredGradientStrategy(KisGradientPainter::enumDither dither, int ditherSteps, QSharedPointer<KisGradientShapeStrategy> shapeStrategy);
+ DitheredGradientStrategy(KisGradientPainter::enumGradientDither dither, int ditherSteps, QSharedPointer<KisGradientShapeStrategy> shapeStrategy);
double valueAt(double x, double y) const override;
protected:
- KisGradientPainter::enumDither m_dither;
+ KisGradientPainter::enumGradientDither m_dither;
int m_ditherSteps;
QSharedPointer<KisGradientShapeStrategy> m_shapeStrategy;
};
-DitheredGradientStrategy::DitheredGradientStrategy(KisGradientPainter::enumDither dither,
+DitheredGradientStrategy::DitheredGradientStrategy(KisGradientPainter::enumGradientDither dither,
int ditherSteps,
QSharedPointer<KisGradientShapeStrategy> shapeStrategy)
: m_dither(dither)
@@ -434,13 +434,13 @@ double DitheredGradientStrategy::valueAt(double x, double y) const
double ditherFactor = 0.0;
switch (m_dither) {
- case KisGradientPainter::DitherBayer2:
+ case KisGradientPainter::GradientDitherBayer2:
ditherFactor = KisDitherMaths::dither_factor_bayer_2_normalized(x, y);
break;
- case KisGradientPainter::DitherBayer4:
+ case KisGradientPainter::GradientDitherBayer4:
ditherFactor = KisDitherMaths::dither_factor_bayer_4_normalized(x, y);
break;
- case KisGradientPainter::DitherBayer8:
+ case KisGradientPainter::GradientDitherBayer8:
ditherFactor = KisDitherMaths::dither_factor_bayer_8_normalized(x, y);
break;
default:
@@ -1148,7 +1148,7 @@ bool KisGradientPainter::paintGradient(const QPointF& gradientVectorStart,
qint32 starty,
qint32 width,
qint32 height,
- enumDither dither,
+ enumGradientDither dither,
int ditherSteps)
{
return paintGradient(gradientVectorStart,
@@ -1167,7 +1167,7 @@ bool KisGradientPainter::paintGradient(const QPointF& gradientVectorStart,
double antiAliasThreshold,
bool reverseGradient,
const QRect &applyRect,
- enumDither dither,
+ enumGradientDither dither,
int ditherSteps)
{
// The following combinations of options have aliasing artifacts
@@ -1237,7 +1237,7 @@ bool KisGradientPainter::paintGradient(const QPointF& gradientVectorStart,
enumGradientRepeat repeat,
double antiAliasThreshold,
bool reverseGradient,
- enumDither dither,
+ enumGradientDither dither,
int ditherSteps,
const QRect &applyRect,
T & paintPolicy)
@@ -1358,7 +1358,7 @@ bool KisGradientPainter::paintGradient(const QPointF& gradientVectorStart,
tmp->setDefaultBounds(dev->defaultBounds());
tmp->clear();
- const KisDitherOp* op = mixCs->ditherOp(destCs->colorDepthId().id(), dither == DitherBlueNoise ? DITHER_BEST : DITHER_NONE);
+ const KisDitherOp* op = mixCs->ditherOp(destCs->colorDepthId().id(), dither == GradientDitherBlueNoise ? DITHER_BEST : DITHER_NONE);
Q_FOREACH (const Private::ProcessRegion &r, m_d->processRegions) {
QRect processRect = r.processRect;
@@ -1411,9 +1411,9 @@ bool KisGradientPainter::paintGradient(const QPointF& gradientVectorStart,
return true;
}
-bool KisGradientPainter::isBayerDither(enumDither dither)
+bool KisGradientPainter::isBayerDither(enumGradientDither dither)
{
- return dither == KisGradientPainter::DitherBayer2 ||
- dither == KisGradientPainter::DitherBayer4 ||
- dither == KisGradientPainter::DitherBayer8;
+ return dither == KisGradientPainter::GradientDitherBayer2 ||
+ dither == KisGradientPainter::GradientDitherBayer4 ||
+ dither == KisGradientPainter::GradientDitherBayer8;
}
diff --git a/libs/image/kis_gradient_painter.h b/libs/image/kis_gradient_painter.h
index 038c97a3e7..d1b7bea464 100644
--- a/libs/image/kis_gradient_painter.h
+++ b/libs/image/kis_gradient_painter.h
@@ -49,14 +49,16 @@ public:
GradientRepeatAlternate
};
- enum enumDither {
- DitherNone,
- DitherBlueNoise,
- DitherBayer2,
- DitherBayer4,
- DitherBayer8
+ enum enumGradientDither {
+ GradientDitherNone,
+ GradientDitherBlueNoise,
+ GradientDitherBayer2,
+ GradientDitherBayer4,
+ GradientDitherBayer8
};
+ static constexpr int minDitherSteps = 2;
+ static constexpr int maxDitherSteps = 10000;
static constexpr int defaultDitherSteps = 2;
void setGradientShape(enumGradientShape shape);
@@ -75,7 +77,7 @@ public:
qint32 starty,
qint32 width,
qint32 height,
- enumDither dither = DitherNone,
+ enumGradientDither dither = GradientDitherNone,
int ditherSteps = defaultDitherSteps);
// convenience overload
@@ -85,7 +87,7 @@ public:
double antiAliasThreshold,
bool reverseGradient,
const QRect &applyRect,
- enumDither dither = DitherNone,
+ enumGradientDither dither = GradientDitherNone,
int ditherSteps = defaultDitherSteps);
template <class T>
@@ -94,12 +96,12 @@ public:
enumGradientRepeat repeat,
double antiAliasThreshold,
bool reverseGradient,
- enumDither dither,
+ enumGradientDither dither,
int ditherSteps,
const QRect &applyRect,
T & paintPolicy);
- static bool isBayerDither(enumDither dither);
+ static bool isBayerDither(enumGradientDither dither);
private:
struct Private;
diff --git a/libs/image/layerstyles/kis_ls_utils.cpp b/libs/image/layerstyles/kis_ls_utils.cpp
index 3a454e6215..9eefaafded 100644
--- a/libs/image/layerstyles/kis_ls_utils.cpp
+++ b/libs/image/layerstyles/kis_ls_utils.cpp
@@ -531,7 +531,7 @@ namespace KisLsUtils
repeat, 0.0,
config->reverse(),
applyRect,
- config->dither() ? KisGradientPainter::DitherBlueNoise : KisGradientPainter::DitherNone);
+ config->dither() ? KisGradientPainter::GradientDitherBlueNoise : KisGradientPainter::GradientDitherNone);
}
}
diff --git a/libs/ui/widgets/kis_scratch_pad.cpp b/libs/ui/widgets/kis_scratch_pad.cpp
index bc6cf71490..bf4f664edf 100644
--- a/libs/ui/widgets/kis_scratch_pad.cpp
+++ b/libs/ui/widgets/kis_scratch_pad.cpp
@@ -1063,7 +1063,7 @@ void KisScratchPad::fillGradient(const QPoint &gradientVectorStart,
reverseGradient,
gradientRect.left(), gradientRect.top(),
gradientRect.width(), gradientRect.height(),
- dither ? KisGradientPainter::DitherBlueNoise : KisGradientPainter::DitherNone);
+ dither ? KisGradientPainter::GradientDitherBlueNoise : KisGradientPainter::GradientDitherNone);
} else {
painter.paintGradient(gradientVectorStart,
gradientVectorEnd,
@@ -1072,7 +1072,7 @@ void KisScratchPad::fillGradient(const QPoint &gradientVectorStart,
reverseGradient,
gradientRect.left(), gradientRect.top(),
gradientRect.width(), gradientRect.height(),
- dither ? KisGradientPainter::DitherBlueNoise : KisGradientPainter::DitherNone);
+ dither ? KisGradientPainter::GradientDitherBlueNoise : KisGradientPainter::GradientDitherNone);
}
t.end();
}
diff --git a/plugins/generators/gradient/KisGradientGenerator.cpp b/plugins/generators/gradient/KisGradientGenerator.cpp
index 741b7b7399..c69b0b5fc9 100644
--- a/plugins/generators/gradient/KisGradientGenerator.cpp
+++ b/plugins/generators/gradient/KisGradientGenerator.cpp
@@ -52,7 +52,8 @@ void KisGradientGenerator::generate(KisProcessingInformation dst,
generatorConfiguration->antiAliasThreshold(),
generatorConfiguration->reverse(),
QRect(dst.topLeft(), size),
- generatorConfiguration->dither() ? KisGradientPainter::DitherBlueNoise : KisGradientPainter::DitherNone
+ generatorConfiguration->dither(),
+ generatorConfiguration->ditherSteps()
);
}
diff --git a/plugins/generators/gradient/KisGradientGeneratorConfigWidget.cpp b/plugins/generators/gradient/KisGradientGeneratorConfigWidget.cpp
index 713164a584..ddd1d90f49 100644
--- a/plugins/generators/gradient/KisGradientGeneratorConfigWidget.cpp
+++ b/plugins/generators/gradient/KisGradientGeneratorConfigWidget.cpp
@@ -39,6 +39,13 @@ KisGradientGeneratorConfigWidget::KisGradientGeneratorConfigWidget(QWidget* pare
<< i18nc("The gradient will not repeat", "None")
<< i18nc("The gradient will repeat forwards", "Forwards")
<< i18nc("The gradient will repeat alternatingly", "Alternating");
+ QStringList ditherNames =
+ QStringList()
+ << i18nc("The gradient will not be dithered", "None")
+ << i18nc("The gradient will be dithered with Blue Noise", "Blue Noise")
+ << i18nc("The gradient will be dithered with Bayer Matrix 2x2", "Bayer Matrix 2x2")
+ << i18nc("The gradient will be dithered with Bayer Matrix 4x4", "Bayer Matrix 4x4")
+ << i18nc("The gradient will be dithered with Bayer Matrix 8x8", "Bayer Matrix 8x8");
QStringList spatialUnitsNames =
QStringList()
<< i18nc("The position will be set in pixels", "Pixels")
@@ -55,6 +62,8 @@ KisGradientGeneratorConfigWidget::KisGradientGeneratorConfigWidget(QWidget* pare
m_ui.comboBoxShape->addItems(shapeNames);
m_ui.comboBoxRepeat->addItems(repeatNames);
+ m_ui.comboBoxDither->addItems(ditherNames);
+ m_ui.spinBoxDitherSteps->setRange(KisGradientPainter::minDitherSteps, KisGradientPainter::maxDitherSteps);
m_ui.sliderAntiAliasThreshold->setRange(0, 1, 3);
m_ui.comboBoxStartPositionXUnits->addItems(spatialUnitsNames);
@@ -70,8 +79,9 @@ KisGradientGeneratorConfigWidget::KisGradientGeneratorConfigWidget(QWidget* pare
connect(m_ui.comboBoxShape, SIGNAL(currentIndexChanged(int)), this, SIGNAL(sigConfigurationUpdated()));
connect(m_ui.comboBoxRepeat, SIGNAL(currentIndexChanged(int)), this, SIGNAL(sigConfigurationUpdated()));
+ connect(m_ui.comboBoxDither, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_comboBoxDither_currentIndexChanged(int)));
+ connect(m_ui.spinBoxDitherSteps, SIGNAL(valueChanged(int)), this, SIGNAL(sigConfigurationUpdated()));
connect(m_ui.sliderAntiAliasThreshold, SIGNAL(valueChanged(qreal)), this, SIGNAL(sigConfigurationUpdated()));
- connect(m_ui.checkBoxDither, SIGNAL(toggled(bool)), this, SIGNAL(sigConfigurationUpdated()));
connect(m_ui.checkBoxReverse, SIGNAL(toggled(bool)), this, SIGNAL(sigConfigurationUpdated()));
connect(m_ui.spinBoxStartPositionX, SIGNAL(valueChanged(double)), this, SIGNAL(sigConfigurationUpdated()));
@@ -120,8 +130,10 @@ void KisGradientGeneratorConfigWidget::setConfiguration(const KisPropertiesConfi
m_ui.comboBoxShape->setCurrentIndex(generatorConfig->shape());
m_ui.comboBoxRepeat->setCurrentIndex(generatorConfig->repeat());
+ m_ui.comboBoxDither->setCurrentIndex(generatorConfig->dither());
+ slot_comboBoxDither_currentIndexChanged(generatorConfig->dither());
+ m_ui.spinBoxDitherSteps->setValue(generatorConfig->ditherSteps());
m_ui.sliderAntiAliasThreshold->setValue(generatorConfig->antiAliasThreshold());
- m_ui.checkBoxDither->setChecked(generatorConfig->dither());
m_ui.checkBoxReverse->setChecked(generatorConfig->reverse());
m_ui.spinBoxStartPositionX->setValue(generatorConfig->startPositionX());
@@ -166,8 +178,9 @@ KisPropertiesConfigurationSP KisGradientGeneratorConfigWidget::configuration() c
config->setShape(static_cast<KisGradientPainter::enumGradientShape>(m_ui.comboBoxShape->currentIndex()));
config->setRepeat(static_cast<KisGradientPainter::enumGradientRepeat>(m_ui.comboBoxRepeat->currentIndex()));
+ config->setDither(static_cast<KisGradientPainter::enumGradientDither>(m_ui.comboBoxDither->currentIndex()));
+ config->setDitherSteps(m_ui.spinBoxDitherSteps->value());
config->setAntiAliasThreshold(m_ui.sliderAntiAliasThreshold->value());
- config->setDither(m_ui.checkBoxDither->isChecked());
config->setReverse(m_ui.checkBoxReverse->isChecked());
config->setStartPositionX(m_ui.spinBoxStartPositionX->value());
@@ -233,3 +246,12 @@ void KisGradientGeneratorConfigWidget::slot_radioButtonEndPositionPolarCoordinat
m_ui.stackedWidgetEndPosition->setCurrentIndex(1);
Q_EMIT sigConfigurationItemChanged();
}
+
+void KisGradientGeneratorConfigWidget::slot_comboBoxDither_currentIndexChanged(int dither)
+{
+ bool ditherStepsVisible = KisGradientPainter::isBayerDither(static_cast<KisGradientPainter::enumGradientDither>(dither));
+ m_ui.spinBoxDitherSteps->setVisible(ditherStepsVisible);
+ m_ui.formLayout->labelForField(m_ui.spinBoxDitherSteps)->setVisible(ditherStepsVisible);
+
+ Q_EMIT sigConfigurationItemChanged();
+}
\ No newline at end of file
diff --git a/plugins/generators/gradient/KisGradientGeneratorConfigWidget.h b/plugins/generators/gradient/KisGradientGeneratorConfigWidget.h
index 0f09b1ba8c..64eb383966 100644
--- a/plugins/generators/gradient/KisGradientGeneratorConfigWidget.h
+++ b/plugins/generators/gradient/KisGradientGeneratorConfigWidget.h
@@ -36,7 +36,7 @@ private:
private Q_SLOTS:
void slot_radioButtonEndPositionCartesianCoordinates_toggled(bool enabled);
void slot_radioButtonEndPositionPolarCoordinates_toggled(bool enabled);
-
+ void slot_comboBoxDither_currentIndexChanged(int dither);
};
#endif
diff --git a/plugins/generators/gradient/KisGradientGeneratorConfigWidget.ui b/plugins/generators/gradient/KisGradientGeneratorConfigWidget.ui
index 955966e71a..69c9313a1b 100644
--- a/plugins/generators/gradient/KisGradientGeneratorConfigWidget.ui
+++ b/plugins/generators/gradient/KisGradientGeneratorConfigWidget.ui
@@ -96,42 +96,52 @@
<widget class="QComboBox" name="comboBoxRepeat"/>
</item>
<item row="2" column="0">
- <widget class="QLabel" name="labelAntiAliasThreshold">
+ <widget class="QLabel" name="labelDither">
<property name="text">
- <string>Anti-alias threshold:</string>
+ <string>Dither:</string>
</property>
</widget>
</item>
<item row="2" column="1">
- <widget class="KisDoubleSliderSpinBox" name="sliderAntiAliasThreshold" native="true">
- <property name="focusPolicy">
- <enum>Qt::WheelFocus</enum>
- </property>
- </widget>
+ <widget class="QComboBox" name="comboBoxDither"/>
</item>
<item row="3" column="0">
- <widget class="QLabel" name="labelReverse">
+ <widget class="QLabel" name="labelDitherSteps">
<property name="text">
- <string>Reverse:</string>
+ <string>Dither steps:</string>
</property>
</widget>
</item>
<item row="3" column="1">
- <widget class="QCheckBox" name="checkBoxReverse">
- <property name="text">
- <string/>
+ <widget class="QSpinBox" name="spinBoxDitherSteps">
+ <property name="focusPolicy">
+ <enum>Qt::WheelFocus</enum>
</property>
</widget>
</item>
<item row="4" column="0">
- <widget class="QLabel" name="labelDither">
+ <widget class="QLabel" name="labelAntiAliasThreshold">
<property name="text">
- <string>Dithering:</string>
+ <string>Anti-alias threshold:</string>
</property>
</widget>
</item>
<item row="4" column="1">
- <widget class="QCheckBox" name="checkBoxDither">
+ <widget class="KisDoubleSliderSpinBox" name="sliderAntiAliasThreshold" native="true">
+ <property name="focusPolicy">
+ <enum>Qt::WheelFocus</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="labelReverse">
+ <property name="text">
+ <string>Reverse:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QCheckBox" name="checkBoxReverse">
<property name="text">
<string/>
</property>
diff --git a/plugins/generators/gradient/KisGradientGeneratorConfiguration.cpp b/plugins/generators/gradient/KisGradientGeneratorConfiguration.cpp
index 7712367fcf..dbb01bb64d 100644
--- a/plugins/generators/gradient/KisGradientGeneratorConfiguration.cpp
+++ b/plugins/generators/gradient/KisGradientGeneratorConfiguration.cpp
@@ -42,6 +42,16 @@ KisGradientPainter::enumGradientRepeat KisGradientGeneratorConfiguration::repeat
return stringToRepeat(getString("repeat"), defaultRepeat());
}
+KisGradientPainter::enumGradientDither KisGradientGeneratorConfiguration::dither() const
+{
+ return stringToDither(getString("dither"), defaultDither());
+}
+
+int KisGradientGeneratorConfiguration::ditherSteps() const
+{
+ return getInt("dither_steps", defaultDitherSteps());
+}
+
qreal KisGradientGeneratorConfiguration::antiAliasThreshold() const
{
return getDouble("antialias_threshold", defaultAntiAliasThreshold());
@@ -52,11 +62,6 @@ bool KisGradientGeneratorConfiguration::reverse() const
return getBool("reverse", defaultReverse());
}
-bool KisGradientGeneratorConfiguration::dither() const
-{
- return getBool("dither", defaultDither());
-}
-
qreal KisGradientGeneratorConfiguration::startPositionX() const
{
return getDouble("start_position_x", defaultStartPositionX());
@@ -188,14 +193,19 @@ void KisGradientGeneratorConfiguration::setRepeat(KisGradientPainter::enumGradie
setProperty("repeat", repeatToString(newRepeat));
}
-void KisGradientGeneratorConfiguration::setAntiAliasThreshold(qreal newAntiAliasThreshold)
+void KisGradientGeneratorConfiguration::setDither(KisGradientPainter::enumGradientDither newDither)
{
- setProperty("antialias_threshold", newAntiAliasThreshold);
+ setProperty("dither", ditherToString(newDither));
+}
+
+void KisGradientGeneratorConfiguration::setDitherSteps(int newDitherSteps)
+{
+ setProperty("dither_steps", newDitherSteps);
}
-void KisGradientGeneratorConfiguration::setDither(bool newDither)
+void KisGradientGeneratorConfiguration::setAntiAliasThreshold(qreal newAntiAliasThreshold)
{
- setProperty("dither", newDither);
+ setProperty("antialias_threshold", newAntiAliasThreshold);
}
void KisGradientGeneratorConfiguration::setReverse(bool newReverse)
@@ -300,6 +310,8 @@ void KisGradientGeneratorConfiguration::setDefaults()
{
setShape(defaultShape());
setRepeat(defaultRepeat());
+ setDither(defaultDither());
+ setDitherSteps(defaultDitherSteps());
setAntiAliasThreshold(defaultAntiAliasThreshold());
setReverse(defaultReverse());
setStartPositionX(defaultStartPositionX());
diff --git a/plugins/generators/gradient/KisGradientGeneratorConfiguration.h b/plugins/generators/gradient/KisGradientGeneratorConfiguration.h
index d25e625bb0..9905e8e787 100644
--- a/plugins/generators/gradient/KisGradientGeneratorConfiguration.h
+++ b/plugins/generators/gradient/KisGradientGeneratorConfiguration.h
@@ -77,14 +77,19 @@ public:
return KisGradientPainter::GradientRepeatNone;
}
- static constexpr qreal defaultAntiAliasThreshold()
+ static constexpr KisGradientPainter::enumGradientDither defaultDither()
{
- return 0.0;
+ return KisGradientPainter::GradientDitherNone;
}
- static constexpr bool defaultDither()
+ static constexpr int defaultDitherSteps()
{
- return false;
+ return KisGradientPainter::defaultDitherSteps;
+ }
+
+ static constexpr qreal defaultAntiAliasThreshold()
+ {
+ return 0.0;
}
static constexpr bool defaultReverse()
@@ -177,8 +182,9 @@ public:
KisGradientPainter::enumGradientShape shape() const;
KisGradientPainter::enumGradientRepeat repeat() const;
+ KisGradientPainter::enumGradientDither dither() const;
+ int ditherSteps() const;
qreal antiAliasThreshold() const;
- bool dither() const;
bool reverse() const;
qreal startPositionX() const;
qreal startPositionY() const;
@@ -200,8 +206,9 @@ public:
void setShape(KisGradientPainter::enumGradientShape newShape);
void setRepeat(KisGradientPainter::enumGradientRepeat newRepeat);
+ void setDither(KisGradientPainter::enumGradientDither newDither);
+ void setDitherSteps(int newDitherSteps);
void setAntiAliasThreshold(qreal newAntiAliasThreshold);
- void setDither(bool newDither);
void setReverse(bool newReverse);
void setStartPositionX(qreal newStartPositionX);
void setStartPositionY(qreal newStartPositionY);
@@ -296,6 +303,40 @@ public:
return defaultRepeat;
}
+ static inline QString ditherToString(KisGradientPainter::enumGradientDither dither,
+ const QString & defaultDitherString = QString())
+ {
+ if (dither == KisGradientPainter::GradientDitherNone) {
+ return "none";
+ } else if (dither == KisGradientPainter::GradientDitherBlueNoise) {
+ return "blue_noise";
+ } else if (dither == KisGradientPainter::GradientDitherBayer2) {
+ return "bayer2";
+ } else if (dither == KisGradientPainter::GradientDitherBayer4) {
+ return "bayer4";
+ } else if (dither == KisGradientPainter::GradientDitherBayer8) {
+ return "bayer8";
+ }
+ return defaultDitherString;
+ }
+
+ static inline KisGradientPainter::enumGradientDither stringToDither(QString const & ditherString,
+ KisGradientPainter::enumGradientDither defaultDither = KisGradientPainter::GradientDitherNone)
+ {
+ if (ditherString == "none") {
+ return KisGradientPainter::GradientDitherNone;
+ } else if (ditherString == "blue_noise") {
+ return KisGradientPainter::GradientDitherBlueNoise;
+ } else if (ditherString == "bayer2") {
+ return KisGradientPainter::GradientDitherBayer2;
+ } else if (ditherString == "bayer4") {
+ return KisGradientPainter::GradientDitherBayer4;
+ } else if (ditherString == "bayer8") {
+ return KisGradientPainter::GradientDitherBayer8;
+ }
+ return defaultDither;
+ }
+
static inline QString coordinateSystemToString(CoordinateSystem coordinateSystem,
const QString &defaultCoordinateSystemString = QString())
{
diff --git a/plugins/tools/basictools/kis_tool_gradient.cc b/plugins/tools/basictools/kis_tool_gradient.cc
index e77ad1114a..ca6378fc83 100644
--- a/plugins/tools/basictools/kis_tool_gradient.cc
+++ b/plugins/tools/basictools/kis_tool_gradient.cc
@@ -58,7 +58,7 @@ KisToolGradient::KisToolGradient(KoCanvasBase * canvas)
m_startPos = QPointF(0, 0);
m_endPos = QPointF(0, 0);
- m_dither = KisGradientPainter::DitherNone;
+ m_dither = KisGradientPainter::GradientDitherNone;
m_ditherSteps = KisGradientPainter::defaultDitherSteps;
m_reverse = false;
m_shape = KisGradientPainter::GradientShapeLinear;
@@ -278,7 +278,7 @@ QWidget* KisToolGradient::createOptionWidget()
m_lbDitherSteps = new QLabel(i18n("Dither steps:"), widget);
m_sbDitherSteps = new KisIntParseSpinBox(widget);
m_sbDitherSteps->setObjectName("dither_steps");
- m_sbDitherSteps->setRange(2, 10000);
+ m_sbDitherSteps->setRange(KisGradientPainter::minDitherSteps, KisGradientPainter::maxDitherSteps);
addOptionWidgetOption(m_sbDitherSteps, m_lbDitherSteps);
connect(m_sbDitherSteps, SIGNAL(valueChanged(int)), this, SLOT(slotSetDitherSteps(int)));
@@ -331,7 +331,7 @@ void KisToolGradient::slotSetDither(int dither)
m_cmbDither->setCurrentIndex(dither);
}
- m_dither = static_cast<KisGradientPainter::enumDither>(dither);
+ m_dither = static_cast<KisGradientPainter::enumGradientDither>(dither);
m_configGroup.writeEntry("dither", dither);
showControl(m_sbDitherSteps, KisGradientPainter::isBayerDither(m_dither));
diff --git a/plugins/tools/basictools/kis_tool_gradient.h b/plugins/tools/basictools/kis_tool_gradient.h
index d2210ad545..e2061d602f 100644
--- a/plugins/tools/basictools/kis_tool_gradient.h
+++ b/plugins/tools/basictools/kis_tool_gradient.h
@@ -84,7 +84,7 @@ private:
KisGradientPainter::enumGradientShape m_shape;
KisGradientPainter::enumGradientRepeat m_repeat;
- KisGradientPainter::enumDither m_dither {KisGradientPainter::DitherNone};
+ KisGradientPainter::enumGradientDither m_dither {KisGradientPainter::GradientDitherNone};
int m_ditherSteps {KisGradientPainter::defaultDitherSteps};
bool m_reverse {false};
double m_antiAliasThreshold {0.0};