all repos — mgba @ 3c5a9258a72ef9b7f5904783857c42232064119d

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#pragma once
 7
 8#include <QColor>
 9#include <QWidget>
10#include <QVector>
11
12namespace QGBA {
13
14class Swatch : public QWidget {
15Q_OBJECT
16
17public:
18	Swatch(QWidget* parent = nullptr);
19
20	void setDimensions(const QSize&);
21	void setSize(int size);
22
23public slots:
24	void setColor(int index, uint16_t);
25	void setColor(int index, uint32_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}