all repos — mgba @ 6646baa3b3c07f123059c9d101d167444efb101a

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;
14struct VDir;
15struct VideoShader;
16
17namespace QGBA {
18
19class Display : public QWidget {
20Q_OBJECT
21
22public:
23	enum class Driver {
24		QT = 0,
25#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
26		OPENGL = 1,
27#endif
28#ifdef BUILD_GL
29		OPENGL1 = 2,
30#endif
31	};
32
33	Display(QWidget* parent = nullptr);
34
35	static Display* create(QWidget* parent = nullptr);
36	static void setDriver(Driver driver) { s_driver = driver; }
37
38	bool isAspectRatioLocked() const { return m_lockAspectRatio; }
39	bool isFiltered() const { return m_filter; }
40
41	virtual bool isDrawing() const = 0;
42	virtual bool supportsShaders() const = 0;
43	virtual VideoShader* shaders() = 0;
44
45signals:
46	void showCursor();
47	void hideCursor();
48
49public slots:
50	virtual void startDrawing(GBAThread* context) = 0;
51	virtual void stopDrawing() = 0;
52	virtual void pauseDrawing() = 0;
53	virtual void unpauseDrawing() = 0;
54	virtual void forceDraw() = 0;
55	virtual void lockAspectRatio(bool lock);
56	virtual void filter(bool filter);
57	virtual void framePosted(const uint32_t*) = 0;
58	virtual void setShaders(struct VDir*) = 0;
59	virtual void clearShaders() = 0;
60
61	void showMessage(const QString& message);
62
63protected:
64	virtual void resizeEvent(QResizeEvent*) override;
65	virtual void mouseMoveEvent(QMouseEvent*) override;
66
67	MessagePainter* messagePainter() { return &m_messagePainter; }
68
69private:
70	static Driver s_driver;
71	static const int MOUSE_DISAPPEAR_TIMER = 1000;
72
73	MessagePainter m_messagePainter;
74	bool m_lockAspectRatio;
75	bool m_filter;
76	QTimer m_mouseTimer;
77};
78
79}
80
81#endif