all repos — mgba @ 8b19ad78098d5fd6b081c1c23058479325c63826

mGBA Game Boy Advance Emulator

Qt: Optimize palette view drawing
Jeffrey Pfau jeffrey@endrift.com
Mon, 27 Apr 2015 23:13:25 -0700
commit

8b19ad78098d5fd6b081c1c23058479325c63826

parent

57999df85e710b3172b8a74593409c6025b025d0

M src/platform/qt/PaletteView.cppsrc/platform/qt/PaletteView.cpp

@@ -41,6 +41,8 @@ for (int i = 0; i < 256; ++i) {

m_ui.bgGrid->setColor(i, palette[i]); m_ui.objGrid->setColor(i, palette[i + 256]); } + m_ui.bgGrid->update(); + m_ui.objGrid->update(); } void PaletteView::selectIndex(int index) {
M src/platform/qt/PaletteView.uisrc/platform/qt/PaletteView.ui

@@ -31,6 +31,12 @@ </spacer>

</item> <item> <widget class="QGroupBox" name="groupBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="title"> <string>Background</string> </property>

@@ -48,22 +54,13 @@ <property name="bottomMargin">

<number>0</number> </property> <item> - <widget class="QGBA::Swatch" name="bgGrid"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> + <widget class="QGBA::Swatch" name="bgGrid" native="true"> <property name="minimumSize"> <size> <width>175</width> <height>175</height> </size> </property> - <property name="text"> - <string/> - </property> </widget> </item> </layout>

@@ -101,21 +98,12 @@ <property name="bottomMargin">

<number>0</number> </property> <item> - <widget class="QGBA::Swatch" name="objGrid"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> + <widget class="QGBA::Swatch" name="objGrid" native="true"> <property name="minimumSize"> <size> <width>175</width> <height>175</height> </size> - </property> - <property name="text"> - <string/> </property> </widget> </item>

@@ -155,9 +143,9 @@ <widget class="QGroupBox" name="groupBox_3">

<property name="title"> <string>Selection</string> </property> - <layout class="QHBoxLayout" name="horizontalLayout_3"> + <layout class="QHBoxLayout" name="horizontalLayout_4"> <item> - <widget class="QGBA::Swatch" name="selected"> + <widget class="QGBA::Swatch" name="selected" native="true"> <property name="sizePolicy"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch>

@@ -169,37 +157,34 @@ <size>

<width>64</width> <height>64</height> </size> - </property> - <property name="text"> - <string/> </property> </widget> </item> <item> - <widget class="Line" name="line"> + <widget class="Line" name="line_3"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> </widget> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_5"> + <layout class="QVBoxLayout" name="verticalLayout_9"> <item> - <widget class="QLabel" name="label_3"> + <widget class="QLabel" name="label_4"> <property name="text"> <string>Red</string> </property> </widget> </item> <item> - <widget class="QLabel" name="label_2"> + <widget class="QLabel" name="label_5"> <property name="text"> <string>Green</string> </property> </widget> </item> <item> - <widget class="QLabel" name="label"> + <widget class="QLabel" name="label_6"> <property name="text"> <string>Blue</string> </property>

@@ -208,7 +193,7 @@ </item>

</layout> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_7"> + <layout class="QVBoxLayout" name="verticalLayout_10"> <property name="leftMargin"> <number>8</number> </property>

@@ -236,30 +221,30 @@ </item>

</layout> </item> <item> - <widget class="Line" name="line_2"> + <widget class="Line" name="line_4"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> </widget> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_8"> + <layout class="QVBoxLayout" name="verticalLayout_11"> <item> - <widget class="QLabel" name="label_11"> + <widget class="QLabel" name="label_14"> <property name="text"> <string>16-bit value</string> </property> </widget> </item> <item> - <widget class="QLabel" name="label_12"> + <widget class="QLabel" name="label_15"> <property name="text"> <string>Hex code</string> </property> </widget> </item> <item> - <widget class="QLabel" name="label_13"> + <widget class="QLabel" name="label_16"> <property name="text"> <string>Palette index</string> </property>

@@ -268,7 +253,7 @@ </item>

</layout> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_6"> + <layout class="QVBoxLayout" name="verticalLayout_12"> <property name="leftMargin"> <number>8</number> </property>

@@ -312,8 +297,9 @@ </widget>

<customwidgets> <customwidget> <class>QGBA::Swatch</class> - <extends>QLabel</extends> + <extends>QWidget</extends> <header>Swatch.h</header> + <container>1</container> </customwidget> </customwidgets> <resources/>
M src/platform/qt/Swatch.cppsrc/platform/qt/Swatch.cpp

@@ -11,7 +11,7 @@

using namespace QGBA; Swatch::Swatch(QWidget* parent) - : QLabel(parent) + : QWidget(parent) { m_size = 10; setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);

@@ -42,8 +42,8 @@ updateFill(index);

} void Swatch::paintEvent(QPaintEvent* event) { - setPixmap(m_backing); - QLabel::paintEvent(event); + QPainter painter(this); + painter.drawPixmap(QPoint(), m_backing); } void Swatch::mousePressEvent(QMouseEvent* event) {
M src/platform/qt/Swatch.hsrc/platform/qt/Swatch.h

@@ -7,12 +7,12 @@ #ifndef QGBA_SWATCH

#define QGBA_SWATCH #include <QColor> -#include <QLabel> +#include <QWidget> #include <QVector> namespace QGBA { -class Swatch : public QLabel { +class Swatch : public QWidget { Q_OBJECT public: