0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
obs-studio/UI/double-slider.cpp
akapar 9249403c96 UI: Ignore wheelEvent for properties
Ignore wheelEvent using subclass
slider,spinbox,combobox with eventhandlers:
wheelEvent - ignore if widget is not focused,
leaveEvent - clear focus when mouse leaves event.

Use these new subclass widgets in properties
to ignore wheelEvent when scrolling.
2019-04-13 12:09:11 -04:00

36 lines
710 B
C++

#include "double-slider.hpp"
#include <cmath>
DoubleSlider::DoubleSlider(QWidget *parent) : SliderIgnoreScroll(parent)
{
connect(this, SIGNAL(valueChanged(int)),
this, SLOT(intValChanged(int)));
}
void DoubleSlider::setDoubleConstraints(double newMin, double newMax,
double newStep, double val)
{
minVal = newMin;
maxVal = newMax;
minStep = newStep;
double total = maxVal - minVal;
int intMax = int(total / minStep);
setMinimum(0);
setMaximum(intMax);
setSingleStep(1);
setDoubleVal(val);
}
void DoubleSlider::intValChanged(int val)
{
emit doubleValChanged((minVal/minStep + val) * minStep);
}
void DoubleSlider::setDoubleVal(double val)
{
setValue(lround((val - minVal) / minStep));
}