Commit 09fc20c4 authored by Boudewijn Rempt's avatar Boudewijn Rempt

BUG:324412: Add a value display for the brightness/contrast filter

Patch by Sahil Nagpal (<nagpal.sahil01@gmail.com>)
parent 539403a9
......@@ -34,6 +34,7 @@
#include <QStringList>
#include <QPushButton>
#include <QHBoxLayout>
#include <QColor>
#include "KoBasicHistogramProducers.h"
#include "KoColorSpace.h"
......@@ -47,6 +48,9 @@
#include "widgets/kis_curve_widget.h"
#include "kis_histogram.h"
#include "kis_painter.h"
#include <kis_view2.h>
#include <KoColor.h>
#include <kis_canvas_resource_provider.h>
KisBrightnessContrastFilterConfiguration::KisBrightnessContrastFilterConfiguration()
: KisFilterConfiguration("brightnesscontrast", 1)
......@@ -251,7 +255,13 @@ KisBrightnessContrastConfigWidget::KisBrightnessContrastConfigWidget(QWidget * p
}
m_page->curveWidget->setPixmap(pix);
m_page->curveWidget->setBasePixmap(pix);
}
KisBrightnessContrastConfigWidget::~KisBrightnessContrastConfigWidget()
{
KoToolManager::instance()->switchBackRequested();
delete m_page;
}
KisBrightnessContrastFilterConfiguration * KisBrightnessContrastConfigWidget::configuration() const
......@@ -261,6 +271,26 @@ KisBrightnessContrastFilterConfiguration * KisBrightnessContrastConfigWidget::co
return cfg;
}
void KisBrightnessContrastConfigWidget::slotDrawLine(const KoColor &color)
{
QColor colorNew = color.toQColor();
int i = (colorNew.red() + colorNew.green() + colorNew.blue())/3 ;
QPixmap pix = m_page->curveWidget->getBasePixmap();
QPainter p(&pix);
p.setPen(QPen(Qt::black, 1, Qt::SolidLine));
p.drawLine(i,0,i,255);
QString label = "x:";
label.insert(2,QString(QString::number(i)));
p.drawText(i,250,label);
m_page->curveWidget->setPixmap(pix);
}
void KisBrightnessContrastConfigWidget::setView(KisView2 *view)
{
connect(view->resourceProvider(), SIGNAL(sigFGColorChanged(const KoColor&)), this, SLOT(slotDrawLine(const KoColor&)));
KoToolManager::instance()->switchToolTemporaryRequested("KritaSelected/KisToolColorPicker");
}
void KisBrightnessContrastConfigWidget::setConfiguration(const KisPropertiesConfiguration * config)
{
const KisBrightnessContrastFilterConfiguration * cfg = dynamic_cast<const KisBrightnessContrastFilterConfiguration *>(config);
......@@ -268,5 +298,6 @@ void KisBrightnessContrastConfigWidget::setConfiguration(const KisPropertiesConf
m_page->curveWidget->setCurve(cfg->curve());
}
#include "kis_brightness_contrast_filter.moc"
......@@ -31,6 +31,7 @@
#include <kis_paint_device.h>
#include <kis_processing_information.h>
#include <KoProgressUpdater.h>
#include <KoColor.h>
class QWidget;
class KoColorTransformation;
......@@ -47,7 +48,7 @@ public:
class KisBrightnessContrastFilterConfiguration : public KisFilterConfiguration
{
public:
using KisFilterConfiguration::fromXML;
using KisFilterConfiguration::toXML;
......@@ -102,14 +103,18 @@ public:
class KisBrightnessContrastConfigWidget : public KisConfigWidget
{
Q_OBJECT
public:
KisBrightnessContrastConfigWidget(QWidget * parent, KisPaintDeviceSP dev, Qt::WFlags f = 0);
virtual ~KisBrightnessContrastConfigWidget() {}
virtual ~KisBrightnessContrastConfigWidget();
virtual KisBrightnessContrastFilterConfiguration * configuration() const;
virtual void setConfiguration(const KisPropertiesConfiguration* config);
WdgBrightnessContrast * m_page;
void setView(KisView2 *view);
public slots:
void slotDrawLine(const KoColor &color);
};
#endif
......@@ -177,6 +177,21 @@ void KisCurveWidget::setPixmap(const QPixmap & pix)
d->setCurveRepaint();
}
QPixmap KisCurveWidget::getPixmap()
{
return d->m_pix;
}
void KisCurveWidget::setBasePixmap(const QPixmap &pix)
{
d->m_pixmapBase = pix;
}
QPixmap KisCurveWidget::getBasePixmap()
{
return d->m_pixmapBase;
}
void KisCurveWidget::keyPressEvent(QKeyEvent *e)
{
if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) {
......
......@@ -83,6 +83,10 @@ public:
* itself?
*/
void setPixmap(const QPixmap & pix);
QPixmap getPixmap();
void setBasePixmap(const QPixmap & pix);
QPixmap getBasePixmap();
signals:
......
......@@ -57,6 +57,7 @@ public:
KisCubicCurve m_curve;
QPixmap m_pix;
QPixmap m_pixmapBase;
bool m_pixmapDirty;
QPixmap *m_pixmapCache;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment