[PATCH libreoffice-4-0] fdo#61390: allow arrow keys to show hidden thumbnail items

Bosdonnat Cedric (via Code Review) gerrit at gerrit.libreoffice.org
Mon Mar 25 10:23:55 PDT 2013


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3033

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/33/3033/1

fdo#61390: allow arrow keys to show hidden thumbnail items

Change-Id: I70924b4c9578122a1c5a5b6c8a67889d6d003a2e
(cherry picked from commit cc599e914e7ade9f10da460fc1c77ea07454d7ff)
---
M sfx2/inc/sfx2/thumbnailview.hxx
M sfx2/source/control/thumbnailview.cxx
M sfx2/source/doc/templatedlg.cxx
3 files changed, 31 insertions(+), 3 deletions(-)



diff --git a/sfx2/inc/sfx2/thumbnailview.hxx b/sfx2/inc/sfx2/thumbnailview.hxx
index 95e6b53..9e29c9a 100644
--- a/sfx2/inc/sfx2/thumbnailview.hxx
+++ b/sfx2/inc/sfx2/thumbnailview.hxx
@@ -277,6 +277,7 @@
     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 f78a308..08be7cb 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -553,11 +553,38 @@
             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 )
@@ -703,11 +730,11 @@
 
 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 b9d3945..e5e4014 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -331,7 +331,7 @@
     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)

-- 
To view, visit https://gerrit.libreoffice.org/3033
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I70924b4c9578122a1c5a5b6c8a67889d6d003a2e
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Bosdonnat Cedric <cedric.bosdonnat at free.fr>



More information about the LibreOffice mailing list