all repos — mgba @ 2743905845e0e3bc7bbb56f34bbc1be06d84ebaa

mGBA Game Boy Advance Emulator

Qt: Add backdrop editor
Vicki Pfau vi@endrift.com
Sat, 01 Jun 2019 15:52:23 -0700
commit

2743905845e0e3bc7bbb56f34bbc1be06d84ebaa

parent

c7b6c4412d772011f4e1b9ee63dd830975e30972

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

@@ -34,6 +34,14 @@

return *this; } +void ColorPicker::setColor(const QColor& color) { + m_defaultColor = color; + + QPalette palette = m_parent->palette(); + palette.setColor(m_parent->backgroundRole(), color); + m_parent->setPalette(palette); +} + bool ColorPicker::eventFilter(QObject* obj, QEvent* event) { if (event->type() != QEvent::MouseButtonRelease) { return false;
M src/platform/qt/ColorPicker.hsrc/platform/qt/ColorPicker.h

@@ -24,6 +24,9 @@

signals: void colorChanged(const QColor&); +public slots: + void setColor(const QColor&); + protected: bool eventFilter(QObject* obj, QEvent* event) override;
M src/platform/qt/FrameView.cppsrc/platform/qt/FrameView.cpp

@@ -41,7 +41,6 @@ ++m_glowFrame;

invalidateQueue(); }); - m_ui.renderedView->installEventFilter(this); m_ui.compositedView->installEventFilter(this); connect(m_ui.queue, &QListWidget::itemChanged, this, [this](QListWidgetItem* item) {

@@ -50,7 +49,7 @@ layer.enabled = item->checkState() == Qt::Checked;

if (layer.enabled) { m_disabled.remove(layer.id); } else { - m_disabled.insert(layer.id); + m_disabled.insert(layer.id); } invalidateQueue(); });

@@ -64,12 +63,20 @@ invalidateQueue();

}); connect(m_ui.magnification, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [this]() { invalidateQueue(); + }); + connect(m_ui.exportButton, &QAbstractButton::pressed, this, &FrameView::exportFrame); - QPixmap rendered = m_rendered.scaledToHeight(m_rendered.height() * m_ui.magnification->value()); - m_ui.renderedView->setPixmap(rendered); + m_backdropPicker = ColorPicker(m_ui.backdrop, QColor(0, 0, 0, 0)); + connect(&m_backdropPicker, &ColorPicker::colorChanged, this, [this](const QColor& color) { + m_overrideBackdrop = color; }); - connect(m_ui.exportButton, &QAbstractButton::pressed, this, &FrameView::exportFrame); m_controller->addFrameAction(std::bind(&FrameView::frameCallback, this, m_callbackLocker)); + + { + CoreController::Interrupter interrupter(m_controller); + refreshVl(); + } + m_controller->frameAdvance(); } FrameView::~FrameView() {

@@ -237,7 +244,12 @@ }

QPalette palette; gba->video.renderer->highlightColor = palette.color(QPalette::HighlightedText).rgb(); gba->video.renderer->highlightAmount = sin(m_glowFrame * M_PI / 30) * 64 + 64; + if (!m_overrideBackdrop.isValid()) { + QRgb backdrop = M_RGB5_TO_RGB8(gba->video.palette[0]) | 0xFF000000; + m_backdropPicker.setColor(backdrop); + } + m_vl->reset(m_vl); for (const Layer& layer : m_queue) { switch (layer.id.type) { case LayerId::SPRITE:

@@ -256,10 +268,13 @@ }

break; } } + if (m_overrideBackdrop.isValid()) { + mVideoLoggerInjectPalette(logger, 0, M_RGB8_TO_RGB5(m_overrideBackdrop.rgb())); + } if (m_ui.disableScanline->checkState() == Qt::Checked) { mVideoLoggerIgnoreAfterInjection(logger, (1 << DIRTY_PALETTE) | (1 << DIRTY_OAM) | (1 << DIRTY_REGISTER)); } else { - mVideoLoggerIgnoreAfterInjection(logger, 0); + mVideoLoggerIgnoreAfterInjection(logger, 0); } } #endif

@@ -290,7 +305,6 @@ }

bool blockSignals = m_ui.queue->blockSignals(true); QMutexLocker locker(&m_mutex); if (m_vl) { - m_vl->reset(m_vl); switch (m_controller->platform()) { #ifdef M_CORE_GBA case PLATFORM_GBA:

@@ -342,8 +356,6 @@ if (m_ui.freeze->checkState() == Qt::Checked) {

return; } m_rendered.convertFromImage(m_controller->getPixels()); - QPixmap rendered = m_rendered.scaledToHeight(m_rendered.height() * m_ui.magnification->value()); - m_ui.renderedView->setPixmap(rendered); } bool FrameView::eventFilter(QObject* obj, QEvent* event) {
M src/platform/qt/FrameView.hsrc/platform/qt/FrameView.h

@@ -16,6 +16,7 @@ #include <QSet>

#include <QTimer> #include "AssetView.h" +#include "ColorPicker.h" #include <mgba-util/vfs.h>

@@ -105,6 +106,8 @@ QSet<LayerId> m_disabled;

QPixmap m_composited; QPixmap m_rendered; mMapCacheEntry m_mapStatus[4][128 * 128] = {}; // TODO: Correct size + ColorPicker m_backdropPicker; + QColor m_overrideBackdrop; #ifdef M_CORE_GBA uint16_t m_gbaDispcnt;
M src/platform/qt/FrameView.uisrc/platform/qt/FrameView.ui

@@ -13,7 +13,7 @@ </property>

<property name="windowTitle"> <string>Inspect frame</string> </property> - <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,1,1,0" columnstretch="0,1"> + <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,1,0" columnstretch="0,1"> <item row="0" column="0"> <layout class="QHBoxLayout" name="horizontalLayout_4"> <item>

@@ -51,7 +51,63 @@ <string>Freeze frame</string>

</property> </widget> </item> - <item row="5" column="1" rowspan="2"> + <item row="3" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QFrame" name="backdrop"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="autoFillBackground"> + <bool>true</bool> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Backdrop color</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="disableScanline"> + <property name="text"> + <string>Disable scanline effects</string> + </property> + </widget> + </item> + <item row="4" column="0" rowspan="2"> + <widget class="QListWidget" name="queue"/> + </item> + <item row="6" column="0"> + <widget class="QPushButton" name="exportButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Export</string> + </property> + </widget> + </item> + <item row="0" column="1" rowspan="7"> <widget class="QScrollArea" name="compositedArea"> <property name="widgetResizable"> <bool>true</bool>

@@ -88,65 +144,6 @@ </spacer>

</item> </layout> </widget> - </widget> - </item> - <item row="0" column="1" rowspan="5"> - <widget class="QScrollArea" name="renderedArea"> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>567</width> - <height>467</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="renderedView"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </widget> - </item> - <item row="3" column="0" rowspan="3"> - <widget class="QListWidget" name="queue"/> - </item> - <item row="6" column="0"> - <widget class="QPushButton" name="exportButton"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Export</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QCheckBox" name="disableScanline"> - <property name="text"> - <string>Disable scanline effects</string> - </property> </widget> </item> </layout>