Mercurial > hg > svgui
diff widgets/Panner.cpp @ 1324:13d9b422f7fe zoom
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 17 Sep 2018 13:51:31 +0100 |
parents | cb51d061cc25 |
children | d39db4673676 |
line wrap: on
line diff
--- a/widgets/Panner.cpp Mon Dec 12 15:18:52 2016 +0000 +++ b/widgets/Panner.cpp Mon Sep 17 13:51:31 2018 +0100 @@ -20,6 +20,8 @@ #include <QWheelEvent> #include <QPainter> +#include "WidgetScale.h" + #include <iostream> #include <cmath> @@ -62,6 +64,12 @@ void Panner::scroll(bool up) { + scroll(up, 1); +} + +void +Panner::scroll(bool up, int count) +{ float unit = m_scrollUnit; if (unit == 0.f) { unit = float(m_rectHeight) / (6 * float(height())); @@ -69,9 +77,9 @@ } if (!up) { - m_rectY += unit; + m_rectY += unit * float(count); } else { - m_rectY -= unit; + m_rectY -= unit * float(count); } normalise(); @@ -132,7 +140,8 @@ void Panner::wheelEvent(QWheelEvent *e) { - scroll(e->delta() > 0); + int delta = m_wheelCounter.count(e); + scroll(delta > 0, abs(delta)); } void @@ -156,9 +165,13 @@ QColor bg(palette().background().color()); bg.setAlpha(m_backgroundAlpha); - paint.setPen(palette().dark().color()); + int penWidth = WidgetScale::scalePixelSize(1); + if (penWidth < 1) penWidth = 1; + paint.setPen(QPen(palette().dark().color(), penWidth)); + paint.setBrush(bg); - paint.drawRect(0, 0, width()-1, height()-1); + paint.drawRect(penWidth/2, penWidth/2, + width()-penWidth/2-1, height()-penWidth/2-1); QColor hl(m_thumbColour); hl.setAlpha(m_thumbAlpha);