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;
22
23class Display : public QWidget {
24Q_OBJECT
25
26public:
27 enum class Driver {
28 QT = 0,
29#if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(USE_EPOXY)
30 OPENGL = 1,
31#endif
32#ifdef BUILD_GL
33 OPENGL1 = 2,
34#endif
35 };
36
37 Display(QWidget* parent = nullptr);
38
39 static Display* create(QWidget* parent = nullptr);
40 static void setDriver(Driver driver) { s_driver = driver; }
41
42 bool isAspectRatioLocked() const { return m_lockAspectRatio; }
43 bool isIntegerScalingLocked() const { return m_lockIntegerScaling; }
44 bool isFiltered() const { return m_filter; }
45
46 virtual void startDrawing(std::shared_ptr<CoreController>) = 0;
47 virtual bool isDrawing() const = 0;
48 virtual bool supportsShaders() const = 0;
49 virtual VideoShader* shaders() = 0;
50
51signals:
52 void showCursor();
53 void hideCursor();
54
55public slots:
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() = 0;
64 virtual void setShaders(struct VDir*) = 0;
65 virtual void clearShaders() = 0;
66 virtual void resizeContext() = 0;
67
68 void showMessage(const QString& message);
69
70protected:
71 virtual void resizeEvent(QResizeEvent*) override;
72 virtual void mouseMoveEvent(QMouseEvent*) override;
73
74 MessagePainter* messagePainter() { return &m_messagePainter; }
75
76private:
77 static Driver s_driver;
78 static const int MOUSE_DISAPPEAR_TIMER = 1000;
79
80 MessagePainter m_messagePainter;
81 bool m_lockAspectRatio = false;
82 bool m_lockIntegerScaling = false;
83 bool m_filter = false;
84 QTimer m_mouseTimer;
85};
86
87}