[Libreoffice-commits] core.git: include/sfx2 sfx2/source

Krisztian Pinter pin.terminator at gmail.com
Thu Sep 19 06:34:35 PDT 2013


 include/sfx2/templateabstractview.hxx        |    2 +
 include/sfx2/thumbnailview.hxx               |    3 +
 sfx2/source/control/templateabstractview.cxx |   22 +++++++++++++
 sfx2/source/control/thumbnailview.cxx        |   43 ++++++++++++++-------------
 4 files changed, 50 insertions(+), 20 deletions(-)

New commits:
commit 806919adf9c9bafbaba92c2d2ab35d2e2f9863f8
Author: Krisztian Pinter <pin.terminator at gmail.com>
Date:   Sun Sep 15 19:37:06 2013 +0200

    Make scrolling in ThumbnailView smoother and not per-line
    
    Change-Id: I3df50dc953c6a5123b62f129b6e303ff682c6d9b
    Reviewed-on: https://gerrit.libreoffice.org/5951
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/sfx2/templateabstractview.hxx b/include/sfx2/templateabstractview.hxx
index 8648205..962e754 100644
--- a/include/sfx2/templateabstractview.hxx
+++ b/include/sfx2/templateabstractview.hxx
@@ -131,6 +131,8 @@ protected:
 
     virtual void OnItemDblClicked(ThumbnailViewItem *pItem);
 
+    virtual void Paint( const Rectangle& rRect );
+
 protected:
 
     sal_uInt16 mnCurRegionId;
diff --git a/include/sfx2/thumbnailview.hxx b/include/sfx2/thumbnailview.hxx
index 30037a6..bfb08bc 100644
--- a/include/sfx2/thumbnailview.hxx
+++ b/include/sfx2/thumbnailview.hxx
@@ -325,6 +325,9 @@ protected:
     long mnDisplayHeight;       // Height of the data display box (name, etc)
     long mnVisLines;
     long mnLines;
+
+    int mnFineness;
+
     sal_uInt16 mnHighItemId;
     sal_uInt16 mnCols;
     sal_uInt16 mnFirstLine;
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx
index 32f1372..5de8a8e 100644
--- a/sfx2/source/control/templateabstractview.cxx
+++ b/sfx2/source/control/templateabstractview.cxx
@@ -17,6 +17,10 @@
 #include <unotools/ucbstreamhelper.hxx>
 #include <vcl/pngread.hxx>
 
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
+#include <drawinglayer/processor2d/baseprocessor2d.hxx>
+
 #include <com/sun/star/embed/ElementModes.hpp>
 #include <com/sun/star/embed/XStorage.hpp>
 #include <com/sun/star/embed/StorageFactory.hpp>
@@ -27,6 +31,9 @@
 #include "../doc/doc.hrc"
 #include "templateview.hrc"
 
+using namespace basegfx;
+using namespace drawinglayer::primitive2d;
+
 bool ViewFilter_Application::isFilteredExtension(FILTER_APPLICATION filter, const OUString &rExt)
 {
     bool bRet = true;
@@ -321,4 +328,19 @@ void TemplateAbstractView::OnItemDblClicked (ThumbnailViewItem *pItem)
     }
 }
 
+void TemplateAbstractView::Paint( const Rectangle& rRect )
+{
+    ThumbnailView::Paint( rRect );
+
+    Rectangle aRect(rRect.TopLeft(),
+        Point(rRect.BottomRight().X(), mnHeaderHeight));
+
+    drawinglayer::primitive2d::Primitive2DSequence aSeq(1);
+    aSeq[0] = drawinglayer::primitive2d::Primitive2DReference(
+        new PolyPolygonColorPrimitive2D(B2DPolyPolygon(Polygon(aRect).getB2DPolygon()),
+        BColor(1.0, 1.0, 1.0)));
+
+    mpProcessor->process(aSeq);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx
index 7976c6a..ab78488 100644
--- a/sfx2/source/control/thumbnailview.cxx
+++ b/sfx2/source/control/thumbnailview.cxx
@@ -136,6 +136,7 @@ void ThumbnailView::ImplInit()
     mnItemPadding       = 0;
     mnVisLines          = 0;
     mnLines             = 0;
+    mnFineness          = 5;
     mnFirstLine         = 0;
     mnHighItemId        = 0;
     mnCols              = 0;
@@ -287,6 +288,14 @@ void ThumbnailView::CalculateItemPositions ()
         }
     }
 
+    // calculate window scroll ratio
+    float nScrollRatio;
+    if( mpScrBar )
+        nScrollRatio = static_cast<float>(mpScrBar->GetThumbPos()) /
+                        static_cast<float>(mpScrBar->GetRangeMax()-2);
+    else
+        nScrollRatio = 0;
+
     // calculate ScrollBar width
     long nScrBarWidth = 0;
     if ( mpScrBar )
@@ -316,25 +325,29 @@ void ThumbnailView::CalculateItemPositions ()
 
     if ( mnLines <= mnVisLines )
         mnFirstLine = 0;
-    else
-    {
-        if ( mnFirstLine > (sal_uInt16)(mnLines-mnVisLines) )
-            mnFirstLine = (sal_uInt16)(mnLines-mnVisLines);
-    }
+    else if ( mnFirstLine > (sal_uInt16)(mnLines-mnVisLines) )
+        mnFirstLine = (sal_uInt16)(mnLines-mnVisLines);
 
     mbHasVisibleItems = true;
 
+    long nItemHeightOffset = mnItemHeight + nVItemSpace;
+    long nHiddenLines = (static_cast<long>(
+        ( mnLines - 1 ) * nItemHeightOffset * nScrollRatio ) -
+        nVItemSpace - mnHeaderHeight) /
+        nItemHeightOffset;
+
     // calculate offsets
     long nStartX = nHItemSpace;
     long nStartY = nVItemSpace + mnHeaderHeight;
 
     // calculate and draw items
     long x = nStartX;
-    long y = nStartY;
+    long y = nStartY - ( mnLines - 1 ) * nItemHeightOffset * nScrollRatio +
+        nHiddenLines * nItemHeightOffset;
 
     // draw items
-    size_t nFirstItem = mnFirstLine * mnCols;
-    size_t nLastItem = nFirstItem + (mnVisLines * mnCols);
+    size_t nFirstItem = nHiddenLines * mnCols;
+    size_t nLastItem = nFirstItem + (mnVisLines + 1) * mnCols;
 
     maItemListRect.Left() = x;
     maItemListRect.Top() = y;
@@ -413,9 +426,8 @@ void ThumbnailView::CalculateItemPositions ()
         Size aSize( nScrBarWidth, aWinSize.Height() - mnHeaderHeight );
 
         mpScrBar->SetPosSizePixel( aPos, aSize );
-        mpScrBar->SetRangeMax( (nCurCount+mnCols-1)/mnCols);
+        mpScrBar->SetRangeMax( (nCurCount+mnCols-1)*mnFineness/mnCols);
         mpScrBar->SetVisibleSize( mnVisLines );
-        mpScrBar->SetThumbPos( (long)mnFirstLine );
         long nPageSize = mnVisLines;
         if ( nPageSize < 1 )
             nPageSize = 1;
@@ -503,17 +515,8 @@ bool ThumbnailView::ImplHasAccessibleListeners()
 
 IMPL_LINK( ThumbnailView,ImplScrollHdl, ScrollBar*, pScrollBar )
 {
-    sal_uInt16 nNewFirstLine = mnFirstLine;
-
-    if (pScrollBar->GetDelta() > 0)
-        nNewFirstLine += 1;
-    else
-        nNewFirstLine -= 1;
-
-    if ( nNewFirstLine != mnFirstLine )
+    if ( pScrollBar->GetDelta() )
     {
-        mnFirstLine = nNewFirstLine;
-
         CalculateItemPositions();
 
         if ( IsReallyVisible() && IsUpdateMode() )


More information about the Libreoffice-commits mailing list