#ifndef SHSTHERMOMETER_H
#define SHSTHERMOMETER_H

#include <QWidget>
#include <QMouseEvent>
#include <QPropertyAnimation>
#include <QDebug>
#include <QPainterPath>
#include "shs_widgets_export.h"

QT_BEGIN_NAMESPACE

class SHS_WIDGETS_EXPORT SHSThermometer: public QWidget
{
	Q_OBJECT
	Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly)
	Q_PROPERTY(double value READ value WRITE setValue)
	Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
	Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
	Q_PROPERTY(double gradMinimum READ gradMinimum WRITE setGradMinimum)
	Q_PROPERTY(double gradMaximum READ gradMaximum WRITE setGradMaximum)
	Q_PROPERTY(double coldValue READ coldValue WRITE setColdValue)
	Q_PROPERTY(double normalValue READ normalValue WRITE setNormalValue)
	Q_PROPERTY(double hotValue READ hotValue WRITE setHotValue)
	Q_PROPERTY(float h__anim READ g_anim WRITE s_anim DESIGNABLE false)
public:
	explicit SHSThermometer(QWidget * parent = 0);
	~SHSThermometer();
	
	bool readOnly() const {return ro_;}
	double value() const {return val_;}
	double minimum() const {return min_;}
	double maximum() const {return max_;}
	double gradMinimum() const {return gmin_;}
	double gradMaximum() const {return gmax_;}
	
	double coldValue() const {return m_coldValue;}
	double normalValue() const {return m_normalValue;}
	double hotValue() const {return m_hotValue;}
	void setColdValue(double v);
	void setNormalValue(double v);
	void setHotValue(double v);

private:
	QSize sizeHint() const {return QSize(120, 300);}
	QSize minimumSizeHint() const {return QSize(30, 60);}
	void resizeEvent(QResizeEvent * );
	void paintEvent(QPaintEvent * );
	void mouseMoveEvent(QMouseEvent * e);
	void mousePressEvent(QMouseEvent * e);
	void mouseReleaseEvent(QMouseEvent * e);
	void calcColor();
	double g_anim() const {return ap_;}
	void animate();
	
	QPainterPath ppath;
	QColor color;
	QPropertyAnimation anim;
	double val_, min_, max_, gmin_, gmax_, ap_;
	double m_coldValue = 0., m_normalValue = 20., m_hotValue = 40.;
	bool ro_, track_;

private slots:
	void s_anim(double v);

public slots:
	void enable() {setEnabled(true);}
	void disable() {setEnabled(false);}
	void setReadOnly(bool y);
	
	void setValue(double v);
	void setMinimum(double v);
	void setMaximum(double v);
	void setGradMinimum(double v);
	void setGradMaximum(double v);
	
signals:
	void valueChanged(double v);

};

QT_END_NAMESPACE

#endif // SHSTHERMOMETER_H
