all repos — mgba @ 9b0393d50ffcd27c487740098c3c0bb72b16529f

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