obs-studio/UI/double-slider.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
658 B
C++
Raw Normal View History

2015-03-18 01:33:21 +00:00
#include "double-slider.hpp"
#include <cmath>
DoubleSlider::DoubleSlider(QWidget *parent) : SliderIgnoreScroll(parent)
2015-03-18 01:33:21 +00:00
{
connect(this, &DoubleSlider::valueChanged, [this](int val) {
emit doubleValChanged((minVal / minStep + val) * minStep);
});
2015-03-18 01:33:21 +00:00
}
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::setDoubleVal(double val)
{
setValue(lround((val - minVal) / minStep));
2015-03-18 01:33:21 +00:00
}