diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-10-20 19:42:58 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-10-21 15:07:25 +0200 |
commit | 4bea7a17056770c83006048f9fd3fa252958718b (patch) | |
tree | 16e9ed5fd4deab1ea232acf0a9d81f89dfb7ef20 /sfx2/source | |
parent | b48d9aeb848c6e9a4d94f84c7fe636319fcfb78f (diff) |
mirror changes of ThumbnailView to SfxThumbnailView
in advance of replacement
commit 6cd1591fb8b0a550067c37cf720708c6a5630b6d
Author: Roman Kuznetsov <antilibreoffice@gmail.com>
Date: Sun Apr 26 20:49:22 2020 +0100
tdf#132441 thumb scrolling in Start Center should be more accuracy
Change-Id: I9e267adcbed9c4ccd7ee8632b0c921a4809737d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104575
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2/source')
-rw-r--r-- | sfx2/source/control/thumbnailview.cxx | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 97235330b81b..fa1f2d26d7a8 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -1409,8 +1409,11 @@ void SfxThumbnailView::CalculateItemPositions(bool bScrollBarUsed) // calculate window scroll ratio float nScrollRatio; if (bScrollBarUsed) + { nScrollRatio = static_cast<float>(mxScrolledWindow->vadjustment_get_value()) / - static_cast<float>(mxScrolledWindow->vadjustment_get_upper()-2); + static_cast<float>(mxScrolledWindow->vadjustment_get_upper() - + mxScrolledWindow->vadjustment_get_page_size()); + } else nScrollRatio = 0; @@ -1448,11 +1451,10 @@ void SfxThumbnailView::CalculateItemPositions(bool bScrollBarUsed) mbHasVisibleItems = true; + long nFullSteps = (mnLines > mnVisLines) ? mnLines - mnVisLines + 1 : 1; + long nItemHeightOffset = mnItemHeight + nVItemSpace; - long nHiddenLines = (static_cast<long>( - ( mnLines - 1 ) * nItemHeightOffset * nScrollRatio ) - - nVItemSpace ) / - nItemHeightOffset; + long nHiddenLines = static_cast<long>((nFullSteps - 1) * nScrollRatio); // calculate offsets long nStartX = nHItemSpace; @@ -1460,8 +1462,7 @@ void SfxThumbnailView::CalculateItemPositions(bool bScrollBarUsed) // calculate and draw items long x = nStartX; - long y = nStartY - ( mnLines - 1 ) * nItemHeightOffset * nScrollRatio + - nHiddenLines * nItemHeightOffset; + long y = nStartY - ((nFullSteps - 1) * nScrollRatio - nHiddenLines) * nItemHeightOffset; // draw items // Unless we are scrolling (via scrollbar) we just use the precalculated @@ -1536,8 +1537,8 @@ void SfxThumbnailView::CalculateItemPositions(bool bScrollBarUsed) // check if scroll is needed mbScroll = mnLines > mnVisLines; - mxScrolledWindow->vadjustment_set_upper((nCurCount+mnCols-1)*gnFineness/mnCols); - mxScrolledWindow->vadjustment_set_page_size(mnVisLines*gnFineness); + mxScrolledWindow->vadjustment_set_upper(mnLines * gnFineness); + mxScrolledWindow->vadjustment_set_page_size(mnVisLines * gnFineness); if (!bScrollBarUsed) mxScrolledWindow->vadjustment_set_value(static_cast<long>(mnFirstLine)*gnFineness); long nPageSize = mnVisLines; |