mirror of https://github.com/mgba-emu/mgba.git
Qt: Add copy and QoL improvements to graphic views (closes #1541)
This commit is contained in:
parent
28151ee65c
commit
038d21debd
1
CHANGES
1
CHANGES
|
@ -78,6 +78,7 @@ Misc:
|
||||||
- Qt: Remove What's This icon from dialogs
|
- Qt: Remove What's This icon from dialogs
|
||||||
- CMake: Don't use libzip on embedded platforms (fixes mgba.io/i/1527)
|
- CMake: Don't use libzip on embedded platforms (fixes mgba.io/i/1527)
|
||||||
- Qt: Printer quality of life improvements (fixes mgba.io/i/1540)
|
- Qt: Printer quality of life improvements (fixes mgba.io/i/1540)
|
||||||
|
- Qt: Add copy and QoL improvements to graphic views (closes mgba.io/i/1541)
|
||||||
|
|
||||||
0.7.3: (2019-09-15)
|
0.7.3: (2019-09-15)
|
||||||
Emulation fixes:
|
Emulation fixes:
|
||||||
|
|
|
@ -116,6 +116,9 @@ void AssetTile::selectIndex(int index) {
|
||||||
m_ui.preview->setColor(i ^ flip, data[i]);
|
m_ui.preview->setColor(i ^ flip, data[i]);
|
||||||
}
|
}
|
||||||
m_ui.preview->update();
|
m_ui.preview->update();
|
||||||
|
|
||||||
|
QImage tile(reinterpret_cast<const uchar*>(data), 8, 8, QImage::Format_ARGB32);
|
||||||
|
m_activeTile = tile.rgbSwapped();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetTile::setFlip(bool h, bool v) {
|
void AssetTile::setFlip(bool h, bool v) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AssetTile(QWidget* parent = nullptr);
|
AssetTile(QWidget* parent = nullptr);
|
||||||
void setController(std::shared_ptr<CoreController>);
|
void setController(std::shared_ptr<CoreController>);
|
||||||
|
QImage activeTile() const { return m_activeTile; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setPalette(int);
|
void setPalette(int);
|
||||||
|
@ -48,6 +49,7 @@ private:
|
||||||
bool m_flipV = false;
|
bool m_flipV = false;
|
||||||
|
|
||||||
QMap<QString, QLabel*> m_customProperties;
|
QMap<QString, QLabel*> m_customProperties;
|
||||||
|
QImage m_activeTile;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
#include <mgba/internal/gb/memory.h>
|
#include <mgba/internal/gb/memory.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
|
@ -88,11 +90,19 @@ MapView::MapView(std::shared_ptr<CoreController> controller, QWidget* parent)
|
||||||
});
|
});
|
||||||
group->addButton(button);
|
group->addButton(button);
|
||||||
}
|
}
|
||||||
#ifdef USE_PNG
|
|
||||||
connect(m_ui.exportButton, &QAbstractButton::clicked, this, &MapView::exportMap);
|
connect(m_ui.exportButton, &QAbstractButton::clicked, this, &MapView::exportMap);
|
||||||
#else
|
connect(m_ui.copyButton, &QAbstractButton::clicked, this, &MapView::copyMap);
|
||||||
m_ui.exportButton->setVisible(false);
|
|
||||||
#endif
|
QAction* exportAction = new QAction(this);
|
||||||
|
exportAction->setShortcut(QKeySequence::Save);
|
||||||
|
connect(exportAction, &QAction::triggered, this, &MapView::exportMap);
|
||||||
|
addAction(exportAction);
|
||||||
|
|
||||||
|
QAction* copyAction = new QAction(this);
|
||||||
|
copyAction->setShortcut(QKeySequence::Copy);
|
||||||
|
connect(copyAction, &QAction::triggered, this, &MapView::copyMap);
|
||||||
|
addAction(copyAction);
|
||||||
|
|
||||||
m_ui.map->installEventFilter(this);
|
m_ui.map->installEventFilter(this);
|
||||||
m_ui.tile->addCustomProperty("mapAddr", tr("Map Addr."));
|
m_ui.tile->addCustomProperty("mapAddr", tr("Map Addr."));
|
||||||
m_ui.tile->addCustomProperty("flip", tr("Mirror"));
|
m_ui.tile->addCustomProperty("flip", tr("Mirror"));
|
||||||
|
@ -211,7 +221,7 @@ void MapView::updateTilesGBA(bool force) {
|
||||||
mBitmapCacheCleanRow(bitmapCache, m_bitmapStatus, j);
|
mBitmapCacheCleanRow(bitmapCache, m_bitmapStatus, j);
|
||||||
memcpy(static_cast<void*>(&bgBits[width * j * 4]), mBitmapCacheGetRow(bitmapCache, j), width * 4);
|
memcpy(static_cast<void*>(&bgBits[width * j * 4]), mBitmapCacheGetRow(bitmapCache, j), width * 4);
|
||||||
}
|
}
|
||||||
m_rawMap = m_rawMap.rgbSwapped();
|
m_rawMap = m_rawMap.convertToFormat(QImage::Format_RGB32).rgbSwapped();
|
||||||
} else {
|
} else {
|
||||||
mMapCache* mapCache = mMapCacheSetGetPointer(&m_cacheSet->maps, m_map);
|
mMapCache* mapCache = mMapCacheSetGetPointer(&m_cacheSet->maps, m_map);
|
||||||
int tilesW = 1 << mMapCacheSystemInfoGetTilesWide(mapCache->sysConfig);
|
int tilesW = 1 << mMapCacheSystemInfoGetTilesWide(mapCache->sysConfig);
|
||||||
|
@ -242,23 +252,18 @@ void MapView::updateTilesGB(bool force) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_PNG
|
|
||||||
void MapView::exportMap() {
|
void MapView::exportMap() {
|
||||||
QString filename = GBAApp::app()->getSaveFileName(this, tr("Export map"),
|
QString filename = GBAApp::app()->getSaveFileName(this, tr("Export map"),
|
||||||
tr("Portable Network Graphics (*.png)"));
|
tr("Portable Network Graphics (*.png)"));
|
||||||
VFile* vf = VFileDevice::open(filename, O_WRONLY | O_CREAT | O_TRUNC);
|
if (filename.isNull()) {
|
||||||
if (!vf) {
|
|
||||||
LOG(QT, ERROR) << tr("Failed to open output PNG file: %1").arg(filename);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreController::Interrupter interrupter(m_controller);
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
png_structp png = PNGWriteOpen(vf);
|
m_rawMap.save(filename, "PNG");
|
||||||
png_infop info = PNGWriteHeaderA(png, m_rawMap.width(), m_rawMap.height());
|
}
|
||||||
|
|
||||||
QImage map = m_rawMap.rgbSwapped();
|
void MapView::copyMap() {
|
||||||
PNGWritePixelsA(png, map.width(), map.height(), map.bytesPerLine() / 4, static_cast<const void*>(map.constBits()));
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
PNGWriteClose(png, info);
|
GBAApp::app()->clipboard()->setImage(m_rawMap);
|
||||||
vf->close(vf);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
|
@ -21,10 +21,9 @@ Q_OBJECT
|
||||||
public:
|
public:
|
||||||
MapView(std::shared_ptr<CoreController> controller, QWidget* parent = nullptr);
|
MapView(std::shared_ptr<CoreController> controller, QWidget* parent = nullptr);
|
||||||
|
|
||||||
#ifdef USE_PNG
|
|
||||||
public slots:
|
public slots:
|
||||||
void exportMap();
|
void exportMap();
|
||||||
#endif
|
void copyMap();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void selectMap(int);
|
void selectMap(int);
|
||||||
|
|
|
@ -13,38 +13,7 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Maps</string>
|
<string>Maps</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0">
|
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0">
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QGBA::AssetTile" name="tile"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QGBA::AssetInfo" name="bgInfo">
|
|
||||||
<property name="title">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0">
|
|
||||||
<widget class="QPushButton" name="exportButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Export</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<layout class="QVBoxLayout" name="bgLayout">
|
<layout class="QVBoxLayout" name="bgLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -79,7 +48,7 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" rowspan="5" colspan="2">
|
<item row="1" column="1" rowspan="6" colspan="2">
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -133,21 +102,59 @@
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QGBA::AssetTile" name="tile"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QPushButton" name="exportButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QGBA::AssetInfo" name="bgInfo">
|
||||||
|
<property name="title">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QPushButton" name="copyButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
|
||||||
<class>QGBA::AssetInfo</class>
|
|
||||||
<extends>QGroupBox</extends>
|
|
||||||
<header>AssetInfo.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QGBA::AssetTile</class>
|
<class>QGBA::AssetTile</class>
|
||||||
<extends>QGroupBox</extends>
|
<extends>QGroupBox</extends>
|
||||||
<header>AssetTile.h</header>
|
<header>AssetTile.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>QGBA::AssetInfo</class>
|
||||||
|
<extends>QGroupBox</extends>
|
||||||
|
<header>AssetInfo.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include "CoreController.h"
|
#include "CoreController.h"
|
||||||
#include "GBAApp.h"
|
#include "GBAApp.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
@ -52,6 +54,17 @@ ObjView::ObjView(std::shared_ptr<CoreController> controller, QWidget* parent)
|
||||||
updateTiles(true);
|
updateTiles(true);
|
||||||
});
|
});
|
||||||
connect(m_ui.exportButton, &QAbstractButton::clicked, this, &ObjView::exportObj);
|
connect(m_ui.exportButton, &QAbstractButton::clicked, this, &ObjView::exportObj);
|
||||||
|
connect(m_ui.copyButton, &QAbstractButton::clicked, this, &ObjView::copyObj);
|
||||||
|
|
||||||
|
QAction* exportAction = new QAction(this);
|
||||||
|
exportAction->setShortcut(QKeySequence::Save);
|
||||||
|
connect(exportAction, &QAction::triggered, this, &ObjView::exportObj);
|
||||||
|
addAction(exportAction);
|
||||||
|
|
||||||
|
QAction* copyAction = new QAction(this);
|
||||||
|
copyAction->setShortcut(QKeySequence::Copy);
|
||||||
|
connect(copyAction, &QAction::triggered, this, &ObjView::copyObj);
|
||||||
|
addAction(copyAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjView::selectObj(int obj) {
|
void ObjView::selectObj(int obj) {
|
||||||
|
@ -203,7 +216,15 @@ void ObjView::updateTilesGB(bool force) {
|
||||||
void ObjView::exportObj() {
|
void ObjView::exportObj() {
|
||||||
QString filename = GBAApp::app()->getSaveFileName(this, tr("Export sprite"),
|
QString filename = GBAApp::app()->getSaveFileName(this, tr("Export sprite"),
|
||||||
tr("Portable Network Graphics (*.png)"));
|
tr("Portable Network Graphics (*.png)"));
|
||||||
|
if (filename.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
CoreController::Interrupter interrupter(m_controller);
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
QImage obj = compositeObj(m_objInfo);
|
QImage obj = compositeObj(m_objInfo);
|
||||||
obj.save(filename, "PNG");
|
obj.save(filename, "PNG");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ObjView::copyObj() {
|
||||||
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
|
GBAApp::app()->clipboard()->setImage(compositeObj(m_objInfo));
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void exportObj();
|
void exportObj();
|
||||||
|
void copyObj();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void selectObj(int);
|
void selectObj(int);
|
||||||
|
|
|
@ -6,80 +6,170 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>454</width>
|
<width>641</width>
|
||||||
<height>385</height>
|
<height>470</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Sprites</string>
|
<string>Sprites</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,1">
|
<layout class="QGridLayout" name="gridLayout" columnstretch="0,0,1,1">
|
||||||
<item row="0" column="2" rowspan="4">
|
<item row="2" column="0">
|
||||||
<widget class="QFrame" name="frame">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="frameShape">
|
<property name="title">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<string>Geometry</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="margin">
|
<item>
|
||||||
<number>0</number>
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Position</string>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0" alignment="Qt::AlignHCenter|Qt::AlignVCenter">
|
</widget>
|
||||||
<widget class="QGBA::TilePainter" name="tiles" native="true">
|
</item>
|
||||||
<property name="sizePolicy">
|
<item>
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<spacer name="horizontalSpacer">
|
||||||
<horstretch>0</horstretch>
|
<property name="orientation">
|
||||||
<verstretch>0</verstretch>
|
<enum>Qt::Horizontal</enum>
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="x">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>8</width>
|
<width>20</width>
|
||||||
<height>8</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>0</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="tileId_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>, </string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="y">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>0</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Dimensions</string>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="magnification">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="sizePolicy">
|
<property name="orientation">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<enum>Qt::Horizontal</enum>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="suffix">
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="w">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>8</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="tileId_5">
|
||||||
|
<property name="text">
|
||||||
<string>×</string>
|
<string>×</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
<property name="alignment">
|
||||||
<number>1</number>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>8</number>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="h">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Magnification</string>
|
<string>8</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" rowspan="5">
|
||||||
|
<widget class="QGBA::AssetTile" name="tile">
|
||||||
|
<property name="title">
|
||||||
|
<string>Tile</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="2">
|
||||||
<widget class="QPushButton" name="exportButton">
|
<widget class="QPushButton" name="exportButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Export</string>
|
<string>Export</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
<item row="3" column="0" rowspan="2">
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Attributes</string>
|
<string>Attributes</string>
|
||||||
|
@ -383,154 +473,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" rowspan="4">
|
|
||||||
<widget class="QGBA::AssetTile" name="tile">
|
|
||||||
<property name="title">
|
|
||||||
<string>Tile</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QGroupBox" name="groupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Geometry</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Position</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="x">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>0</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="tileId_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>, </string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="y">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>0</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>Dimensions</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="w">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>8</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="tileId_5">
|
|
||||||
<property name="text">
|
|
||||||
<string>×</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="h">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>8</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
|
@ -568,6 +510,80 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="magnification">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string>×</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>8</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Magnification</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="3">
|
||||||
|
<widget class="QPushButton" name="copyButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2" rowspan="4" colspan="2">
|
||||||
|
<widget class="QFrame" name="frame">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0" alignment="Qt::AlignHCenter|Qt::AlignVCenter">
|
||||||
|
<widget class="QGBA::TilePainter" name="tiles" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>8</width>
|
||||||
|
<height>8</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|
|
@ -36,6 +36,11 @@ PrinterView::PrinterView(std::shared_ptr<CoreController> controller, QWidget* pa
|
||||||
m_ui.image->setFixedHeight(m_ui.image->size().height() / oldMag * mag);
|
m_ui.image->setFixedHeight(m_ui.image->size().height() / oldMag * mag);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QAction* save = new QAction(this);
|
||||||
|
save->setShortcut(QKeySequence::Save);
|
||||||
|
connect(save, &QAction::triggered, this, &MapView::save);
|
||||||
|
addAction(save);
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include "CoreController.h"
|
#include "CoreController.h"
|
||||||
#include "GBAApp.h"
|
#include "GBAApp.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
@ -87,7 +89,20 @@ TileView::TileView(std::shared_ptr<CoreController> controller, QWidget* parent)
|
||||||
updateTiles(true);
|
updateTiles(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_ui.exportButton, &QAbstractButton::clicked, this, &TileView::exportTiles);
|
connect(m_ui.exportAll, &QAbstractButton::clicked, this, &TileView::exportTiles);
|
||||||
|
connect(m_ui.exportOne, &QAbstractButton::clicked, this, &TileView::exportTile);
|
||||||
|
connect(m_ui.copyAll, &QAbstractButton::clicked, this, &TileView::copyTiles);
|
||||||
|
connect(m_ui.copyOne, &QAbstractButton::clicked, this, &TileView::copyTile);
|
||||||
|
|
||||||
|
QAction* exportAll = new QAction(this);
|
||||||
|
exportAll->setShortcut(QKeySequence::Save);
|
||||||
|
connect(exportAll, &QAction::triggered, this, &TileView::exportTiles);
|
||||||
|
addAction(exportAll);
|
||||||
|
|
||||||
|
QAction* copyOne = new QAction(this);
|
||||||
|
copyOne->setShortcut(QKeySequence::Copy);
|
||||||
|
connect(copyOne, &QAction::triggered, this, &TileView::copyTile);
|
||||||
|
addAction(copyOne);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
|
@ -162,8 +177,36 @@ void TileView::updatePalette(int palette) {
|
||||||
void TileView::exportTiles() {
|
void TileView::exportTiles() {
|
||||||
QString filename = GBAApp::app()->getSaveFileName(this, tr("Export tiles"),
|
QString filename = GBAApp::app()->getSaveFileName(this, tr("Export tiles"),
|
||||||
tr("Portable Network Graphics (*.png)"));
|
tr("Portable Network Graphics (*.png)"));
|
||||||
|
if (filename.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
CoreController::Interrupter interrupter(m_controller);
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
updateTiles(false);
|
updateTiles(false);
|
||||||
QPixmap pixmap(m_ui.tiles->backing());
|
QPixmap pixmap(m_ui.tiles->backing());
|
||||||
pixmap.save(filename, "PNG");
|
pixmap.save(filename, "PNG");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TileView::exportTile() {
|
||||||
|
QString filename = GBAApp::app()->getSaveFileName(this, tr("Export tile"),
|
||||||
|
tr("Portable Network Graphics (*.png)"));
|
||||||
|
if (filename.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
|
updateTiles(false);
|
||||||
|
QImage image(m_ui.tile->activeTile());
|
||||||
|
image.save(filename, "PNG");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileView::copyTiles() {
|
||||||
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
|
updateTiles(false);
|
||||||
|
QPixmap pixmap();
|
||||||
|
GBAApp::app()->clipboard()->setPixmap(m_ui.tiles->backing());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TileView::copyTile() {
|
||||||
|
CoreController::Interrupter interrupter(m_controller);
|
||||||
|
updateTiles(false);
|
||||||
|
GBAApp::app()->clipboard()->setImage(m_ui.tile->activeTile());
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void updatePalette(int);
|
void updatePalette(int);
|
||||||
void exportTiles();
|
void exportTiles();
|
||||||
|
void exportTile();
|
||||||
|
void copyTiles();
|
||||||
|
void copyTile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
|
|
|
@ -6,14 +6,28 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>693</width>
|
<width>748</width>
|
||||||
<height>467</height>
|
<height>823</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Tiles</string>
|
<string>Tiles</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
|
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,1,0,0,0,0" columnstretch="0,1">
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QPushButton" name="exportOne">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export Selected</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0">
|
||||||
|
<widget class="QPushButton" name="exportAll">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export All</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
|
@ -104,17 +118,7 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="0" column="1" rowspan="8">
|
||||||
<widget class="QGBA::AssetTile" name="tile"/>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QPushButton" name="exportButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Export</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1" rowspan="5">
|
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||||
|
@ -133,7 +137,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>405</width>
|
<width>480</width>
|
||||||
<height>768</height>
|
<height>768</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -179,6 +183,23 @@
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QGBA::AssetTile" name="tile"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QPushButton" name="copyOne">
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy Selected</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QPushButton" name="copyAll">
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy All</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|
Loading…
Reference in New Issue