#ifndef DOUBLE_INPUT_H
#define DOUBLE_INPUT_H

#include <QWidget>
#include <QSlider>
#include <QDoubleSpinBox>


class DoubleInput : public QObject {
	Q_OBJECT

	const double _min;
	const double _max;
	const int _slider_resolution;
	QDoubleSpinBox *_spin_box;
	QSlider *_slider;
	bool _propagate = true;

	double intToDouble(int value) const;
	int doubleToInt(double value) const;

private slots:
	void onSpinBoxValueChanged(double value);
	void onSliderValueChanged(int value);

public:
	DoubleInput(QObject *parent, double min, double max, double value,
				int slider_resolution=100);
	QWidget *spinBox() { return _spin_box; }
	QWidget *slider() { return _slider; }
	double value() const { return _spin_box->value(); }

signals:
	void valueChanged(double value);

public slots:
	void setValue(double value);
};


#endif