all repos — mgba @ 3227d74e4d434d497673e5a77589b674e811c969

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#pragma once
 7
 8#include <QMutex>
 9#include <QObject>
10#include <QPixmap>
11#include <QStaticText>
12#include <QTimer>
13
14namespace QGBA {
15
16class MessagePainter : public QObject {
17Q_OBJECT
18
19public:
20	MessagePainter(QObject* parent = nullptr);
21
22	void resize(const QSize& size, bool lockAspectRatio, qreal scaleFactor);
23	void paint(QPainter* painter);
24	void setScaleFactor(qreal factor);
25
26public slots:
27	void showMessage(const QString& message);
28	void clearMessage();
29
30private:
31	void redraw();
32
33	QMutex m_mutex;
34	QStaticText m_message;
35	QPixmap m_pixmap;
36	QPixmap m_pixmapBuffer;
37	QTimer m_messageTimer{this};
38	QPoint m_local;
39	QTransform m_world;
40	QFont m_messageFont;
41	qreal m_scaleFactor = 1;
42};
43
44}