all repos — mgba @ d662ba98de41c22489ca4d42ae3291fe043aa13e

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