all repos — mgba @ 6e40b38b6350fc6d833317b788a3bfbc4c3683b6

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