all repos — mgba @ f6f3cb5d3d8b91dd603772ea0eebb2513562a0cf

mGBA Game Boy Advance Emulator

src/platform/qt/Swatch.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_SWATCH
 7#define QGBA_SWATCH
 8
 9#include <QColor>
10#include <QWidget>
11#include <QVector>
12
13namespace QGBA {
14
15class Swatch : public QWidget {
16Q_OBJECT
17
18public:
19	Swatch(QWidget* parent = nullptr);
20
21	void setDimensions(const QSize&);
22	void setSize(int size);
23
24public slots:
25	void setColor(int index, uint16_t);
26
27signals:
28	void indexPressed(int index);
29
30protected:
31	void paintEvent(QPaintEvent*) override;
32	void mousePressEvent(QMouseEvent*) override;
33
34private:
35	int m_size = 10;
36	QVector<QColor> m_colors;
37	QPixmap m_backing;
38	QSize m_dims;
39
40	void updateFill(int index);
41};
42
43}
44
45#endif