Skip to content

Commit

Permalink
fix #278968: improve mixer sliders mouse dragging
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrio95 committed Dec 3, 2018
1 parent 116866d commit 1624f15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions awl/styledslider.cpp
Expand Up @@ -75,7 +75,7 @@ void StyledSlider::mousePressEvent(QMouseEvent* e)
{
draggingMouse = true;
mouseDownPos = e->pos();
lastMousePos = mouseDownPos;
mouseDownVal = _value;
emit(sliderPressed());
}

Expand All @@ -97,13 +97,12 @@ void StyledSlider::mouseMoveEvent(QMouseEvent* e)
{
if (draggingMouse) {
QPoint p = e->pos();
double dPixY = p.y() - lastMousePos.y();
double dPixY = p.y() - mouseDownPos.y();
double barLength = height() - (_margin * 2);
double dy = dPixY * (_maxValue - _minValue) / barLength;

double val = qBound(_minValue, _value - dy + 0.5, _maxValue);
double val = qBound(_minValue, mouseDownVal - dy, _maxValue);

lastMousePos = p;
setValue(val);
update();
}
Expand Down
2 changes: 1 addition & 1 deletion awl/styledslider.h
Expand Up @@ -48,7 +48,7 @@ class StyledSlider : public QWidget

bool draggingMouse;
QPoint mouseDownPos;
QPoint lastMousePos;
double mouseDownVal;

QIcon _sliderHeadIcon;

Expand Down

0 comments on commit 1624f15

Please sign in to comment.