Commit c52ca3f4 authored by Wolthera van Hövell's avatar Wolthera van Hövell 🛍

Make moving the cursor around more pleasant

Ref T2337
parent 5f161976
......@@ -27,6 +27,7 @@
#include <QList>
#include "KoColorConversions.h"
#include "kis_signal_compressor.h"
struct KisVisualColorSelector::Private
{
......@@ -145,6 +146,8 @@ struct KisVisualColorSelectorShape::Private
KoColor currentColor;
int channel1;
int channel2;
KisSignalCompressor *updateTimer;
bool mousePressActive = false;
};
KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent,
......@@ -164,9 +167,7 @@ KisVisualColorSelectorShape::KisVisualColorSelectorShape(QWidget *parent,
m_d->channel1 = qBound(0, channel1, maxchannel);
m_d->channel2 = qBound(0, channel2, maxchannel);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
//m_d->gradient = QPixmap(size());
//m_d->pixmapsNeedUpdate = true;
//getPixmap();
m_d->updateTimer = new KisSignalCompressor(100 /* ms */, KisSignalCompressor::POSTPONE, this);
}
KisVisualColorSelectorShape::~KisVisualColorSelectorShape()
......@@ -314,14 +315,27 @@ QPointF KisVisualColorSelectorShape::convertKoColorToShapeCoordinate(KoColor c)
void KisVisualColorSelectorShape::mousePressEvent(QMouseEvent *e)
{
QPointF coordinates = convertWidgetCoordinateToShapeCoordinate(e->pos());
KoColor col = convertShapeCoordinateToKoColor(coordinates);
setColor(col);
Q_EMIT sigNewColor(col);
m_d->mousePressActive = true;
}
void KisVisualColorSelectorShape::mouseReleaseEvent(QMouseEvent *)
void KisVisualColorSelectorShape::mouseMoveEvent(QMouseEvent *e)
{
if (m_d->mousePressActive==true && this->mask().contains(e->pos())) {
QPointF coordinates = convertWidgetCoordinateToShapeCoordinate(e->pos());
KoColor col = convertShapeCoordinateToKoColor(coordinates);
setColor(col);
if (!m_d->updateTimer->isActive()) {
Q_EMIT sigNewColor(col);
m_d->updateTimer->start();
}
} else {
e->ignore();
}
}
void KisVisualColorSelectorShape::mouseReleaseEvent(QMouseEvent *)
{
m_d->mousePressActive = false;
}
void KisVisualColorSelectorShape::paintEvent(QPaintEvent*)
{
......
......@@ -95,7 +95,8 @@ public Q_SLOTS:
void slotSetActiveChannels(int channel1, int channel2);
protected:
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void paintEvent(QPaintEvent*);
void resizeEvent(QResizeEvent *);
private:
......
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