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