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
- Qt: State file load/save menu options
- Windows installer
- Tile viewer now has adjustable width
Bugfixes:
- PSP2: Fix audio crackling after fast forward
- 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 h = (tiles + w - 1) * m_size / w;
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) {

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]() {
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

View File

@ -6,48 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>501</width>
<height>335</height>
<width>693</width>
<height>467</height>
</rect>
</property>
<property name="windowTitle">
<string>Tiles</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<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">
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
<item row="0" column="1" rowspan="4">
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
@ -66,7 +33,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>256</width>
<width>405</width>
<height>768</height>
</rect>
</property>
@ -112,7 +79,7 @@
</widget>
</widget>
</item>
<item row="4" column="0">
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -125,22 +92,84 @@
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QGBA::AssetTile" name="tile"/>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QSpinBox" name="paletteId">
<property name="maximum">
<number>15</number>
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QCheckBox" name="palette256">
<property name="text">
<string>256 colors</string>
</property>
</widget>
</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>
</item>
</layout>
@ -164,6 +193,22 @@
</customwidgets>
<resources/>
<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>
<sender>magnification</sender>
<signal>valueChanged(int)</signal>
@ -171,12 +216,12 @@
<slot>setTileMagnification(int)</slot>
<hints>
<hint type="sourcelabel">
<x>36</x>
<y>83</y>
<x>39</x>
<y>81</y>
</hint>
<hint type="destinationlabel">
<x>339</x>
<y>396</y>
<x>462</x>
<y>391</y>
</hint>
</hints>
</connection>
@ -187,11 +232,11 @@
<slot>setDisabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>158</x>
<y>29</y>
<x>148</x>
<y>24</y>
</hint>
<hint type="destinationlabel">
<x>44</x>
<x>39</x>
<y>29</y>
</hint>
</hints>