[PATCH 8/9] Fixed (reprogrammed) smudge brush

Silvio Heinrich plassy at web.de
Fri Dec 31 00:23:07 CET 2010


Reprogrammed the smudge brush with a simpler algorithm.
An option to mix color into the smudge process is also introduced.
---
 .../defaultpaintops/smudge/kis_smudgeop.cpp        |  107 ++++++++++++++++----
 .../paintops/defaultpaintops/smudge/kis_smudgeop.h |    3 +-
 .../smudge/kis_smudgeop_settings_widget.cpp        |   10 +-
 krita/plugins/paintops/libpaintop/CMakeLists.txt   |    2 +
 .../libpaintop/kis_pressure_composite_option.cpp   |   76 ++++++++++++++
 .../libpaintop/kis_pressure_composite_option.h     |   58 +++++++++++
 .../kis_pressure_composite_option_widget.cpp       |  104 +++++++++++++++++++
 .../kis_pressure_composite_option_widget.h         |   46 +++++++++
 8 files changed, 380 insertions(+), 26 deletions(-)
 create mode 100644 krita/plugins/paintops/libpaintop/kis_pressure_composite_option.cpp
 create mode 100644 krita/plugins/paintops/libpaintop/kis_pressure_composite_option.h
 create mode 100644 krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.cpp
 create mode 100644 krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.h

diff --git a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp
index ee7927f..c8dde6d 100644
--- a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp
+++ b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.cpp
@@ -58,11 +58,11 @@ KisSmudgeOp::KisSmudgeOp(const KisBrushBasedPaintOpSettings *settings, KisPainte
     Q_ASSERT(settings);
     Q_ASSERT(painter);
     m_sizeOption.readOptionSetting(settings);
-    m_opacityOption.readOptionSetting(settings);
     m_rateOption.readOptionSetting(settings);
+    m_compositeOption.readOptionSetting(settings);
     m_sizeOption.sensor()->reset();
-    m_opacityOption.sensor()->reset();
     m_rateOption.sensor()->reset();
+    m_compositeOption.sensor()->reset();
 
     m_tempDev = new KisPaintDevice(painter->device()->colorSpace());
     
@@ -76,9 +76,77 @@ KisSmudgeOp::~KisSmudgeOp()
 {
 }
 
-/* To smudge, one does the following:
 
- 1.- First step: initialize a temporary paint device (m_tempDev) with a copy of the colors below the mouse pointer.
+
+qreal KisSmudgeOp::paintAt(const KisPaintInformation& info)
+{
+    // Simple error catching
+    if (!painter()->device())
+        return 1.0;
+    
+    KisBrushSP brush = m_brush;
+    
+    if(!brush || !brush->canPaintFor(info))
+        return 1.0;
+    
+    double scale = m_sizeOption.apply(info);
+    
+    if((scale*brush->width()) <= 0.01 || (scale*brush->height()) <= 0.01)
+        return 1.0;
+    
+    setCurrentScale(scale);
+    
+    QPointF point = info.pos() - brush->hotSpot(scale, scale);
+    
+    qint32 x, y;
+    qreal xFraction, yFraction;
+    splitCoordinate(point.x(), &x, &xFraction);
+    splitCoordinate(point.y(), &y, &yFraction);
+    
+    KisFixedPaintDeviceSP maskDab = cachedDab(painter()->device()->colorSpace());
+    
+    // Extract the brush mask (maskDab) from brush, and turn it into a transparency mask (alpha8).
+    if(brush->brushType() == IMAGE || brush->brushType() == PIPE_IMAGE) {
+        // This is for bitmap brushes
+        maskDab = brush->paintDevice(painter()->device()->colorSpace(), scale, 0.0, info, xFraction, yFraction);
+    } else {
+        // This is for parametric brushes, those created in the Autobrush popup config dialogue
+        maskDab = cachedDab();
+        brush->mask(maskDab, painter()->paintColor(), scale, scale, 0.0, info, xFraction, yFraction);
+    }
+    
+    maskDab->convertTo(KoColorSpaceRegistry::instance()->alpha8());
+    
+    KisPainter copyPainter(m_tempDev);
+    
+    if(m_compositeOption.isChecked()) {
+        m_compositeOption.apply(&copyPainter, OPACITY_OPAQUE_U8, info);
+        
+        copyPainter.setFillStyle(KisPainter::FillStyleForegroundColor);
+        copyPainter.setPaintColor(painter()->paintColor());
+        copyPainter.paintRect(maskDab->bounds());
+    }
+    
+    quint8 newOpacity = m_rateOption.apply(OPACITY_OPAQUE_U8, info);
+    
+    painter()->setOpacity(newOpacity);
+    painter()->bitBltWithFixedSelection(x, y, m_tempDev, maskDab, maskDab->bounds().width(), maskDab->bounds().height());
+    //painter()->bitBlt(QPoint(x,y), m_tempDev, dab->bounds());
+    
+    m_tempDev->clear(maskDab->bounds());
+    
+    copyPainter.setCompositeOp(COMPOSITE_OVER);
+    copyPainter.setOpacity(OPACITY_OPAQUE_U8);
+    copyPainter.bitBlt(0, 0, painter()->device(), x, y, maskDab->bounds().width(), maskDab->bounds().height());
+    copyPainter.end();
+    
+    return spacing(scale);
+}
+
+
+/* To smudge, one does the following:
+ * 
+ 1 *.- First step: initialize a temporary paint device (m_tempDev) with a copy of the colors below the mouse pointer.
  All other times:
  2.- Vanishing step: Reduce the transparency of the temporary paint device so as to let it mix gradually.
  3.- Combine: Combine the temporary device with the piece the brush currently is 'painting', according to a ratio:
@@ -93,8 +161,7 @@ KisSmudgeOp::~KisSmudgeOp()
  temporary device is cached such that only the colored areas are considered.
  TODO: Make this cached value dump colors that have faded nearly completely and lie outside of the rectangle (dab)
  of the current iteration.
-*/
-    
+ *
 qreal KisSmudgeOp::paintAt(const KisPaintInformation& info)
 {
     KisBrushSP brush = m_brush;
@@ -109,14 +176,14 @@ qreal KisSmudgeOp::paintAt(const KisPaintInformation& info)
     if ((scale * brush->width()) <= 0.01 || (scale * brush->height()) <= 0.01) return 1.0;
     setCurrentScale(scale);
     
-    /* Align a point that represents the top-left corner of the brush-stroke-rendering
-    with the mouse pointer and take into account the brush mask size */
+    // Align a point that represents the top-left corner of the brush-stroke-rendering
+    // with the mouse pointer and take into account the brush mask size
     QPointF hotSpot = brush->hotSpot(scale, scale);
     QPointF pt = info.pos() - hotSpot;
 
-    /* Split the coordinates into integer plus fractional parts. The integer
-    is where the dab will be positioned and the fractional part determines
-    the sub-pixel positioning. */
+    // Split the coordinates into integer plus fractional parts. The integer
+    //is where the dab will be positioned and the fractional part determines
+    // the sub-pixel positioning.
     qint32 x, y;
     qreal xFraction, yFraction;
 
@@ -141,17 +208,17 @@ qreal KisSmudgeOp::paintAt(const KisPaintInformation& info)
     qint32 sw = maskDab->bounds().width();
     qint32 sh = maskDab->bounds().height();
     
-    /* Prepare the top left corner of the temporary paint device where the extracted color will be drawn */
+    // Prepare the top left corner of the temporary paint device where the extracted color will be drawn
     QPoint extractionTopLeft = QPoint(ANCHOR_POINT.x() - sw / 2,
                                       ANCHOR_POINT.y() - sh / 2);
                                       
-    /* In the block below, the opacity of the colors stored in m_tempDev
-    is reduced in opacity. Nothing of the color present inside it is left out */
+    // In the block below, the opacity of the colors stored in m_tempDev
+    // is reduced in opacity. Nothing of the color present inside it is left out
     quint8 opacity = OPACITY_OPAQUE_U8;
     if (!m_firstRun) {
         opacity = m_rateOption.apply(opacity, info);
-        /* Without those limits, the smudge brush doesn't smudge anymore, it either makes a single
-        dropplet of color, or drags a frame indefinitely over the canvas. */
+        // Without those limits, the smudge brush doesn't smudge anymore, it either makes a single
+        // dropplet of color, or drags a frame indefinitely over the canvas.
         opacity = qBound(MIXABLE_LOWER_LIMIT, opacity, MIXABLE_UPPER_LIMIT);
                 
         // Invert the opacity value for color absorption in the next lines (copyPainter)
@@ -162,9 +229,9 @@ qreal KisSmudgeOp::paintAt(const KisPaintInformation& info)
         m_firstRun = false;
         m_wholeTempData = QRect(extractionTopLeft, maskDab->bounds().size());
     }
-    /* copyPainter will extract the piece of color (image) to be duplicated to generate the smudge effect,
-    it extracts a simple unmasked rectangle and adds it to what was extracted before in this same block of code,
-    this sometimes shows artifacts when the brush is used with stylus and high spacing */
+    // copyPainter will extract the piece of color (image) to be duplicated to generate the smudge effect,
+    // it extracts a simple unmasked rectangle and adds it to what was extracted before in this same block of code,
+    // this sometimes shows artifacts when the brush is used with stylus and high spacing
     KisPainter copyPainter(m_tempDev);
     copyPainter.setCompositeOp(COMPOSITE_COPY);
     copyPainter.setOpacity(opacity);
@@ -179,4 +246,4 @@ qreal KisSmudgeOp::paintAt(const KisPaintInformation& info)
     renderMirrorMask(QRect(QPoint(x,y),QSize(sw,sh)),m_tempDev,extractionTopLeft.x(), extractionTopLeft.y(),maskDab);
     
     return spacing(scale);
-}
+}//*/
diff --git a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h
index 6e3e63f..35a5b64 100644
--- a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h
+++ b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop.h
@@ -31,6 +31,7 @@
 #include <kis_pressure_opacity_option.h>
 #include <kis_pressure_size_option.h>
 #include <kis_pressure_rate_option.h>
+#include <kis_pressure_composite_option.h>
 
 class KisBrushBasedPaintOpSettings;
 
@@ -56,8 +57,8 @@ private:
     KoColor m_color;
     
     KisPressureSizeOption m_sizeOption;
-    KisPressureOpacityOption m_opacityOption;
     KisPressureRateOption m_rateOption;
+    KisPressureCompositeOption m_compositeOption;
 };
 
 #endif // KIS_SMUDGEOP_H_
diff --git a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop_settings_widget.cpp b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop_settings_widget.cpp
index 07a70ca..3f01533 100644
--- a/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop_settings_widget.cpp
+++ b/krita/plugins/paintops/defaultpaintops/smudge/kis_smudgeop_settings_widget.cpp
@@ -24,12 +24,13 @@
 #include "kis_brush_based_paintop_settings.h"
 #include <kis_properties_configuration.h>
 #include <kis_paintop_options_widget.h>
-#include <kis_pressure_darken_option.h>
-#include <kis_pressure_opacity_option.h>
 #include <kis_pressure_size_option.h>
+#include <kis_pressure_composite_option.h>
 #include <kis_pressure_rate_option.h>
 #include <kis_curve_option_widget.h>
 #include <kis_pressure_rate_option_widget.h>
+#include <kis_pressure_composite_option_widget.h>
+
 
 KisSmudgeOpSettingsWidget::KisSmudgeOpSettingsWidget(QWidget* parent)
     : KisBrushBasedPaintopOptionWidget(parent)
@@ -37,9 +38,8 @@ KisSmudgeOpSettingsWidget::KisSmudgeOpSettingsWidget(QWidget* parent)
     setObjectName("brush option widget");
 
     addPaintOpOption(new KisCurveOptionWidget(new KisPressureSizeOption()));
-    addPaintOpOption(new KisCurveOptionWidget(new KisPressureOpacityOption()));
-    addPaintOpOption(new KisCurveOptionWidget(new KisPressureDarkenOption));
     addPaintOpOption(new KisPressureRateOptionWidget());
+    addPaintOpOption(new KisPressureCompositeOptionWidget());
 
 }
 
@@ -51,7 +51,7 @@ KisPropertiesConfiguration* KisSmudgeOpSettingsWidget::configuration() const
 {
     KisBrushBasedPaintOpSettings *config = new KisBrushBasedPaintOpSettings();
     config->setOptionsWidget(const_cast<KisSmudgeOpSettingsWidget*>(this));
-    config->setProperty("paintop", "smudge"); // XXX: make this a const id string
+    config->setProperty("paintop", "smudge"); // TODO: make this a const id string
     writeConfiguration(config);
     return config;
 }
diff --git a/krita/plugins/paintops/libpaintop/CMakeLists.txt b/krita/plugins/paintops/libpaintop/CMakeLists.txt
index 996cafc..b0bc55d 100644
--- a/krita/plugins/paintops/libpaintop/CMakeLists.txt
+++ b/krita/plugins/paintops/libpaintop/CMakeLists.txt
@@ -38,6 +38,8 @@ set(kritalibpaintop_LIB_SRCS
     kis_pressure_size_option.cpp
     kis_pressure_softness_option.cpp
     kis_pressure_mix_option.cpp
+    kis_pressure_composite_option.cpp
+    kis_pressure_composite_option_widget.cpp
     kis_sensor_selector.cc
     kis_text_brush_chooser.cpp
     kis_brush_based_paintop_options_widget.cpp
diff --git a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.cpp b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.cpp
new file mode 100644
index 0000000..18a9882
--- /dev/null
+++ b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.cpp
@@ -0,0 +1,76 @@
+/* This file is part of the KDE project
+ * Copyright (C) Boudewijn Rempt <boud at valdyas.org>, (C) 2008
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "kis_pressure_composite_option.h"
+
+
+#include <klocale.h>
+
+#include <kis_painter.h>
+#include <widgets/kis_curve_widget.h>
+
+#include <KoColor.h>
+#include <KoColorSpace.h>
+#include <KoCompositeOp.h>
+
+KisPressureCompositeOption::KisPressureCompositeOption()
+        : KisCurveOption(i18n("Color"), "Color", KisPaintOpOption::brushCategory(), false)
+{
+    setMinimumLabel(i18n("Full Color"));
+    setMaximumLabel(i18n("No Color"));
+}
+
+void KisPressureCompositeOption::writeOptionSetting(KisPropertiesConfiguration* setting) const
+{
+    KisCurveOption::writeOptionSetting(setting);
+    setting->setProperty("CompositeOp", m_compositeOp);
+    setting->setProperty("CompositeRateValue", m_rate);
+}
+
+void KisPressureCompositeOption::readOptionSetting(const KisPropertiesConfiguration* setting)
+{
+    KisCurveOption::readOptionSetting(setting);
+    m_compositeOp = setting->getString("CompositeOp");
+    m_rate        = setting->getInt("CompositeRateValue");
+    
+    if(m_compositeOp == "") //TODO: test if compositeOp is valid instead of just testing for an empty string
+        m_compositeOp = COMPOSITE_OVER;
+}
+
+QString KisPressureCompositeOption::apply(KisPainter* painter, qint8 opacity, const KisPaintInformation& info) const
+{
+    if(!isChecked())
+        return painter->compositeOp()->id();
+    
+    QString oldCompositeOp = painter->compositeOp()->id();
+    
+    opacity = (m_rate * 255) / 100;
+    opacity = qBound((qint32)OPACITY_TRANSPARENT_U8,
+                     (qint32)(double(opacity) * computeValue(info) / PRESSURE_DEFAULT),
+                     (qint32)OPACITY_OPAQUE_U8);
+    
+    //qreal  opacity1 = (qreal)(painter->opacity() * computeValue(info));
+    //quint8 opacity2 = (quint8)qRound(qBound<qreal>(OPACITY_TRANSPARENT_U8, opacity1, OPACITY_OPAQUE_U8));
+    
+    painter->setCompositeOp(m_compositeOp);
+    painter->setOpacity(opacity);
+
+    return oldCompositeOp;
+}
+
diff --git a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.h b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.h
new file mode 100644
index 0000000..f05642a
--- /dev/null
+++ b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option.h
@@ -0,0 +1,58 @@
+/* This file is part of the KDE project
+ * Copyright (C) Boudewijn Rempt <boud at valdyas.org>, (C) 2008
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KIS_PRESSURE_COMPOSITE_OPTION_H
+#define KIS_PRESSURE_COMPOSITE_OPTION_H
+
+#include "kis_curve_option.h"
+#include <kis_paint_information.h>
+#include <krita_export.h>
+#include <kis_types.h>
+
+class QSlider;
+class KisPropertiesConfiguration;
+class KisPainter;
+
+class PAINTOP_EXPORT KisPressureCompositeOption : public KisCurveOption
+{
+public:
+    KisPressureCompositeOption();
+
+    /**
+     * Set the composite mode and opacity of the painter based on the pressure
+     * and the curve (if checked) and return the old composite mode
+     * of the painter.
+     */
+    QString apply(KisPainter* painter, qint8 opacity, const KisPaintInformation& info) const;
+
+    void writeOptionSetting(KisPropertiesConfiguration* setting) const;
+    void readOptionSetting(const KisPropertiesConfiguration* setting);
+    
+    void setCompositeOp(const QString& compositeOp) { m_compositeOp = compositeOp; }
+    QString getCompositeOp() { return m_compositeOp; }
+    
+    void setRate(int rate) { m_rate = rate; }
+    int getRate() { return m_rate; }
+    
+private:
+    QString m_compositeOp;
+    int     m_rate;
+};
+
+#endif // KIS_PRESSURE_COMPOSITE_OPTION_H
diff --git a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.cpp b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.cpp
new file mode 100644
index 0000000..140c628
--- /dev/null
+++ b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.cpp
@@ -0,0 +1,104 @@
+/* This file is part of the KDE project
+ * Copyright (C) Boudewijn Rempt <boud at valdyas.org>, (C) 2008
+ * Copyright (C) Sven Langkamp <sven.langkamp at gmail.com>, (C) 2009
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "kis_pressure_composite_option_widget.h"
+#include "kis_pressure_composite_option.h"
+
+#include <KoCompositeOp.h>
+
+#include <QWidget>
+#include <QCheckBox>
+#include <QLabel>
+#include <QComboBox>
+#include <QSlider>
+#include <QVBoxLayout>
+#include <QGridLayout>
+
+#include <klocale.h>
+
+KisPressureCompositeOptionWidget::KisPressureCompositeOptionWidget()
+    : KisCurveOptionWidget(new KisPressureCompositeOption())
+{
+    QWidget* widget    = new QWidget;
+    QLabel*  modeLabel = new QLabel(i18n("Mode: "));
+    QLabel*  rateLabel = new QLabel(i18n("Rate: "));
+    
+    m_compositeOpBox = new QComboBox();
+    m_compositeOpBox->addItem(COMPOSITE_OVER);
+    m_compositeOpBox->addItem(COMPOSITE_OVERLAY);
+    m_compositeOpBox->addItem(COMPOSITE_SCREEN);
+    m_compositeOpBox->addItem(COMPOSITE_ADD);
+    m_compositeOpBox->addItem(COMPOSITE_SUBTRACT);
+    
+    m_rateSlider = new QSlider();
+    m_rateSlider->setMinimum(0);
+    m_rateSlider->setMaximum(100);
+    m_rateSlider->setPageStep(1);
+    m_rateSlider->setValue(90);
+    m_rateSlider->setOrientation(Qt::Horizontal);
+    
+    connect(m_compositeOpBox, SIGNAL(activated(QString)), this, SLOT(compositeOpChanged(QString)));
+    connect(m_rateSlider, SIGNAL(valueChanged(int)), this, SLOT(rateChanged(int)));
+    
+    QGridLayout* gridLayout = new QGridLayout();
+    gridLayout->addWidget(modeLabel, 0, 0);
+    gridLayout->addWidget(m_compositeOpBox, 0, 1);
+    gridLayout->addWidget(rateLabel, 1, 0);
+    gridLayout->addWidget(m_rateSlider, 1, 1);
+
+    QVBoxLayout* vBoxLayout = new QVBoxLayout;
+    vBoxLayout->addLayout(gridLayout);
+    vBoxLayout->addWidget(curveWidget());
+
+    widget->setLayout(vBoxLayout);
+    
+    setConfigurationPage(widget);
+    
+    compositeOpChanged(COMPOSITE_OVER);
+    rateChanged(m_rateSlider->value());
+}
+
+void KisPressureCompositeOptionWidget::readOptionSetting(const KisPropertiesConfiguration* setting)
+{
+    KisCurveOptionWidget::readOptionSetting(setting);
+    
+    QString compositeOp = static_cast<KisPressureCompositeOption*>(curveOption())->getCompositeOp();
+    
+    for(int i=0; i<m_compositeOpBox->count(); ++i) {
+        if(m_compositeOpBox->itemText(i) == compositeOp) {
+            m_compositeOpBox->setCurrentIndex(i);
+            break;
+        }
+    }
+    
+    m_rateSlider->setValue(static_cast<KisPressureCompositeOption*>(curveOption())->getRate());
+}
+
+void KisPressureCompositeOptionWidget::compositeOpChanged(const QString& compositeOp)
+{
+    static_cast<KisPressureCompositeOption*>(curveOption())->setCompositeOp(compositeOp);
+    emit sigSettingChanged();
+}
+
+void KisPressureCompositeOptionWidget::rateChanged(int rate)
+{
+    static_cast<KisPressureCompositeOption*>(curveOption())->setRate(rate);
+    emit sigSettingChanged();
+}
diff --git a/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.h b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.h
new file mode 100644
index 0000000..6660f72
--- /dev/null
+++ b/krita/plugins/paintops/libpaintop/kis_pressure_composite_option_widget.h
@@ -0,0 +1,46 @@
+/* This file is part of the KDE project
+ * Copyright (C) Sven Langkamp <sven.langkamp at gmail.com>, (C) 2009
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KIS_PRESSURE_COMPOSITE_OPTION_WIDGET_H
+#define KIS_PRESSURE_COMPOSITE_OPTION_WIDGET_H
+
+#include "kis_curve_option_widget.h"
+
+class QComboBox;
+class QSlider;
+
+class PAINTOP_EXPORT KisPressureCompositeOptionWidget : public KisCurveOptionWidget
+{
+    Q_OBJECT
+    
+public:
+    KisPressureCompositeOptionWidget();
+
+    void readOptionSetting(const KisPropertiesConfiguration* setting);
+    
+private slots:
+     void compositeOpChanged(const QString& compositeOp);
+     void rateChanged(int rate);
+    
+private:
+    QComboBox* m_compositeOpBox;
+    QSlider*   m_rateSlider;
+};
+
+#endif // KIS_PRESSURE_COMPOSITE_OPTION_WIDGET_H
-- 
1.7.1




More information about the kimageshop mailing list