summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-04-15 16:22:53 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-04-16 10:25:49 +0000
commited2d6ab389c169330f3c359463ce503eafcee253 (patch)
tree8bb182617354861e69f875f00ebc4d212b061a08
parent4128c63d655869e0ab7befde2c46761d8e1b273f (diff)
fdo#72287 Scroll automatically to show selected item when keyboard used.
806919adf9c9bafbaba92c2d2ab35d2e2f9863f8 added finer-grained scrolling using the scrollbar / scrollwheel, but inadvertently prevents the display from scrolling when an item is selected that is currently offscreen (e.g. by using the down-arrow button on the keyboard). Change-Id: Iaa3a7dc6d214741d37cf4ec78c00ed0034ed1e42 (cherry picked from commit 717aa1ac75ddd54fdf72cd4de6551f1fb536da9b) Reviewed-on: https://gerrit.libreoffice.org/9017 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--include/sfx2/thumbnailview.hxx2
-rw-r--r--sfx2/source/control/thumbnailview.cxx15
2 files changed, 12 insertions, 5 deletions
diff --git a/include/sfx2/thumbnailview.hxx b/include/sfx2/thumbnailview.hxx
index e21b87b55474..851eba07060d 100644
--- a/include/sfx2/thumbnailview.hxx
+++ b/include/sfx2/thumbnailview.hxx
@@ -292,7 +292,7 @@ protected:
using Control::ImplInitSettings;
using Window::ImplInit;
- void CalculateItemPositions ();
+ void CalculateItemPositions (bool bScrollBarUsed = false);
void MakeItemVisible( sal_uInt16 nId );
SFX2_DLLPRIVATE void ImplInit();
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index a4e38a7eccd0..814a8d752368 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -275,7 +275,7 @@ void ThumbnailView::OnItemDblClicked (ThumbnailViewItem*)
return new ThumbnailViewAcc( this, mbIsTransientChildrenDisabled );
}
-void ThumbnailView::CalculateItemPositions ()
+void ThumbnailView::CalculateItemPositions (bool bScrollBarUsed)
{
if (!mnItemHeight || !mnItemWidth)
return;
@@ -300,7 +300,7 @@ void ThumbnailView::CalculateItemPositions ()
// calculate window scroll ratio
float nScrollRatio;
- if( mpScrBar )
+ if( bScrollBarUsed && mpScrBar )
nScrollRatio = static_cast<float>(mpScrBar->GetThumbPos()) /
static_cast<float>(mpScrBar->GetRangeMax()-2);
else
@@ -356,7 +356,12 @@ void ThumbnailView::CalculateItemPositions ()
nHiddenLines * nItemHeightOffset;
// draw items
- size_t nFirstItem = nHiddenLines * mnCols;
+ // Unless we are scrolling (via scrollbar) we just use the precalculated
+ // mnFirstLine -- our nHiddenLines calculation takes into account only
+ // what the user has done with the scrollbar but not any changes of selection
+ // using the keyboard, meaning we could accidentally hide the selected item
+ // if we believe the scrollbar (fdo#72287).
+ size_t nFirstItem = (bScrollBarUsed ? nHiddenLines : mnFirstLine) * mnCols;
size_t nLastItem = nFirstItem + (mnVisLines + 1) * mnCols;
maItemListRect.Left() = x;
@@ -438,6 +443,8 @@ void ThumbnailView::CalculateItemPositions ()
mpScrBar->SetPosSizePixel( aPos, aSize );
mpScrBar->SetRangeMax( (nCurCount+mnCols-1)*mnFineness/mnCols);
mpScrBar->SetVisibleSize( mnVisLines );
+ if (!bScrollBarUsed)
+ mpScrBar->SetThumbPos( (long)mnFirstLine*mnFineness );
long nPageSize = mnVisLines;
if ( nPageSize < 1 )
nPageSize = 1;
@@ -520,7 +527,7 @@ IMPL_LINK( ThumbnailView,ImplScrollHdl, ScrollBar*, pScrollBar )
{
if ( pScrollBar->GetDelta() )
{
- CalculateItemPositions();
+ CalculateItemPositions(true);
if ( IsReallyVisible() && IsUpdateMode() )
Invalidate();