#ifndef circleindicator_H
#define circleindicator_H

#include "qad_widgets_export.h"

#include <QDebug>
#include <QTime>
#include <QVariantAnimation>
#include <QWidget>


class QAD_WIDGETS_EXPORT CircleIndicator: public QWidget {
	Q_OBJECT
	Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor)
	Q_PROPERTY(QColor backColor READ backColor WRITE setBackColor)
	Q_PROPERTY(QColor borderColor READ borderColor WRITE setBorderColor)
	Q_PROPERTY(QString text READ text WRITE setText)
	Q_PROPERTY(double angleStartOffset READ angleStartOffset WRITE setAngleStartOffset)
	Q_PROPERTY(double angleGap READ angleGap WRITE setAngleGap)
	Q_PROPERTY(double barSize READ barSize WRITE setBarSize)
	Q_PROPERTY(double value READ value WRITE setValue)
	Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
	Q_PROPERTY(double maximum READ maximum WRITE setMaximum)

public:
	explicit CircleIndicator(QWidget * parent = 0);
	~CircleIndicator();

	double value() const { return m_value; }
	double minimum() const { return m_minimum; }
	double maximum() const { return m_maximum; }

	QColor backColor() const { return back_color; }
	void setBackColor(const QColor & c);

	QColor fillColor() const { return fill_color; }
	void setFillColor(const QColor & c);

	QColor borderColor() const { return border_color; }
	void setBorderColor(const QColor & c);

	QString text() const { return m_text; }
	void setText(const QString & t);

	double angleStartOffset() const { return m_angle_offset; }
	void setAngleStartOffset(double a);

	double angleGap() const { return angle_gap; }
	void setAngleGap(double a);

	double barSize() const { return bar_; }
	void setBarSize(double a);

	int heightForWidth(int) const;
	bool hasHeightForWidth() const;

private:
	void init();
	QSize minimumSizeHint() const;
	QSize sizeHint() const;
	void paintEvent(QPaintEvent *);
	void animate();

	QColor fill_color, back_color, border_color;
	QString m_text;
	QVariantAnimation anim;
	double m_value = 0., m_value_visual = 0., m_minimum = 0., m_maximum = 100.;
	double m_angle_offset = 0., angle_gap = 20., bar_ = 30.;

public slots:
	void enable() { setEnabled(true); }
	void disable() { setEnabled(false); }

	void setValue(double v);
	void setMinimum(double m);
	void setMaximum(double m);
};


#endif
