From 5b0ae8c70d1e674ecc12facb66ddcd422e7cb2e3 Mon Sep 17 00:00:00 2001 From: Ryan Foster Date: Sun, 28 Aug 2022 00:18:09 -0400 Subject: [PATCH] UI: Fix scrollbar enablement in Scene Grid Mode The UI layout math used to determine if scrollbars should be displayed in the Scenes Dock was off by one pixel. This caused the scrollbar to disappear when performing actions while scrolled to the bottom, such as dragging items or resizing the dock. --- UI/scene-tree.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/UI/scene-tree.cpp b/UI/scene-tree.cpp index 769bd740e..a458fef70 100644 --- a/UI/scene-tree.cpp +++ b/UI/scene-tree.cpp @@ -70,7 +70,8 @@ void SceneTree::resizeEvent(QResizeEvent *event) { if (gridMode) { int scrollWid = verticalScrollBar()->sizeHint().width(); - int h = visualItemRect(item(count() - 1)).bottom(); + const QRect lastItem = visualItemRect(item(count() - 1)); + const int h = lastItem.y() + lastItem.height(); if (h < height()) { setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -113,7 +114,8 @@ void SceneTree::dropEvent(QDropEvent *event) if (gridMode) { int scrollWid = verticalScrollBar()->sizeHint().width(); - int h = visualItemRect(item(count() - 1)).bottom(); + const QRect lastItem = visualItemRect(item(count() - 1)); + const int h = lastItem.y() + lastItem.height(); if (h < height()) { setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -154,7 +156,8 @@ void SceneTree::dropEvent(QDropEvent *event) void SceneTree::RepositionGrid(QDragMoveEvent *event) { int scrollWid = verticalScrollBar()->sizeHint().width(); - int h = visualItemRect(item(count() - 1)).bottom(); + const QRect lastItem = visualItemRect(item(count() - 1)); + const int h = lastItem.y() + lastItem.height(); if (h < height()) { setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);