Qt: Add width adjustment to tile viewer
Vicki Pfau vi@endrift.com
Fri, 05 Oct 2018 13:15:08 -0700
4 files changed,
115 insertions(+),
50 deletions(-)
M
src/platform/qt/TilePainter.cpp
→
src/platform/qt/TilePainter.cpp
@@ -59,8 +59,12 @@ // Only manage the size ourselves if we don't appear to have something else managing it
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) {
M
src/platform/qt/TileView.cpp
→
src/platform/qt/TileView.cpp
@@ -65,6 +65,21 @@ });
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
M
src/platform/qt/TileView.ui
→
src/platform/qt/TileView.ui
@@ -6,48 +6,15 @@ <property name="geometry">
<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 @@ <property name="geometry">
<rect> <x>0</x> <y>0</y> - <width>256</width> + <width>405</width> <height>768</height> </rect> </property>@@ -112,7 +79,7 @@ </layout>
</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 @@ </size>
</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>@@ -165,18 +194,34 @@ </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> <receiver>tiles</receiver> <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 @@ <receiver>paletteId</receiver>
<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>