From 6cb99415ccb50b6f37044116024c6dafe789c582 Mon Sep 17 00:00:00 2001 From: RickyRister Date: Mon, 24 Feb 2025 00:09:49 -0800 Subject: [PATCH] refactor --- cockatrice/src/game/zones/view_zone_widget.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/game/zones/view_zone_widget.cpp b/cockatrice/src/game/zones/view_zone_widget.cpp index 4a7d92417..8f1d82ee6 100644 --- a/cockatrice/src/game/zones/view_zone_widget.cpp +++ b/cockatrice/src/game/zones/view_zone_widget.cpp @@ -258,14 +258,25 @@ void ZoneViewWidget::resizeScrollbar(const qreal newZoneHeight) scrollBar->setMaximum(newMax); } +/** + * Maps a height that is given as number of rows of cards to the actual height, given in pixels. + * + * @param rows Rows of cards + * @return The height in pixels + */ +static qreal rowsToHeight(int rows) +{ + const qreal cardsHeight = (rows + 1) * (CARD_HEIGHT / 3); + return cardsHeight + 5; // +5 padding to make the cutoff look nicer +} + /** * Calculates the max initial height from the settings. * The max initial height setting is given as number of rows, so we need to map it to a height. **/ static qreal calcMaxInitialHeight() { - const qreal cardsHeight = (SettingsCache::instance().getCardViewInitialRowsMax() + 1) * (CARD_HEIGHT / 3); - return cardsHeight + 5; // +5 padding to make the cutoff look nicer + return rowsToHeight(SettingsCache::instance().getCardViewInitialRowsMax()); } /**