all repos — mgba @ 5436d2576ffd0dac6254963e4a8d656e445ef078

mGBA Game Boy Advance Emulator

src/platform/qt/FrameView.h (view raw)

 1/* Copyright (c) 2013-2019 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 "ui_FrameView.h"
 9
10#include <QBitmap>
11#include <QImage>
12#include <QList>
13#include <QPixmap>
14#include <QSet>
15#include <QTimer>
16
17#include "AssetView.h"
18
19#include <memory>
20
21namespace QGBA {
22
23class CoreController;
24
25class FrameView : public AssetView {
26Q_OBJECT
27
28public:
29	FrameView(std::shared_ptr<CoreController> controller, QWidget* parent = nullptr);
30
31public slots:
32	void selectLayer(const QPointF& coord);
33	void disableLayer(const QPointF& coord);
34
35protected:
36#ifdef M_CORE_GBA
37	void updateTilesGBA(bool force) override;
38#endif
39#ifdef M_CORE_GB
40	void updateTilesGB(bool force) override;
41#endif
42
43	bool eventFilter(QObject* obj, QEvent* event) override;
44
45private slots:
46	void invalidateQueue(const QSize& dims = QSize());
47	void updateRendered();
48
49private:
50	struct LayerId {
51		enum {
52			NONE = 0,
53			BACKGROUND,
54			WINDOW,
55			SPRITE,
56			BACKDROP
57		} type = NONE;
58		int index = -1;
59
60		bool operator==(const LayerId& other) const { return other.type == type && other.index == index; }
61		operator uint() const { return (type << 8) | index; }
62		QString readable() const;
63	};
64
65	struct Layer {
66		LayerId id;
67		bool enabled;
68		QPixmap image;
69		QRegion mask;
70		QPointF location;
71		bool repeats;
72	};
73
74	bool lookupLayer(const QPointF& coord, Layer*&);
75
76	Ui::FrameView m_ui;
77
78	LayerId m_active{};
79
80	int m_glowFrame;
81	QTimer m_glowTimer;
82
83	QSize m_dims;
84	QList<Layer> m_queue;
85	QSet<LayerId> m_disabled;
86	QPixmap m_composited;
87	QPixmap m_rendered;
88	mMapCacheEntry m_mapStatus[4][128 * 128] = {}; // TODO: Correct size
89};
90
91}