all repos — mgba @ c689e32856c7564c7a7a28a25d2776e1a65a7f21

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