diff --git a/CHANGES b/CHANGES
index 274125f91..71b33ea88 100644
--- a/CHANGES
+++ b/CHANGES
@@ -14,6 +14,7 @@ Bugfixes:
- Qt: Fix changing resolution of software renderer
- Qt: Fix setting overrides
- GBA Cheats: Fix GameShark ROM patches
+ - Qt: Fix cut off tiles and alignment issues in tile viewer
Misc:
- SDL: Remove scancode key input
- GBA Video: Clean up unused timers
diff --git a/src/platform/qt/TilePainter.cpp b/src/platform/qt/TilePainter.cpp
index 29b99df2f..e55bdf592 100644
--- a/src/platform/qt/TilePainter.cpp
+++ b/src/platform/qt/TilePainter.cpp
@@ -27,7 +27,9 @@ void TilePainter::paintEvent(QPaintEvent* 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) {
m_backing = QPixmap(width(), calculatedHeight);
m_backing.fill(Qt::transparent);
@@ -53,7 +55,9 @@ void TilePainter::setTile(int index, const uint16_t* data) {
void TilePainter::setTileCount(int 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);
}
diff --git a/src/platform/qt/TileView.ui b/src/platform/qt/TileView.ui
index 0763f96f8..1c61bd869 100644
--- a/src/platform/qt/TileView.ui
+++ b/src/platform/qt/TileView.ui
@@ -97,6 +97,9 @@
true
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
+
@@ -106,6 +109,12 @@
768
+
+
+ 0
+ 0
+
+
0