mirror of https://github.com/mgba-emu/mgba.git
Qt: Add backdrop editor
This commit is contained in:
parent
c7b6c4412d
commit
2743905845
|
@ -34,6 +34,14 @@ ColorPicker& ColorPicker::operator=(const ColorPicker& other) {
|
|||
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;
|
||||
|
|
|
@ -24,6 +24,9 @@ public:
|
|||
signals:
|
||||
void colorChanged(const QColor&);
|
||||
|
||||
public slots:
|
||||
void setColor(const QColor&);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ FrameView::FrameView(std::shared_ptr<CoreController> controller, QWidget* parent
|
|||
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 @@ FrameView::FrameView(std::shared_ptr<CoreController> controller, QWidget* parent
|
|||
if (layer.enabled) {
|
||||
m_disabled.remove(layer.id);
|
||||
} else {
|
||||
m_disabled.insert(layer.id);
|
||||
m_disabled.insert(layer.id);
|
||||
}
|
||||
invalidateQueue();
|
||||
});
|
||||
|
@ -64,12 +63,20 @@ FrameView::FrameView(std::shared_ptr<CoreController> controller, QWidget* parent
|
|||
});
|
||||
connect(m_ui.magnification, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [this]() {
|
||||
invalidateQueue();
|
||||
|
||||
QPixmap rendered = m_rendered.scaledToHeight(m_rendered.height() * m_ui.magnification->value());
|
||||
m_ui.renderedView->setPixmap(rendered);
|
||||
});
|
||||
connect(m_ui.exportButton, &QAbstractButton::pressed, this, &FrameView::exportFrame);
|
||||
|
||||
m_backdropPicker = ColorPicker(m_ui.backdrop, QColor(0, 0, 0, 0));
|
||||
connect(&m_backdropPicker, &ColorPicker::colorChanged, this, [this](const QColor& color) {
|
||||
m_overrideBackdrop = color;
|
||||
});
|
||||
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 @@ void FrameView::injectGBA() {
|
|||
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 @@ void FrameView::injectGBA() {
|
|||
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 @@ void FrameView::invalidateQueue(const QSize& dims) {
|
|||
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 @@ void FrameView::updateRendered() {
|
|||
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) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <QTimer>
|
||||
|
||||
#include "AssetView.h"
|
||||
#include "ColorPicker.h"
|
||||
|
||||
#include <mgba-util/vfs.h>
|
||||
|
||||
|
@ -105,6 +106,8 @@ private:
|
|||
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;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<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 @@
|
|||
</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>
|
||||
|
@ -90,65 +146,6 @@
|
|||
</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>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
Loading…
Reference in New Issue