sd/source/ui/inc/ViewShell.hxx | 1 sd/source/ui/view/viewshel.cxx | 44 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+)
New commits: commit 85ab77d241ce3bc6adca26d541873583bce2d9d0 Author: Povilas Kanapickas <povi...@radix.lt> AuthorDate: Thu Aug 25 00:18:32 2022 +0300 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sat Aug 27 10:14:31 2022 +0200 sd: react to touchpad zoom gestures in ViewShell Zoom touchpad gesture now works in the main Impress window to zoom in and out of the main slide. Change-Id: I50e2fef668b1670e446068200f65337ec5ab1a94 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138791 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sd/source/ui/inc/ViewShell.hxx b/sd/source/ui/inc/ViewShell.hxx index 5454639687ed..a7b24ef57759 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -455,6 +455,7 @@ protected: rtl::Reference<FuPoor> mxCurrentFunction; rtl::Reference<FuPoor> mxOldFunction; std::unique_ptr<ZoomList> mpZoomList; + double mfLastZoomScale; Point maViewPos; Size maViewSize; diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 296b42d064c7..efc4d7a7687f 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -178,6 +178,7 @@ void ViewShell::construct() mpView = nullptr; mpFrameView = nullptr; mpZoomList = nullptr; + mfLastZoomScale = 0; mbStartShowWithDialog = false; mnPrintedHandoutPageNum = 1; mnPrintedHandoutPageCount = 0; @@ -751,6 +752,49 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi } break; + case CommandEventId::GestureZoom: + { + const CommandGestureZoomData* pData = rCEvt.GetGestureZoomData(); + + Reference<XSlideShowController> xSlideShowController(SlideShow::GetSlideShowController(GetViewShellBase())); + + if (pData->meEventType == GestureEventZoomType::Begin) + { + mfLastZoomScale = pData->mfScaleDelta; + bDone = true; + break; + } + + if (pData->meEventType == GestureEventZoomType::Update) + { + double deltaBetweenEvents = (pData->mfScaleDelta - mfLastZoomScale) / mfLastZoomScale; + mfLastZoomScale = pData->mfScaleDelta; + + if (pData != nullptr && !GetDocSh()->IsUIActive() && !xSlideShowController.is()) + { + const ::tools::Long nOldZoom = GetActiveWindow()->GetZoom(); + ::tools::Long nNewZoom; + Point aOldMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel()); + + nNewZoom = nOldZoom + deltaBetweenEvents * 100; + nNewZoom = std::max<::tools::Long>(pWin->GetMinZoom(), nNewZoom); + nNewZoom = std::min<::tools::Long>(pWin->GetMaxZoom(), nNewZoom); + + SetZoom(nNewZoom); + + // Keep mouse at same doc point before zoom + Point aNewMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel()); + SetWinViewPos(GetWinViewPos() - (aNewMousePos - aOldMousePos)); + + Invalidate(SID_ATTR_ZOOM); + Invalidate(SID_ATTR_ZOOMSLIDER); + } + } + + bDone = true; + } + break; + default: break; }