Kaydet (Commit) b179235f authored tarafından Caolán McNamara's avatar Caolán McNamara

center slide after changing zoom

Change-Id: I08698b06d0485d2cd3573af665e0621b42d37349
üst 34ae7b16
...@@ -206,6 +206,7 @@ public: ...@@ -206,6 +206,7 @@ public:
virtual void UpdateScrollBars (void); virtual void UpdateScrollBars (void);
void Scroll(long nX, long nY); void Scroll(long nX, long nY);
void ScrollLines(long nX, long nY); void ScrollLines(long nX, long nY);
void ScrollCenter();
virtual void SetZoom(long nZoom); virtual void SetZoom(long nZoom);
virtual void SetZoomRect(const Rectangle& rZoomRect); virtual void SetZoomRect(const Rectangle& rZoomRect);
void InitWindows(const Point& rViewOrigin, const Size& rViewSize, void InitWindows(const Point& rViewOrigin, const Size& rViewSize,
......
...@@ -365,6 +365,33 @@ void ViewShell::SetZoom(long nZoom) ...@@ -365,6 +365,33 @@ void ViewShell::SetZoom(long nZoom)
UpdateScrollBars(); 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 * Set zoom rectangle for active window. Sets all split windows to the same zoom
* factor. * factor.
......
...@@ -683,6 +683,7 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi ...@@ -683,6 +683,7 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi
nNewZoom = std::min( (long) pWin->GetMaxZoom(), basegfx::zoomtools::zoomIn( nOldZoom )); nNewZoom = std::min( (long) pWin->GetMaxZoom(), basegfx::zoomtools::zoomIn( nOldZoom ));
SetZoom( nNewZoom ); SetZoom( nNewZoom );
ScrollCenter(); //center slide after changing zoom
Invalidate( SID_ATTR_ZOOM ); Invalidate( SID_ATTR_ZOOM );
Invalidate( SID_ATTR_ZOOMSLIDER ); Invalidate( SID_ATTR_ZOOMSLIDER );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment