From 27e5d21b6b39b385063f18795d58408632d4f048 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Tue, 17 Dec 2024 21:16:47 -0800 Subject: [PATCH] fix bug with scrollbar resizing (#5263) --- cockatrice/src/game/zones/view_zone_widget.cpp | 9 ++++++--- cockatrice/src/game/zones/view_zone_widget.h | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/game/zones/view_zone_widget.cpp b/cockatrice/src/game/zones/view_zone_widget.cpp index 8514aa60d..bf166f208 100644 --- a/cockatrice/src/game/zones/view_zone_widget.cpp +++ b/cockatrice/src/game/zones/view_zone_widget.cpp @@ -247,10 +247,12 @@ void ZoneViewWidget::moveEvent(QGraphicsSceneMoveEvent * /* event */) void ZoneViewWidget::resizeEvent(QGraphicsSceneResizeEvent *event) { // We need to manually resize the scroll bar whenever the window gets resized - qreal totalZoneHeight = zone->getOptimumRect().height(); - qreal newWindowHeight = event->newSize().height(); - qreal newZoneHeight = newWindowHeight - extraHeight - 10; + resizeScrollbar(event->newSize().height() - extraHeight - 10); +} +void ZoneViewWidget::resizeScrollbar(const qreal newZoneHeight) +{ + qreal totalZoneHeight = zone->getOptimumRect().height(); scrollBar->setMaximum(totalZoneHeight - newZoneHeight); } @@ -278,6 +280,7 @@ void ZoneViewWidget::resizeToZoneContents() qreal initialZoneHeight = qMin(zoneRect.height(), calcMaxInitialHeight()); QSizeF initialSize(width, initialZoneHeight + extraHeight + 10); resize(initialSize); + resizeScrollbar(initialZoneHeight); zone->setGeometry(QRectF(0, -scrollBar->value(), zoneContainer->size().width(), totalZoneHeight)); diff --git a/cockatrice/src/game/zones/view_zone_widget.h b/cockatrice/src/game/zones/view_zone_widget.h index 677e0127e..9b0714dce 100644 --- a/cockatrice/src/game/zones/view_zone_widget.h +++ b/cockatrice/src/game/zones/view_zone_widget.h @@ -55,6 +55,8 @@ private: bool canBeShuffled; int extraHeight; Player *player; + + void resizeScrollbar(qreal newZoneHeight); signals: void closePressed(ZoneViewWidget *zv); private slots: