all repos — mgba @ e17e4fd19003209ff9db1f0ac1394e463c7b4a47

mGBA Game Boy Advance Emulator

src/platform/qt/MessagePainter.h (view raw)

 1/* Copyright (c) 2013-2015 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef QGBA_MESSAGE_PAINTER
 7#define QGBA_MESSAGE_PAINTER
 8
 9#include <QMutex>
10#include <QObject>
11#include <QPixmap>
12#include <QStaticText>
13#include <QTimer>
14
15namespace QGBA {
16
17class MessagePainter : public QObject {
18Q_OBJECT
19
20public:
21	MessagePainter(QObject* parent = nullptr);
22
23	void resize(const QSize& size, bool lockAspectRatio, qreal scaleFactor);
24	void paint(QPainter* painter);
25	void setScaleFactor(qreal factor);
26
27public slots:
28	void showMessage(const QString& message);
29	void clearMessage();
30
31private:
32	void redraw();
33
34	QMutex m_mutex;
35	QStaticText m_message;
36	QPixmap m_pixmap;
37	QPixmap m_pixmapBuffer;
38	QTimer m_messageTimer;
39	QPoint m_local;
40	QTransform m_world;
41	QFont m_messageFont;
42	qreal m_scaleFactor;
43};
44
45}
46
47#endif