Kaydet (Commit) 717aa1ac authored tarafından Andrzej Hunt's avatar Andrzej Hunt

fdo#72287 Scroll automatically to show selected item when keyboard used.

806919ad 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
üst 279d2333
...@@ -282,7 +282,7 @@ protected: ...@@ -282,7 +282,7 @@ protected:
using Control::ImplInitSettings; using Control::ImplInitSettings;
using Window::ImplInit; using Window::ImplInit;
void CalculateItemPositions (); void CalculateItemPositions (bool bScrollBarUsed = false);
void MakeItemVisible( sal_uInt16 nId ); void MakeItemVisible( sal_uInt16 nId );
SFX2_DLLPRIVATE void ImplInit(); SFX2_DLLPRIVATE void ImplInit();
......
...@@ -270,7 +270,7 @@ void ThumbnailView::OnItemDblClicked (ThumbnailViewItem*) ...@@ -270,7 +270,7 @@ void ThumbnailView::OnItemDblClicked (ThumbnailViewItem*)
return new ThumbnailViewAcc( this, mbIsTransientChildrenDisabled ); return new ThumbnailViewAcc( this, mbIsTransientChildrenDisabled );
} }
void ThumbnailView::CalculateItemPositions () void ThumbnailView::CalculateItemPositions (bool bScrollBarUsed)
{ {
if (!mnItemHeight || !mnItemWidth) if (!mnItemHeight || !mnItemWidth)
return; return;
...@@ -295,7 +295,7 @@ void ThumbnailView::CalculateItemPositions () ...@@ -295,7 +295,7 @@ void ThumbnailView::CalculateItemPositions ()
// calculate window scroll ratio // calculate window scroll ratio
float nScrollRatio; float nScrollRatio;
if( mpScrBar ) if( bScrollBarUsed && mpScrBar )
nScrollRatio = static_cast<float>(mpScrBar->GetThumbPos()) / nScrollRatio = static_cast<float>(mpScrBar->GetThumbPos()) /
static_cast<float>(mpScrBar->GetRangeMax()-2); static_cast<float>(mpScrBar->GetRangeMax()-2);
else else
...@@ -351,7 +351,12 @@ void ThumbnailView::CalculateItemPositions () ...@@ -351,7 +351,12 @@ void ThumbnailView::CalculateItemPositions ()
nHiddenLines * nItemHeightOffset; nHiddenLines * nItemHeightOffset;
// draw items // 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; size_t nLastItem = nFirstItem + (mnVisLines + 1) * mnCols;
maItemListRect.Left() = x; maItemListRect.Left() = x;
...@@ -433,6 +438,8 @@ void ThumbnailView::CalculateItemPositions () ...@@ -433,6 +438,8 @@ void ThumbnailView::CalculateItemPositions ()
mpScrBar->SetPosSizePixel( aPos, aSize ); mpScrBar->SetPosSizePixel( aPos, aSize );
mpScrBar->SetRangeMax( (nCurCount+mnCols-1)*mnFineness/mnCols); mpScrBar->SetRangeMax( (nCurCount+mnCols-1)*mnFineness/mnCols);
mpScrBar->SetVisibleSize( mnVisLines ); mpScrBar->SetVisibleSize( mnVisLines );
if (!bScrollBarUsed)
mpScrBar->SetThumbPos( (long)mnFirstLine*mnFineness );
long nPageSize = mnVisLines; long nPageSize = mnVisLines;
if ( nPageSize < 1 ) if ( nPageSize < 1 )
nPageSize = 1; nPageSize = 1;
...@@ -515,7 +522,7 @@ IMPL_LINK( ThumbnailView,ImplScrollHdl, ScrollBar*, pScrollBar ) ...@@ -515,7 +522,7 @@ IMPL_LINK( ThumbnailView,ImplScrollHdl, ScrollBar*, pScrollBar )
{ {
if ( pScrollBar->GetDelta() ) if ( pScrollBar->GetDelta() )
{ {
CalculateItemPositions(); CalculateItemPositions(true);
if ( IsReallyVisible() && IsUpdateMode() ) if ( IsReallyVisible() && IsUpdateMode() )
Invalidate(); Invalidate();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment