summaryrefslogtreecommitdiffstats
path: root/src/widget/wdisplay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widget/wdisplay.cpp')
-rw-r--r--src/widget/wdisplay.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/widget/wdisplay.cpp b/src/widget/wdisplay.cpp
index 81177b3d62..3942efa2e2 100644
--- a/src/widget/wdisplay.cpp
+++ b/src/widget/wdisplay.cpp
@@ -27,6 +27,7 @@
WDisplay::WDisplay(QWidget * parent)
: WWidget(parent),
+ m_iCurrentPixmap(0),
m_pPixmapBack(NULL),
m_bDisabledLoaded(false) {
setPositions(0);
@@ -112,7 +113,7 @@ void WDisplay::setPixmap(QVector<PaintablePointer>* pPixmaps, int iPos,
}
}
-int WDisplay::getActivePixmapIndex() const {
+int WDisplay::getPixmapForParameter(double dParameter) const {
// When there are an even number of pixmaps by convention we want a value of
// 0.5 to align to the lower of the two middle pixmaps. In Mixxx < 1.12.0 we
// accomplished this by the below formula:
@@ -149,7 +150,16 @@ int WDisplay::getActivePixmapIndex() const {
// Subtracting an epsilon prevents out of bound values at the end of the
// range and biases the middle value towards the lower of the 2 center
// pixmaps when there are an even number of pixmaps.
- return static_cast<int>(getControlParameterDisplay() * numPixmaps() - 0.00001);
+ return static_cast<int>(dParameter * numPixmaps() - 0.00001);
+}
+
+void WDisplay::onConnectedControlChanged(double dParameter, double dValue) {
+ Q_UNUSED(dValue);
+ int pixmap = getPixmapForParameter(dParameter);
+ if (pixmap != m_iCurrentPixmap) {
+ // paintEvent updates m_iCurrentPixmap.
+ update();
+ }
}
void WDisplay::paintEvent(QPaintEvent* ) {
@@ -171,7 +181,11 @@ void WDisplay::paintEvent(QPaintEvent* ) {
return;
}
- int idx = getActivePixmapIndex();
+ int idx = getPixmapForParameter(getControlParameterDisplay());
+
+ // onConnectedControlChanged uses this to detect no-ops but it does not
+ // clamp so don't clamp.
+ m_iCurrentPixmap = idx;
// Clamp active pixmap index to valid ranges.
if (idx < 0) {