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 isFiltered() const { return m_filter; }
42
43 virtual bool isDrawing() const = 0;
44 virtual bool supportsShaders() const = 0;
45 virtual VideoShader* shaders() = 0;
46
47 QSize viewportSize();
48
49signals:
50 void showCursor();
51 void hideCursor();
52
53public slots:
54 virtual void startDrawing(mCoreThread* context) = 0;
55 virtual void stopDrawing() = 0;
56 virtual void pauseDrawing() = 0;
57 virtual void unpauseDrawing() = 0;
58 virtual void forceDraw() = 0;
59 virtual void lockAspectRatio(bool lock);
60 virtual void filter(bool filter);
61 virtual void framePosted(const uint32_t*) = 0;
62 virtual void setShaders(struct VDir*) = 0;
63 virtual void clearShaders() = 0;
64
65 void showMessage(const QString& message);
66
67protected:
68 virtual void resizeEvent(QResizeEvent*) override;
69 virtual void mouseMoveEvent(QMouseEvent*) override;
70
71 MessagePainter* messagePainter() { return &m_messagePainter; }
72
73 void setSystemDimensions(int width, int height);
74
75private:
76 static Driver s_driver;
77 static const int MOUSE_DISAPPEAR_TIMER = 1000;
78
79 MessagePainter m_messagePainter;
80 bool m_lockAspectRatio;
81 bool m_filter;
82 QTimer m_mouseTimer;
83 int m_coreWidth;
84 int m_coreHeight;
85};
86
87}
88
89#endif