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
48signals:
49 void showCursor();
50 void hideCursor();
51
52public slots:
53 virtual void startDrawing(mCoreThread* context) = 0;
54 virtual void stopDrawing() = 0;
55 virtual void pauseDrawing() = 0;
56 virtual void unpauseDrawing() = 0;
57 virtual void forceDraw() = 0;
58 virtual void lockAspectRatio(bool lock);
59 virtual void lockIntegerScaling(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
73private:
74 static Driver s_driver;
75 static const int MOUSE_DISAPPEAR_TIMER = 1000;
76
77 MessagePainter m_messagePainter;
78 bool m_lockAspectRatio;
79 bool m_lockIntegerScaling;
80 bool m_filter;
81 QTimer m_mouseTimer;
82};
83
84}
85
86#endif