summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedric.bosdonnat@free.fr>2013-03-25 16:40:37 +0100
committerMiklos Vajna <vmiklos@suse.cz>2013-03-26 08:43:32 +0000
commit369cb8e216f9287234d601f4b28e0332a2ec29a5 (patch)
tree9387e309dc44cfbe5541d02ac0cf94a448e09c20
parent2902a8369fc6033c74ebbb46408ccb29f279a5a8 (diff)
fdo#61390: allow arrow keys to show hidden thumbnail items
Change-Id: I70924b4c9578122a1c5a5b6c8a67889d6d003a2e (cherry picked from commit cc599e914e7ade9f10da460fc1c77ea07454d7ff) Reviewed-on: https://gerrit.libreoffice.org/3033 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
-rw-r--r--sfx2/inc/sfx2/thumbnailview.hxx1
-rw-r--r--sfx2/source/control/thumbnailview.cxx31
-rw-r--r--sfx2/source/doc/templatedlg.cxx2
3 files changed, 31 insertions, 3 deletions
diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 95e6b53679c5..9e29c9a34f8e 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -277,6 +277,7 @@ protected:
using Window::ImplInit;
void CalculateItemPositions ();
+ void MakeItemVisible( sal_uInt16 nId );
SFX2_DLLPRIVATE void ImplInit();
SFX2_DLLPRIVATE void ImplInitSettings( bool bFont, bool bForeground, bool bBackground );
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index f78a308275ee..08be7cb39014 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -553,13 +553,40 @@ void ThumbnailView::KeyInput( const KeyEvent& rKEvt )
Control::KeyInput( rKEvt );
}
- if ( pNext && pNext->isVisible() )
+ if ( pNext )
{
deselectItems();
SelectItem(pNext->mnId);
+ MakeItemVisible(pNext->mnId);
}
}
+void ThumbnailView::MakeItemVisible( sal_uInt16 nItemId )
+{
+ // Get the item row
+ size_t nPos = 0;
+ bool bFound = false;
+ for ( size_t i = 0; !bFound && i < mFilteredItemList.size(); ++i )
+ {
+ ThumbnailViewItem* pItem = mFilteredItemList[i];
+ if ( pItem->mnId == nItemId )
+ {
+ nPos = i;
+ bFound = true;
+ }
+ }
+ sal_uInt16 nRow = nPos / mnCols;
+
+ // Move the visible rows as little as possible to include that one
+ if ( nRow < mnFirstLine )
+ mnFirstLine = nRow;
+ else if ( nRow > mnFirstLine + mnVisLines )
+ mnFirstLine = nRow - mnVisLines;
+
+ CalculateItemPositions();
+ Invalidate();
+}
+
void ThumbnailView::MouseButtonDown( const MouseEvent& rMEvt )
{
if ( rMEvt.IsLeft() )
@@ -703,11 +730,11 @@ void ThumbnailView::LoseFocus()
void ThumbnailView::Resize()
{
+ Control::Resize();
CalculateItemPositions();
if ( IsReallyVisible() && IsUpdateMode() )
Invalidate();
- Control::Resize();
}
void ThumbnailView::StateChanged( StateChangedType nType )
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index b9d3945c98d0..e5e4014ebbdb 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -331,7 +331,7 @@ void SfxTemplateManagerDlg::Resize()
Point aViewPos = maView->GetPosPixel();
aViewPos.setY(nToolbarsHeight);
aViewPos.setX(0);
- Size aThumbSize(aWinSize.getWidth(), maTabControl.GetTabPageSizePixel().getWidth() - aViewPos.getY());
+ Size aThumbSize(aWinSize.getWidth(), maTabControl.GetTabPageSizePixel().getHeight() - aViewPos.getY());
maView->SetPosSizePixel(aViewPos, aThumbSize);
if (aWinSize.getHeight() < aViewPos.getY() + aThumbSize.getHeight() + PADDING_DLG_BORDER)