all repos — mgba @ 10b14f90d136881c6cf94d67cd809b767a8bde88

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
26signals:
27	void indexPressed(int index);
28
29protected:
30	void paintEvent(QPaintEvent*) override;
31	void mousePressEvent(QMouseEvent*) override;
32
33private:
34	int m_size = 10;
35	QVector<QColor> m_colors;
36	QPixmap m_backing;
37	QSize m_dims;
38
39	void updateFill(int index);
40};
41
42}