Qt: Fix cut off tiles and alignment issues in tile viewer

This commit is contained in:
Jeffrey Pfau 2016-10-20 22:51:30 -07:00
parent 63f9461da4
commit 8a572ab136
3 changed files with 16 additions and 2 deletions

View File

@ -7,6 +7,7 @@ Bugfixes:
- Windows: Fix Unicode directory handling - Windows: Fix Unicode directory handling
- Qt: Fix changing resolution of software renderer - Qt: Fix changing resolution of software renderer
- Qt: Fix setting overrides - Qt: Fix setting overrides
- Qt: Fix cut off tiles and alignment issues in tile viewer
0.5.1: (2016-10-05) 0.5.1: (2016-10-05)
Bugfixes: Bugfixes:

View File

@ -27,7 +27,9 @@ void TilePainter::paintEvent(QPaintEvent* event) {
} }
void TilePainter::resizeEvent(QResizeEvent* event) { void TilePainter::resizeEvent(QResizeEvent* event) {
int calculatedHeight = (m_tileCount * m_size) / (width() / m_size) + m_size / 2; int w = width() / m_size;
int calculatedHeight = (m_tileCount + w - 1) * m_size / w;
calculatedHeight -= calculatedHeight % m_size;
if (width() / m_size != m_backing.width() / m_size || m_backing.height() != calculatedHeight) { if (width() / m_size != m_backing.width() / m_size || m_backing.height() != calculatedHeight) {
m_backing = QPixmap(width(), calculatedHeight); m_backing = QPixmap(width(), calculatedHeight);
m_backing.fill(Qt::transparent); m_backing.fill(Qt::transparent);
@ -53,7 +55,9 @@ void TilePainter::setTile(int index, const uint16_t* data) {
void TilePainter::setTileCount(int tiles) { void TilePainter::setTileCount(int tiles) {
m_tileCount = tiles; m_tileCount = tiles;
setMinimumSize(16, (tiles * m_size) / (width() / m_size)); int w = width() / m_size;
int h = (tiles + w - 1) * m_size / w;
setMinimumSize(16, h - (h % m_size));
resizeEvent(nullptr); resizeEvent(nullptr);
} }

View File

@ -140,6 +140,9 @@
<property name="widgetResizable"> <property name="widgetResizable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents"> <widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -149,6 +152,12 @@
<height>768</height> <height>768</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>