all repos — mgba @ 0cd28060e07c587ab10901ce815563a9e998f297

mGBA Game Boy Advance Emulator

src/platform/qt/Display.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_DISPLAY
 7#define QGBA_DISPLAY
 8
 9#include <QWidget>
10
11#include "MessagePainter.h"
12
13struct GBAThread;
14
15namespace QGBA {
16
17class Display : public QWidget {
18Q_OBJECT
19
20public:
21	enum class Driver {
22		QT = 0,
23#ifdef BUILD_GL
24		OPENGL = 1,
25#endif
26	};
27
28	Display(QWidget* parent = nullptr);
29
30	static Display* create(QWidget* parent = nullptr);
31	static void setDriver(Driver driver) { s_driver = driver; }
32
33	bool isAspectRatioLocked() const { return m_lockAspectRatio; }
34	bool isFiltered() const { return m_filter; }
35
36	virtual bool isDrawing() const = 0;
37
38signals:
39	void showCursor();
40	void hideCursor();
41
42public slots:
43	virtual void startDrawing(GBAThread* context) = 0;
44	virtual void stopDrawing() = 0;
45	virtual void pauseDrawing() = 0;
46	virtual void unpauseDrawing() = 0;
47	virtual void forceDraw() = 0;
48	virtual void lockAspectRatio(bool lock);
49	virtual void filter(bool filter);
50	virtual void framePosted(const uint32_t*) = 0;
51
52	void showMessage(const QString& message);
53
54protected:
55	void resizeEvent(QResizeEvent*);
56	virtual void mouseMoveEvent(QMouseEvent*) override;
57
58	MessagePainter* messagePainter() { return &m_messagePainter; }
59
60
61private:
62	static Driver s_driver;
63	static const int MOUSE_DISAPPEAR_TIMER = 1000;
64
65	MessagePainter m_messagePainter;
66	bool m_lockAspectRatio;
67	bool m_filter;
68	QTimer m_mouseTimer;
69};
70
71}
72
73#endif