Qt: Add width adjustment to tile viewer

This commit is contained in:
Vicki Pfau 2018-10-05 13:15:08 -07:00
parent a8d991e24f
commit 7046422417
4 changed files with 115 additions and 50 deletions

View File

@ -106,6 +106,7 @@ Features:
- Switch: Rotation support - Switch: Rotation support
- Qt: State file load/save menu options - Qt: State file load/save menu options
- Windows installer - Windows installer
- Tile viewer now has adjustable width
Bugfixes: Bugfixes:
- PSP2: Fix audio crackling after fast forward - PSP2: Fix audio crackling after fast forward
- PSP2: Fix audio crackling when buffer is full - PSP2: Fix audio crackling when buffer is full

View File

@ -59,8 +59,12 @@ void TilePainter::setTileCount(int tiles) {
int w = width() / m_size; int w = width() / m_size;
int h = (tiles + w - 1) * m_size / w; int h = (tiles + w - 1) * m_size / w;
setMinimumSize(m_size, h - (h % m_size)); setMinimumSize(m_size, h - (h % m_size));
resizeEvent(nullptr); } else {
int w = minimumSize().width() / m_size;
int h = (tiles + w - 1) * m_size / w;
setMinimumSize(minimumSize().width(), h - (h % m_size));
} }
resizeEvent(nullptr);
} }
void TilePainter::setTileMagnification(int mag) { void TilePainter::setTileMagnification(int mag) {

View File

@ -65,6 +65,21 @@ TileView::TileView(std::shared_ptr<CoreController> controller, QWidget* parent)
connect(m_ui.magnification, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this]() { connect(m_ui.magnification, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this]() {
updateTiles(true); updateTiles(true);
}); });
connect(m_ui.tilesPerRow, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this](int count) {
m_ui.tiles->setMinimumSize(m_ui.magnification->value() * 8 * count, m_ui.tiles->minimumSize().height());
updateTiles(true);
});
connect(m_ui.tileFit, &QAbstractButton::toggled, [this](bool selected) {
if (!selected) {
m_ui.tiles->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_ui.tiles->setMinimumSize(m_ui.magnification->value() * 8 * m_ui.tilesPerRow->value(), m_ui.tiles->minimumSize().height());
} else {
m_ui.tiles->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
}
updateTiles(true);
});
} }
#ifdef M_CORE_GBA #ifdef M_CORE_GBA

View File

@ -6,48 +6,15 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>501</width> <width>693</width>
<height>335</height> <height>467</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Tiles</string> <string>Tiles</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
<item row="2" column="0"> <item row="0" column="1" rowspan="4">
<widget class="QGBA::AssetTile" name="tile"/>
</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>4</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Magnification</string>
</property>
</widget>
</item>
</layout>
</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">
@ -66,7 +33,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>256</width> <width>405</width>
<height>768</height> <height>768</height>
</rect> </rect>
</property> </property>
@ -112,7 +79,7 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="3" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -125,22 +92,84 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="0">
<widget class="QGBA::AssetTile" name="tile"/>
</item>
<item row="0" column="0"> <item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QFormLayout" name="formLayout">
<item> <item row="0" column="0">
<widget class="QSpinBox" name="paletteId"> <widget class="QSpinBox" name="paletteId">
<property name="maximum"> <property name="maximum">
<number>15</number> <number>15</number>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QCheckBox" name="palette256"> <widget class="QCheckBox" name="palette256">
<property name="text"> <property name="text">
<string>256 colors</string> <string>256 colors</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<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>4</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Magnification</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QSpinBox" name="tilesPerRow">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>64</number>
</property>
<property name="value">
<number>32</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Tiles per row</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="tileFit">
<property name="text">
<string>Fit to window</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -164,6 +193,22 @@
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections> <connections>
<connection>
<sender>tileFit</sender>
<signal>toggled(bool)</signal>
<receiver>tilesPerRow</receiver>
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>162</x>
<y>180</y>
</hint>
<hint type="destinationlabel">
<x>39</x>
<y>133</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>magnification</sender> <sender>magnification</sender>
<signal>valueChanged(int)</signal> <signal>valueChanged(int)</signal>
@ -171,12 +216,12 @@
<slot>setTileMagnification(int)</slot> <slot>setTileMagnification(int)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>36</x> <x>39</x>
<y>83</y> <y>81</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>339</x> <x>462</x>
<y>396</y> <y>391</y>
</hint> </hint>
</hints> </hints>
</connection> </connection>
@ -187,11 +232,11 @@
<slot>setDisabled(bool)</slot> <slot>setDisabled(bool)</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>158</x> <x>148</x>
<y>29</y> <y>24</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>44</x> <x>39</x>
<y>29</y> <y>29</y>
</hint> </hint>
</hints> </hints>