mirror of https://github.com/mgba-emu/mgba.git
Qt: Optimize palette view drawing
This commit is contained in:
parent
57999df85e
commit
8b19ad7809
|
@ -41,6 +41,8 @@ void PaletteView::updatePalette() {
|
||||||
m_ui.bgGrid->setColor(i, palette[i]);
|
m_ui.bgGrid->setColor(i, palette[i]);
|
||||||
m_ui.objGrid->setColor(i, palette[i + 256]);
|
m_ui.objGrid->setColor(i, palette[i + 256]);
|
||||||
}
|
}
|
||||||
|
m_ui.bgGrid->update();
|
||||||
|
m_ui.objGrid->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaletteView::selectIndex(int index) {
|
void PaletteView::selectIndex(int index) {
|
||||||
|
|
|
@ -31,6 +31,12 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Background</string>
|
<string>Background</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -48,22 +54,13 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGBA::Swatch" name="bgGrid">
|
<widget class="QGBA::Swatch" name="bgGrid" native="true">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>175</width>
|
<width>175</width>
|
||||||
<height>175</height>
|
<height>175</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -101,22 +98,13 @@
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGBA::Swatch" name="objGrid">
|
<widget class="QGBA::Swatch" name="objGrid" native="true">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>175</width>
|
<width>175</width>
|
||||||
<height>175</height>
|
<height>175</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -155,9 +143,9 @@
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Selection</string>
|
<string>Selection</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGBA::Swatch" name="selected">
|
<widget class="QGBA::Swatch" name="selected" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -170,36 +158,33 @@
|
||||||
<height>64</height>
|
<height>64</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line">
|
<widget class="Line" name="line_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Red</string>
|
<string>Red</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Green</string>
|
<string>Green</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Blue</string>
|
<string>Blue</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -208,7 +193,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>8</number>
|
<number>8</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -236,30 +221,30 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_2">
|
<widget class="Line" name="line_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_11">
|
<widget class="QLabel" name="label_14">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>16-bit value</string>
|
<string>16-bit value</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_12">
|
<widget class="QLabel" name="label_15">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Hex code</string>
|
<string>Hex code</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_13">
|
<widget class="QLabel" name="label_16">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Palette index</string>
|
<string>Palette index</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -268,7 +253,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>8</number>
|
<number>8</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -312,8 +297,9 @@
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QGBA::Swatch</class>
|
<class>QGBA::Swatch</class>
|
||||||
<extends>QLabel</extends>
|
<extends>QWidget</extends>
|
||||||
<header>Swatch.h</header>
|
<header>Swatch.h</header>
|
||||||
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
using namespace QGBA;
|
using namespace QGBA;
|
||||||
|
|
||||||
Swatch::Swatch(QWidget* parent)
|
Swatch::Swatch(QWidget* parent)
|
||||||
: QLabel(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
m_size = 10;
|
m_size = 10;
|
||||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
|
@ -42,8 +42,8 @@ void Swatch::setColor(int index, uint16_t color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Swatch::paintEvent(QPaintEvent* event) {
|
void Swatch::paintEvent(QPaintEvent* event) {
|
||||||
setPixmap(m_backing);
|
QPainter painter(this);
|
||||||
QLabel::paintEvent(event);
|
painter.drawPixmap(QPoint(), m_backing);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Swatch::mousePressEvent(QMouseEvent* event) {
|
void Swatch::mousePressEvent(QMouseEvent* event) {
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
#define QGBA_SWATCH
|
#define QGBA_SWATCH
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QLabel>
|
#include <QWidget>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
namespace QGBA {
|
namespace QGBA {
|
||||||
|
|
||||||
class Swatch : public QLabel {
|
class Swatch : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue