summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorPovilas Kanapickas <povilas@radix.lt>2022-08-25 00:18:32 +0300
committerCaolán McNamara <caolanm@redhat.com>2022-08-27 10:14:31 +0200
commit85ab77d241ce3bc6adca26d541873583bce2d9d0 (patch)
tree5c9d9788212b77069b8cb82a7a7d001541efb07c /sd
parentf5c3a215fdd5505ebba8ae341d2146c3a4f739e3 (diff)
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 <caolanm@redhat.com>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/ui/inc/ViewShell.hxx1
-rw-r--r--sd/source/ui/view/viewshel.cxx44
2 files changed, 45 insertions, 0 deletions
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;
}