diff options
author | Krisztian Pinter <pin.terminator@gmail.com> | 2013-09-15 19:37:06 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-19 13:34:15 +0000 |
commit | 806919adf9c9bafbaba92c2d2ab35d2e2f9863f8 (patch) | |
tree | 06f6bd92eb7154bf47b9a1384a17a8e7ca80f3a5 /sfx2 | |
parent | 58d8a11a1b44d5f07c43f96c7e4ab03dc549ef27 (diff) |
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@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/templateabstractview.cxx | 22 | ||||
-rw-r--r-- | sfx2/source/control/thumbnailview.cxx | 43 |
2 files changed, 45 insertions, 20 deletions
diff --git a/sfx2/source/control/templateabstractview.cxx b/sfx2/source/control/templateabstractview.cxx index 32f1372842ae..5de8a8ee1994 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 7976c6af476a..ab78488b29f0 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() ) |