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++

Let the smoothness of the brush be affected by speed

killy |0veufOrever2cd216e52861
diff --git a/krita/data/aboutdata/developers.txt b/krita/data/aboutdata/developers.txt
index f3a0e79750..454dbec972 100644
--- a/krita/data/aboutdata/developers.txt
+++ b/krita/data/aboutdata/developers.txt
@@ -109,6 +109,7 @@ Kai-Uwe Behrmann
Karl Ove Hufthammer
Kevin Krammer
Kevin Ottens
+Killyorz
Kurt Pfeifle
Laurent Montel
Lauri Watts
diff --git a/libs/ui/kis_config.cc b/libs/ui/kis_config.cc
index dd51552db2..7c5303e095 100644
--- a/libs/ui/kis_config.cc
+++ b/libs/ui/kis_config.cc
@@ -1894,14 +1894,34 @@ void KisConfig::setLineSmoothingType(int value)
m_cfg.writeEntry("LineSmoothingType", value);
}
-qreal KisConfig::lineSmoothingDistance(bool defaultValue) const
+qreal KisConfig::lineSmoothingDistanceMin(bool defaultValue) const
{
- return (defaultValue ? 50.0 : m_cfg.readEntry("LineSmoothingDistance", 50.0));
+ return (defaultValue ? 50.0 : m_cfg.readEntry("LineSmoothingDistanceMin", 50.0));
}
-void KisConfig::setLineSmoothingDistance(qreal value)
+void KisConfig::setLineSmoothingDistanceMin(qreal value)
{
- m_cfg.writeEntry("LineSmoothingDistance", value);
+ m_cfg.writeEntry("LineSmoothingDistanceMin", value);
+}
+
+qreal KisConfig::lineSmoothingDistanceMax(bool defaultValue) const
+{
+ return (defaultValue ? 50.0 : m_cfg.readEntry("LineSmoothingDistanceMax", 50.0));
+}
+
+void KisConfig::setLineSmoothingDistanceMax(qreal value)
+{
+ m_cfg.writeEntry("LineSmoothingDistanceMax", value);
+}
+
+bool KisConfig::lineSmoothingDistanceKeepAspectRatio(bool defaultValue) const
+{
+ return (defaultValue ? true : m_cfg.readEntry("LineSmoothingDistanceKeepAspectRatio", true));
+}
+
+void KisConfig::setLineSmoothingDistanceKeepAspectRatio(bool value)
+{
+ m_cfg.writeEntry("LineSmoothingDistanceKeepAspectRatio", value);
}
qreal KisConfig::lineSmoothingTailAggressiveness(bool defaultValue) const
diff --git a/libs/ui/kis_config.h b/libs/ui/kis_config.h
index 6def72ae01..8fbd8fe617 100644
--- a/libs/ui/kis_config.h
+++ b/libs/ui/kis_config.h
@@ -491,8 +491,14 @@ public:
int lineSmoothingType(bool defaultValue = false) const;
void setLineSmoothingType(int value);
- qreal lineSmoothingDistance(bool defaultValue = false) const;
- void setLineSmoothingDistance(qreal value);
+ qreal lineSmoothingDistanceMin(bool defaultValue = false) const;
+ void setLineSmoothingDistanceMin(qreal value);
+
+ qreal lineSmoothingDistanceMax(bool defaultValue = false) const;
+ void setLineSmoothingDistanceMax(qreal value);
+
+ bool lineSmoothingDistanceKeepAspectRatio(bool defaultValue = false) const;
+ void setLineSmoothingDistanceKeepAspectRatio(bool value);
qreal lineSmoothingTailAggressiveness(bool defaultValue = false) const;
void setLineSmoothingTailAggressiveness(qreal value);
diff --git a/libs/ui/tool/kis_smoothing_options.cpp b/libs/ui/tool/kis_smoothing_options.cpp
index e586df512a..0c49a9b21b 100644
--- a/libs/ui/tool/kis_smoothing_options.cpp
+++ b/libs/ui/tool/kis_smoothing_options.cpp
@@ -14,7 +14,9 @@ struct KisSmoothingOptions::Private {
{
KisConfig cfg(true);
smoothingType = (SmoothingType)cfg.lineSmoothingType(!useSavedSmoothing);
- smoothnessDistance = cfg.lineSmoothingDistance(!useSavedSmoothing);
+ smoothnessDistanceMin = cfg.lineSmoothingDistanceMin(!useSavedSmoothing);
+ smoothnessDistanceMax = cfg.lineSmoothingDistanceMax(!useSavedSmoothing);
+ smoothnessDistanceKeepAspectRatio = cfg.lineSmoothingDistanceKeepAspectRatio(!useSavedSmoothing);
tailAggressiveness = cfg.lineSmoothingTailAggressiveness(!useSavedSmoothing);
smoothPressure = cfg.lineSmoothingSmoothPressure(!useSavedSmoothing);
useScalableDistance = cfg.lineSmoothingScalableDistance(!useSavedSmoothing);
@@ -27,7 +29,9 @@ struct KisSmoothingOptions::Private {
KisSignalCompressor writeCompressor;
SmoothingType smoothingType;
- qreal smoothnessDistance;
+ qreal smoothnessDistanceMin;
+ qreal smoothnessDistanceMax;
+ bool smoothnessDistanceKeepAspectRatio;
qreal tailAggressiveness;
bool smoothPressure;
bool useScalableDistance;
@@ -60,14 +64,37 @@ void KisSmoothingOptions::setSmoothingType(KisSmoothingOptions::SmoothingType va
m_d->writeCompressor.start();
}
-qreal KisSmoothingOptions::smoothnessDistance() const
+qreal KisSmoothingOptions::smoothnessDistanceMin() const
{
- return m_d->smoothnessDistance;
+ return m_d->smoothnessDistanceMin;
}
-void KisSmoothingOptions::setSmoothnessDistance(qreal value)
+
+void KisSmoothingOptions::setSmoothnessDistanceMin(qreal value)
+{
+ m_d->smoothnessDistanceMin = value;
+ m_d->writeCompressor.start();
+}
+
+qreal KisSmoothingOptions::smoothnessDistanceMax() const
+{
+ return m_d->smoothnessDistanceMax;
+}
+
+void KisSmoothingOptions::setSmoothnessDistanceMax(qreal value)
+{
+ m_d->smoothnessDistanceMax = value;
+ m_d->writeCompressor.start();
+}
+
+bool KisSmoothingOptions::smoothnessDistanceKeepAspectRatio() const
+{
+ return m_d->smoothnessDistanceKeepAspectRatio;
+}
+
+void KisSmoothingOptions::setSmoothnessDistanceKeepAspectRatio(bool value)
{
- m_d->smoothnessDistance = value;
+ m_d->smoothnessDistanceKeepAspectRatio = value;
m_d->writeCompressor.start();
}
@@ -156,7 +183,9 @@ void KisSmoothingOptions::slotWriteConfig()
{
KisConfig cfg(false);
cfg.setLineSmoothingType(m_d->smoothingType);
- cfg.setLineSmoothingDistance(m_d->smoothnessDistance);
+ cfg.setLineSmoothingDistanceMin(m_d->smoothnessDistanceMin);
+ cfg.setLineSmoothingDistanceMax(m_d->smoothnessDistanceMax);
+ cfg.setLineSmoothingDistanceKeepAspectRatio(m_d->smoothnessDistanceKeepAspectRatio);
cfg.setLineSmoothingTailAggressiveness(m_d->tailAggressiveness);
cfg.setLineSmoothingSmoothPressure(m_d->smoothPressure);
cfg.setLineSmoothingScalableDistance(m_d->useScalableDistance);
diff --git a/libs/ui/tool/kis_smoothing_options.h b/libs/ui/tool/kis_smoothing_options.h
index 16208d0ae6..0fb8a926ec 100644
--- a/libs/ui/tool/kis_smoothing_options.h
+++ b/libs/ui/tool/kis_smoothing_options.h
@@ -33,8 +33,14 @@ public:
SmoothingType smoothingType() const;
void setSmoothingType(SmoothingType value);
- qreal smoothnessDistance() const;
- void setSmoothnessDistance(qreal value);
+ qreal smoothnessDistanceMin() const;
+ void setSmoothnessDistanceMin(qreal value);
+
+ qreal smoothnessDistanceMax() const;
+ void setSmoothnessDistanceMax(qreal value);
+
+ bool smoothnessDistanceKeepAspectRatio() const;
+ void setSmoothnessDistanceKeepAspectRatio(bool value);
qreal tailAggressiveness() const;
void setTailAggressiveness(qreal value);
diff --git a/libs/ui/tool/kis_tool_freehand_helper.cpp b/libs/ui/tool/kis_tool_freehand_helper.cpp
index 6ab124fab1..59a09b594b 100644
--- a/libs/ui/tool/kis_tool_freehand_helper.cpp
+++ b/libs/ui/tool/kis_tool_freehand_helper.cpp
@@ -108,7 +108,7 @@ struct KisToolFreehandHelper::Private
KisStabilizedEventsSampler stabilizedSampler;
KisStabilizerDelayedPaintHelper stabilizerDelayedPaintHelper;
- qreal effectiveSmoothnessDistance() const;
+ qreal effectiveSmoothnessDistance(qreal speed) const;
};
@@ -430,7 +430,7 @@ void KisToolFreehandHelper::paintBezierSegment(KisPaintInformation pi1, KisPaint
pi2);
}
-qreal KisToolFreehandHelper::Private::effectiveSmoothnessDistance() const
+qreal KisToolFreehandHelper::Private::effectiveSmoothnessDistance(qreal speed) const
{
qreal zoomingCoeff = 1.0;
@@ -443,7 +443,7 @@ qreal KisToolFreehandHelper::Private::effectiveSmoothnessDistance() const
zoomingCoeff = 1.0 / resources->effectiveZoom();
}
- return smoothingOptions->smoothnessDistance() * zoomingCoeff;
+ return zoomingCoeff * ((1.0 - speed) * smoothingOptions->smoothnessDistanceMax() + speed * smoothingOptions->smoothnessDistanceMin());
}
void KisToolFreehandHelper::paintEvent(KoPointerEvent *event)
@@ -485,9 +485,10 @@ void KisToolFreehandHelper::paint(KisPaintInformation &info)
if (m_d->smoothingOptions->smoothingType() == KisSmoothingOptions::WEIGHTED_SMOOTHING
- && m_d->smoothingOptions->smoothnessDistance() > 0.0) {
- {
- // initialize current distance
+ && (m_d->smoothingOptions->smoothnessDistanceMin() > 0.0
+ || m_d->smoothingOptions->smoothnessDistanceMax() > 0.0)) {
+
+ { // initialize current distance
QPointF prevPos;
if (!m_d->history.isEmpty()) {
@@ -507,7 +508,7 @@ void KisToolFreehandHelper::paint(KisPaintInformation &info)
qreal y = 0.0;
if (m_d->history.size() > 3) {
- const qreal sigma = m_d->effectiveSmoothnessDistance() / 3.0; // '3.0' for (3 * sigma) range
+ const qreal sigma = m_d->effectiveSmoothnessDistance(m_d->previousPaintInformation.drawingSpeed()) / 3.0; // '3.0' for (3 * sigma) range
qreal gaussianWeight = 1 / (sqrt(2 * M_PI) * sigma);
qreal gaussianWeight2 = sigma * sigma;
@@ -742,7 +743,7 @@ void KisToolFreehandHelper::stabilizerStart(KisPaintInformation firstPaintInfo)
{
m_d->usingStabilizer = true;
// FIXME: Ugly hack, this is no a "distance" in any way
- int sampleSize = qRound(m_d->effectiveSmoothnessDistance());
+ int sampleSize = qRound(m_d->effectiveSmoothnessDistance(firstPaintInfo.drawingSpeed()));
sampleSize = qMax(3, sampleSize);
// Fill the deque with the current value repeated until filling the sample
diff --git a/plugins/tools/basictools/kis_tool_brush.cc b/plugins/tools/basictools/kis_tool_brush.cc
index 251f0e7b3e..80a2c60d10 100644
--- a/plugins/tools/basictools/kis_tool_brush.cc
+++ b/plugins/tools/basictools/kis_tool_brush.cc
@@ -32,6 +32,7 @@
#include "kis_tool.h"
#include "kis_paintop_preset.h"
#include "kis_paintop_settings.h"
+#include "kis_aspect_ratio_locker.h"
#include "kis_floating_message.h"
#include "canvas/kis_canvas2.h"
#include "KisViewManager.h"
@@ -101,9 +102,14 @@ bool KisToolBrush::smoothPressure() const
return smoothingOptions()->smoothPressure();
}
-int KisToolBrush::smoothnessQuality() const
+int KisToolBrush::smoothnessQualityMin() const
{
- return smoothingOptions()->smoothnessDistance();
+ return smoothingOptions()->smoothnessDistanceMin();
+}
+
+int KisToolBrush::smoothnessQualityMax() const
+{
+ return smoothingOptions()->smoothnessDistanceMax();
}
qreal KisToolBrush::smoothnessFactor() const
@@ -121,18 +127,80 @@ void KisToolBrush::slotSetSmoothingType(int index)
m_cmbSmoothingType->setCurrentIndex(index);
}
- smoothingOptions()->setSmoothingType((KisSmoothingOptions::SmoothingType) index);
-
- showControl(m_sliderSmoothnessDistance, (KisSmoothingOptions::WEIGHTED_SMOOTHING == smoothingOptions()->smoothingType()||
- KisSmoothingOptions::STABILIZER == smoothingOptions()->smoothingType()));
- showControl(m_sliderTailAggressiveness, (KisSmoothingOptions::WEIGHTED_SMOOTHING == smoothingOptions()->smoothingType()));
- showControl(m_chkSmoothPressure, (KisSmoothingOptions::WEIGHTED_SMOOTHING == smoothingOptions()->smoothingType()));
- showControl(m_chkUseScalableDistance, (KisSmoothingOptions::WEIGHTED_SMOOTHING == smoothingOptions()->smoothingType() /*||
- KisSmoothingOptions::STABILIZER == smoothingOptions()->smoothingType()*/)); // scalable distance option is disabled due to bug 421314
- showControl(m_sliderDelayDistance, (KisSmoothingOptions::STABILIZER == smoothingOptions()->smoothingType()));
- showControl(m_chkFinishStabilizedCurve, (KisSmoothingOptions::STABILIZER == smoothingOptions()->smoothingType()));
- showControl(m_chkStabilizeSensors, (KisSmoothingOptions::STABILIZER == smoothingOptions()->smoothingType()));
-
+ switch (index) {
+ case KisSmoothingOptions::NO_SMOOTHING:
+ smoothingOptions()->setSmoothingType(KisSmoothingOptions::NO_SMOOTHING);
+ m_lblSmoothnessDistanceMin->setVisible(false);
+ m_sliderSmoothnessDistanceMin->setVisible(false);
+ m_lblSmoothnessDistanceMax->setVisible(false);
+ m_sliderSmoothnessDistanceMax->setVisible(false);
+ m_distanceAspectButton->setVisible(false);
+ showControl(m_sliderTailAggressiveness, false);
+ showControl(m_chkSmoothPressure, false);
+ showControl(m_chkUseScalableDistance, false);
+ showControl(m_sliderDelayDistance, false);
+ showControl(m_chkFinishStabilizedCurve, false);
+ showControl(m_chkStabilizeSensors, false);
+ break;
+ case KisSmoothingOptions::SIMPLE_SMOOTHING:
+ smoothingOptions()->setSmoothingType(KisSmoothingOptions::SIMPLE_SMOOTHING);
+ m_lblSmoothnessDistanceMin->setVisible(false);
+ m_sliderSmoothnessDistanceMin->setVisible(false);
+ m_lblSmoothnessDistanceMax->setVisible(false);
+ m_sliderSmoothnessDistanceMax->setVisible(false);
+ m_distanceAspectButton->setVisible(false);
+ showControl(m_sliderTailAggressiveness, false);
+ showControl(m_chkSmoothPressure, false);
+ showControl(m_chkUseScalableDistance, false);
+ showControl(m_sliderDelayDistance, false);
+ showControl(m_chkFinishStabilizedCurve, false);
+ showControl(m_chkStabilizeSensors, false);
+ break;
+ case KisSmoothingOptions::WEIGHTED_SMOOTHING:
+ smoothingOptions()->setSmoothingType(KisSmoothingOptions::WEIGHTED_SMOOTHING);
+ m_lblSmoothnessDistanceMin->setVisible(true);
+ m_sliderSmoothnessDistanceMin->setVisible(true);
+ m_lblSmoothnessDistanceMax->setVisible(true);
+ m_sliderSmoothnessDistanceMax->setVisible(true);
+ m_distanceAspectButton->setVisible(true);
+ showControl(m_sliderTailAggressiveness, true);
+ showControl(m_chkSmoothPressure, true);
+ showControl(m_chkUseScalableDistance, true);
+ showControl(m_sliderDelayDistance, false);
+ showControl(m_chkFinishStabilizedCurve, false);
+ showControl(m_chkStabilizeSensors, false);
+ break;
+ case KisSmoothingOptions::STABILIZER:
+ smoothingOptions()->setSmoothingType(KisSmoothingOptions::STABILIZER);
+ m_lblSmoothnessDistanceMin->setVisible(true);
+ m_sliderSmoothnessDistanceMin->setVisible(true);
+ m_lblSmoothnessDistanceMax->setVisible(true);
+ m_sliderSmoothnessDistanceMax->setVisible(true);
+ m_distanceAspectButton->setVisible(true);
+ showControl(m_sliderTailAggressiveness, false);
+ showControl(m_chkSmoothPressure, false);
+ showControl(m_sliderDelayDistance, true);
+ showControl(m_chkFinishStabilizedCurve, true);
+ showControl(m_chkStabilizeSensors, true);
+
+ // scalable distance option is disabled due to bug 421314
+ showControl(m_chkUseScalableDistance, false);
+ break;
+ case KisSmoothingOptions::PIXEL_PERFECT:
+ default:
+ smoothingOptions()->setSmoothingType(KisSmoothingOptions::PIXEL_PERFECT);
+ m_lblSmoothnessDistanceMin->setVisible(false);
+ m_sliderSmoothnessDistanceMin->setVisible(false);
+ m_lblSmoothnessDistanceMax->setVisible(false);
+ m_sliderSmoothnessDistanceMax->setVisible(false);
+ m_distanceAspectButton->setVisible(false);
+ showControl(m_sliderTailAggressiveness, false);
+ showControl(m_chkSmoothPressure, false);
+ showControl(m_chkUseScalableDistance, false);
+ showControl(m_sliderDelayDistance, false);
+ showControl(m_chkFinishStabilizedCurve, false);
+ showControl(m_chkStabilizeSensors, false);
+ }
updateSmoothnessDistanceLabel();
Q_EMIT smoothingTypeChanged();
@@ -140,38 +208,69 @@ void KisToolBrush::slotSetSmoothingType(int index)
void KisToolBrush::updateSmoothnessDistanceLabel()
{
- const qreal oldValue = m_sliderSmoothnessDistance->value();
+ const qreal oldValueMin = m_sliderSmoothnessDistanceMin->value();
+ const qreal oldValueMax = m_sliderSmoothnessDistanceMax->value();
if (smoothingType() == KisSmoothingOptions::STABILIZER) {
- m_lblSmoothnessDistance->setText(i18n("Sample count:"));
- m_sliderSmoothnessDistance->setRange(3.0, MAXIMUM_SMOOTHNESS_DISTANCE, 0);
- m_sliderSmoothnessDistance->setSingleStep(1);
- m_sliderSmoothnessDistance->setExponentRatio(3.0); // help pick smaller values
-
- if (!qFuzzyCompare(m_sliderSmoothnessDistance->value(), oldValue)) {
- // the slider will Q_EMIT the change signal automatically
- m_sliderSmoothnessDistance->setValue(qRound(oldValue));
+ m_lblSmoothnessDistanceMin->setText(i18n("Sample Count at Max Speed:"));
+ m_sliderSmoothnessDistanceMin->setRange(3.0, MAXIMUM_SMOOTHNESS_DISTANCE, 0);
+ m_sliderSmoothnessDistanceMin->setSingleStep(1);
+ m_sliderSmoothnessDistanceMin->setExponentRatio(3.0); // help pick smaller values
+
+ if (!qFuzzyCompare(m_sliderSmoothnessDistanceMin->value(), oldValueMin)) {
+ // the slider will emit the change signal automatically
+ m_sliderSmoothnessDistanceMin->setValue(qRound(oldValueMin));
}
+ m_lblSmoothnessDistanceMax->setText(i18n("Sample Count at Min Speed:"));
+ m_sliderSmoothnessDistanceMax->setRange(3.0, MAXIMUM_SMOOTHNESS_DISTANCE, 0);
+ m_sliderSmoothnessDistanceMax->setSingleStep(1);
+ m_sliderSmoothnessDistanceMax->setExponentRatio(3.0); // help pick smaller values
+
+ if (!qFuzzyCompare(m_sliderSmoothnessDistanceMax->value(), oldValueMax)) {
+ // the slider will emit the change signal automatically
+ m_sliderSmoothnessDistanceMax->setValue(qRound(oldValueMax));
+ }
} else {
- m_lblSmoothnessDistance->setText(i18nc("Label of Distance value in Freehand brush tool's Weighted Smoothing mode", "Distance:"));
- m_sliderSmoothnessDistance->setRange(3.0, MAXIMUM_SMOOTHNESS_DISTANCE, 1);
- m_sliderSmoothnessDistance->setSingleStep(0.1);
- m_sliderSmoothnessDistance->setExponentRatio(3.0); // help pick smaller values
-
- if (!qFuzzyCompare(m_sliderSmoothnessDistance->value(), oldValue)) {
- // the slider will Q_EMIT the change signal automatically
- m_sliderSmoothnessDistance->setValue(oldValue);
+ m_lblSmoothnessDistanceMin->setText(i18n("Distance at Max Speed:"));
+ m_sliderSmoothnessDistanceMin->setRange(3.0, MAXIMUM_SMOOTHNESS_DISTANCE, 1);
+ m_sliderSmoothnessDistanceMin->setSingleStep(1);
+ m_sliderSmoothnessDistanceMin->setExponentRatio(3.0); // help pick smaller values
+
+ if (!qFuzzyCompare(m_sliderSmoothnessDistanceMin->value(), oldValueMin)) {
+ // the slider will emit the change signal automatically
+ m_sliderSmoothnessDistanceMin->setValue(oldValueMin);
+ }
+
+ m_lblSmoothnessDistanceMax->setText(i18n("Distance at Min Speed:"));
+ m_sliderSmoothnessDistanceMax->setRange(3.0, MAXIMUM_SMOOTHNESS_DISTANCE, 1);
+ m_sliderSmoothnessDistanceMax->setSingleStep(1);
+ m_sliderSmoothnessDistanceMax->setExponentRatio(3.0); // help pick smaller values
+
+ if (!qFuzzyCompare(m_sliderSmoothnessDistanceMax->value(), oldValueMax)) {
+ // the slider will emit the change signal automatically
+ m_sliderSmoothnessDistanceMax->setValue(oldValueMax);
}
}
}
-void KisToolBrush::slotSetSmoothnessDistance(qreal distance)
+void KisToolBrush::slotSetSmoothnessDistanceMin(qreal distance)
+{
+ smoothingOptions()->setSmoothnessDistanceMin(distance);
+ Q_EMIT smoothnessQualityChanged();
+}
+
+void KisToolBrush::slotSetSmoothnessDistanceMax(qreal distance)
{
- smoothingOptions()->setSmoothnessDistance(distance);
+ smoothingOptions()->setSmoothnessDistanceMax(distance);
Q_EMIT smoothnessQualityChanged();
}
+void KisToolBrush::slotSetSmoothnessDistanceKeepAspectRatio(bool value)
+{
+ smoothingOptions()->setSmoothnessDistanceKeepAspectRatio(value);
+}
+
void KisToolBrush::slotSetTailAggressiveness(qreal argh_rhhrr)
{
smoothingOptions()->setTailAggressiveness(argh_rhhrr);
@@ -275,7 +374,8 @@ void KisToolBrush::updateSettingsViews()
{
m_cmbSmoothingType->setCurrentIndex(smoothingOptions()->smoothingType());
- m_sliderSmoothnessDistance->setValue(smoothingOptions()->smoothnessDistance());
+ m_sliderSmoothnessDistanceMin->setValue(smoothingOptions()->smoothnessDistanceMin());
+ m_sliderSmoothnessDistanceMax->setValue(smoothingOptions()->smoothnessDistanceMax());
m_chkDelayDistance->setChecked(smoothingOptions()->useDelayDistance());
m_sliderDelayDistance->setValue(smoothingOptions()->delayDistance());
m_sliderTailAggressiveness->setValue(smoothingOptions()->tailAggressiveness());
@@ -319,24 +419,59 @@ QWidget * KisToolBrush::createOptionWidget()
connect(m_cmbSmoothingType, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetSmoothingType(int)));
addOptionWidgetOption(m_cmbSmoothingType, new QLabel(i18n("Brush Smoothing:"), optionsWidget));
- m_sliderSmoothnessDistance = new KisDoubleSliderSpinBox(optionsWidget);
- m_sliderSmoothnessDistance->setEnabled(true);
- m_lblSmoothnessDistance = new QLabel(optionsWidget);
- updateSmoothnessDistanceLabel();
+ // Smoothness Distance
+ m_sliderSmoothnessDistanceMin = new KisDoubleSliderSpinBox(optionsWidget);
+ m_sliderSmoothnessDistanceMin->setEnabled(true);
+ m_lblSmoothnessDistanceMin = new QLabel(optionsWidget);
+
+ m_sliderSmoothnessDistanceMax = new KisDoubleSliderSpinBox(optionsWidget);
+ m_sliderSmoothnessDistanceMax->setEnabled(true);
+ m_lblSmoothnessDistanceMax = new QLabel(optionsWidget);
+ updateSmoothnessDistanceLabel();
// make sure that initialization of the value happens **after** we
// have configured the slider's range in updateSmoothnessDistanceLabel()
- connect(m_sliderSmoothnessDistance, SIGNAL(valueChanged(qreal)), SLOT(slotSetSmoothnessDistance(qreal)));
- m_sliderSmoothnessDistance->setValue(smoothingOptions()->smoothnessDistance());
-
- addOptionWidgetOption(m_sliderSmoothnessDistance, m_lblSmoothnessDistance);
+ connect(m_sliderSmoothnessDistanceMin, SIGNAL(valueChanged(qreal)), SLOT(slotSetSmoothnessDistanceMin(qreal)));
+ m_sliderSmoothnessDistanceMin->setValue(smoothingOptions()->smoothnessDistanceMin());
+
+ connect(m_sliderSmoothnessDistanceMax, SIGNAL(valueChanged(qreal)), SLOT(slotSetSmoothnessDistanceMax(qreal)));
+ m_sliderSmoothnessDistanceMax->setValue(smoothingOptions()->smoothnessDistanceMax());
+
+ // Create KoAspectButton
+ m_distanceAspectButton = new KoAspectButton(optionsWidget);
+ m_distanceAspectButton->setKeepAspectRatio(smoothingOptions()->smoothnessDistanceKeepAspectRatio());
+ m_distanceAspectButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ m_distanceAspectButton->setMinimumSize(QSize(24, 24));
+ connect(m_distanceAspectButton, SIGNAL(keepAspectRatioChanged(bool)), SLOT(slotSetSmoothnessDistanceKeepAspectRatio(bool)));
+
+ // Add distanceLabels
+ QWidget* distanceLabelWidget = new QWidget(optionsWidget);
+ QVBoxLayout* distanceLabelLayout = new QVBoxLayout(distanceLabelWidget);
+ distanceLabelLayout->setContentsMargins(0,0,0,0);
+ distanceLabelLayout->setSpacing(5);
+ distanceLabelLayout->addWidget(m_lblSmoothnessDistanceMin);
+ distanceLabelLayout->addWidget(m_lblSmoothnessDistanceMax);
+
+ // Add distanceSliders
+ QWidget* distanceSliderWidget = new QWidget(optionsWidget);
+ QGridLayout* distanceSliderLayout = new QGridLayout(distanceSliderWidget);
+ distanceSliderLayout->setContentsMargins(0,0,0,0);
+ distanceSliderLayout->setHorizontalSpacing(0);
+ distanceSliderLayout->setVerticalSpacing(5);
+ distanceSliderLayout->addWidget(m_sliderSmoothnessDistanceMin, 0, 0, 1, 1);
+ distanceSliderLayout->addWidget(m_sliderSmoothnessDistanceMax, 1, 0, 1, 1);
+ distanceSliderLayout->addWidget(m_distanceAspectButton, 0, 1, 2, 1);
+
+ addOptionWidgetOption(distanceSliderWidget, distanceLabelWidget);
+
+ KisAspectRatioLocker *distanceAspectLocker = new KisAspectRatioLocker(this);
+ distanceAspectLocker->connectSpinBoxes(m_sliderSmoothnessDistanceMin, m_sliderSmoothnessDistanceMax, m_distanceAspectButton);
// Finish stabilizer curve
m_chkFinishStabilizedCurve = new QCheckBox(optionsWidget);
- m_chkFinishStabilizedCurve->setMinimumHeight(qMax(m_sliderSmoothnessDistance->sizeHint().height()-3,
- m_chkFinishStabilizedCurve->sizeHint().height()));
connect(m_chkFinishStabilizedCurve, SIGNAL(toggled(bool)), this, SLOT(setFinishStabilizedCurve(bool)));
m_chkFinishStabilizedCurve->setChecked(smoothingOptions()->finishStabilizedCurve());
+ m_chkFinishStabilizedCurve->setMinimumHeight(m_cmbSmoothingType->sizeHint().height()-3);
// Delay Distance for Stabilizer
QWidget* delayWidget = new QWidget(optionsWidget);
@@ -368,13 +503,11 @@ QWidget * KisToolBrush::createOptionWidget()
// Stabilize sensors
m_chkStabilizeSensors = new QCheckBox(optionsWidget);
- m_chkStabilizeSensors->setMinimumHeight(qMax(m_sliderSmoothnessDistance->sizeHint().height()-3,
- m_chkStabilizeSensors->sizeHint().height()));
connect(m_chkStabilizeSensors, SIGNAL(toggled(bool)), this, SLOT(setStabilizeSensors(bool)));
m_chkStabilizeSensors->setChecked(smoothingOptions()->stabilizeSensors());
+ m_chkStabilizeSensors->setMinimumHeight(m_cmbSmoothingType->sizeHint().height()-3);
addOptionWidgetOption(m_chkStabilizeSensors, new QLabel(i18n("Stabilize Sensors:"), optionsWidget));
-
m_sliderTailAggressiveness = new KisDoubleSliderSpinBox(optionsWidget);
m_sliderTailAggressiveness->setRange(0.0, 1.0, 2);
m_sliderTailAggressiveness->setSingleStep(0.01);
@@ -384,16 +517,14 @@ QWidget * KisToolBrush::createOptionWidget()
addOptionWidgetOption(m_sliderTailAggressiveness, new QLabel(i18n("Stroke Ending:"), optionsWidget));
m_chkSmoothPressure = new QCheckBox(optionsWidget);
- m_chkSmoothPressure->setMinimumHeight(qMax(m_sliderSmoothnessDistance->sizeHint().height()-3,
- m_chkSmoothPressure->sizeHint().height()));
+ m_chkSmoothPressure->setMinimumHeight(m_cmbSmoothingType->sizeHint().height()-3);
m_chkSmoothPressure->setChecked(smoothingOptions()->smoothPressure());
connect(m_chkSmoothPressure, SIGNAL(toggled(bool)), this, SLOT(setSmoothPressure(bool)));
addOptionWidgetOption(m_chkSmoothPressure, new QLabel(QString("%1:").arg(i18n("Smooth Pressure")), optionsWidget));
m_chkUseScalableDistance = new QCheckBox(optionsWidget);
m_chkUseScalableDistance->setChecked(smoothingOptions()->useScalableDistance());
- m_chkUseScalableDistance->setMinimumHeight(qMax(m_sliderSmoothnessDistance->sizeHint().height()-3,
- m_chkUseScalableDistance->sizeHint().height()));
+ m_chkUseScalableDistance->setMinimumHeight(m_cmbSmoothingType->sizeHint().height()-3);
m_chkUseScalableDistance->setToolTip(i18nc("@info:tooltip",
"Scalable distance takes zoom level "
"into account and makes the distance "
@@ -402,7 +533,6 @@ QWidget * KisToolBrush::createOptionWidget()
connect(m_chkUseScalableDistance, SIGNAL(toggled(bool)), this, SLOT(setUseScalableDistance(bool)));
addOptionWidgetOption(m_chkUseScalableDistance, new QLabel(QString("%1:").arg(i18n("Scalable Distance")), optionsWidget));
-
// add a line spacer so we know that the next set of options are for different settings
QFrame* line = new QFrame(optionsWidget);
line->setObjectName(QString::fromUtf8("line"));
diff --git a/plugins/tools/basictools/kis_tool_brush.h b/plugins/tools/basictools/kis_tool_brush.h
index 9d0a56f9ba..7ddd8e4a49 100644
--- a/plugins/tools/basictools/kis_tool_brush.h
+++ b/plugins/tools/basictools/kis_tool_brush.h
@@ -13,6 +13,8 @@
#include "KisToolPaintFactoryBase.h"
+#include "KoAspectButton.h"
+
#include <flake/kis_node_shape.h>
#include <kis_icon.h>
#include <QKeySequence>
@@ -34,7 +36,8 @@ class KisDoubleSliderSpinBox;
class KisToolBrush : public KisToolFreehand
{
Q_OBJECT
- Q_PROPERTY(int smoothnessQuality READ smoothnessQuality WRITE slotSetSmoothnessDistance NOTIFY smoothnessQualityChanged)
+ Q_PROPERTY(int smoothnessQualityMin READ smoothnessQualityMin WRITE slotSetSmoothnessDistanceMin NOTIFY smoothnessQualityChanged)
+ Q_PROPERTY(int smoothnessQualityMax READ smoothnessQualityMax WRITE slotSetSmoothnessDistanceMax NOTIFY smoothnessQualityChanged)
Q_PROPERTY(qreal smoothnessFactor READ smoothnessFactor WRITE slotSetTailAggressiveness NOTIFY smoothnessFactorChanged)
Q_PROPERTY(bool smoothPressure READ smoothPressure WRITE setSmoothPressure NOTIFY smoothPressureChanged)
Q_PROPERTY(int smoothingType READ smoothingType WRITE slotSetSmoothingType NOTIFY smoothingTypeChanged)
@@ -53,7 +56,8 @@ public:
QWidget * createOptionWidget() override;
- int smoothnessQuality() const;
+ int smoothnessQualityMin() const;
+ int smoothnessQualityMax() const;
qreal smoothnessFactor() const;
bool smoothPressure() const;
int smoothingType() const;
@@ -74,7 +78,9 @@ protected Q_SLOTS:
public Q_SLOTS:
void activate(const QSet<KoShape*> &shapes) override;
void deactivate() override;
- void slotSetSmoothnessDistance(qreal distance);
+ void slotSetSmoothnessDistanceMin(qreal distance);
+ void slotSetSmoothnessDistanceMax(qreal distance);
+ void slotSetSmoothnessDistanceKeepAspectRatio(bool value);
void slotSetMagnetism(int magnetism);
void slotSetSmoothingType(int index);
void slotSetTailAggressiveness(qreal argh_rhhrr);
@@ -112,8 +118,11 @@ private:
KisSliderSpinBox *m_sliderMagnetism {0};
QCheckBox *m_chkOnlyOneAssistant {0};
QCheckBox *m_chkSnapEraser {0};
- KisDoubleSliderSpinBox *m_sliderSmoothnessDistance {0};
- QLabel *m_lblSmoothnessDistance {0};
+ KisDoubleSliderSpinBox *m_sliderSmoothnessDistanceMin {0};
+ KisDoubleSliderSpinBox *m_sliderSmoothnessDistanceMax {0};
+ KoAspectButton *m_distanceAspectButton {0};
+ QLabel *m_lblSmoothnessDistanceMin {0};
+ QLabel *m_lblSmoothnessDistanceMax {0};
KisDoubleSliderSpinBox *m_sliderTailAggressiveness {0};
QCheckBox *m_chkSmoothPressure {0};
QCheckBox *m_chkUseScalableDistance {0};