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 <QWidget>
10
11#include "MessagePainter.h"
12
13struct GBAThread;
14
15namespace QGBA {
16
17class Display : public QWidget {
18Q_OBJECT
19
20public:
21 enum class Driver {
22 QT = 0,
23#ifdef BUILD_GL
24 OPENGL = 1,
25#endif
26 };
27
28 Display(QWidget* parent = nullptr);
29
30 static Display* create(QWidget* parent = nullptr);
31 static void setDriver(Driver driver) { s_driver = driver; }
32
33 bool isAspectRatioLocked() const { return m_lockAspectRatio; }
34 bool isFiltered() const { return m_filter; }
35
36signals:
37 void showCursor();
38 void hideCursor();
39
40public slots:
41 virtual void startDrawing(GBAThread* context) = 0;
42 virtual void stopDrawing() = 0;
43 virtual void pauseDrawing() = 0;
44 virtual void unpauseDrawing() = 0;
45 virtual void forceDraw() = 0;
46 virtual void lockAspectRatio(bool lock);
47 virtual void filter(bool filter);
48 virtual void framePosted(const uint32_t*) = 0;
49
50 void showMessage(const QString& message);
51
52protected:
53 void resizeEvent(QResizeEvent*);
54 virtual void mouseMoveEvent(QMouseEvent*) override;
55
56 MessagePainter* messagePainter() { return &m_messagePainter; }
57
58
59private:
60 static Driver s_driver;
61 static const int MOUSE_DISAPPEAR_TIMER = 2000;
62
63 MessagePainter m_messagePainter;
64 bool m_lockAspectRatio;
65 bool m_filter;
66 QTimer m_mouseTimer;
67};
68
69}
70
71#endif