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