all repos — mgba @ ded463ea25eb4752a612cbe0c53a578ec3b4666f

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