/***********************************************************************
 *
 * Copyright (C) 2010, 2011, 2015, 2016 Graeme Gott <graeme@gottcode.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 ***********************************************************************/

#ifndef MESSAGE_H
#define MESSAGE_H

#include "graphics_layer.h"

#include <QColor>
class QOpenGLTexture;
class QTimeLine;
class QTimer;
class QWidget;

class Message : public QObject
{
	Q_OBJECT

public:
	Message(QWidget* parent);
	~Message();

	void draw() const;
	void setText(const QString& text);
	void setViewport(const QSize& size);
	void setVisible(bool visible, bool stay = true);

public slots:
	void hide();
	void show();

private:
	void cleanup();
	void updateVerts();

private slots:
	void fade(int frame);

private:
	QWidget* m_parent;
	QTimer* m_hide_timer;
	QTimeLine* m_fade_timer;
	QOpenGLTexture* m_image;
	VertexArray m_array;

	QString m_text;
	QSize m_size;
	QSize m_viewport;
	bool m_visible;

	QColor m_color;
};

#endif
