diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-05-07 16:16:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-05-07 16:35:35 +0100 |
commit | b179235f702e474b115ca479b603052f422346fd (patch) | |
tree | 79208edcc9006afe3dff9637d2cfae94d1e7b0b6 /sd | |
parent | 34ae7b16d7ef365f4b63dd3d4a9e756e2b77e7bd (diff) |
center slide after changing zoom
Change-Id: I08698b06d0485d2cd3573af665e0621b42d37349
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/inc/ViewShell.hxx | 1 | ||||
-rw-r--r-- | sd/source/ui/view/viewshe2.cxx | 27 | ||||
-rw-r--r-- | sd/source/ui/view/viewshel.cxx | 1 |
3 files changed, 29 insertions, 0 deletions
diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index ce5ea3152fb2..87edbc5a611e 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -206,6 +206,7 @@ public: virtual void UpdateScrollBars (void); void Scroll(long nX, long nY); void ScrollLines(long nX, long nY); + void ScrollCenter(); virtual void SetZoom(long nZoom); virtual void SetZoomRect(const Rectangle& rZoomRect); void InitWindows(const Point& rViewOrigin, const Size& rViewSize, diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index 5f98d68ba8f4..8f91d6c75af0 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -365,6 +365,33 @@ void ViewShell::SetZoom(long nZoom) UpdateScrollBars(); } +namespace +{ + void CenterScrollBar(ScrollBar *pBar) + { + long nVisSize = pBar->GetVisibleSize(); + long nMin = pBar->GetRangeMin(); + long nMax = pBar->GetRangeMax(); + long nLen = nMax - nMin - nVisSize; + long nPos = nMin + nLen/2; + pBar->DoScroll(nPos); + } +} + +void ViewShell::ScrollCenter() +{ + if (mpHorizontalScrollBar.get() != NULL) + CenterScrollBar(mpHorizontalScrollBar.get()); + + //zoom mode with no panning of the current slide, i.e. the + //scrollbar is in change slide mode not pan slide mode + if (IsPageFlipMode()) + return; + + if (mpVerticalScrollBar.get() != NULL) + CenterScrollBar(mpVerticalScrollBar.get()); +} + /** * Set zoom rectangle for active window. Sets all split windows to the same zoom * factor. diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 28e272e229e4..17bcf5f8cd1b 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -683,6 +683,7 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi nNewZoom = std::min( (long) pWin->GetMaxZoom(), basegfx::zoomtools::zoomIn( nOldZoom )); SetZoom( nNewZoom ); + ScrollCenter(); //center slide after changing zoom Invalidate( SID_ATTR_ZOOM ); Invalidate( SID_ATTR_ZOOMSLIDER ); |