sd/source/ui/inc/ViewShell.hxx | 1 + sd/source/ui/view/viewshel.cxx | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-)
New commits: commit bfcca49e55eff2017287f88ad4747bb0f58308a1 Author: Povilas Kanapickas <povi...@radix.lt> AuthorDate: Wed Dec 7 03:13:24 2022 +0200 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Thu Dec 15 19:32:16 2022 +0000 sd: Improve reaction to slow zoom gestures in ViewShell The current implementation will ignore slow zoom gestures because each event may result in zoom change of less than 1% which will be truncated to zero during floating-point -> integer conversion. Storing accumulated amount and changing the zoom level once a whole integer quantity is accumulated solves this problem. Change-Id: If27a88d7695d0eed241dada5a09b25b2cb577841 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143751 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144225 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 a7b24ef57759..d9fd8564edd0 100644 --- a/sd/source/ui/inc/ViewShell.hxx +++ b/sd/source/ui/inc/ViewShell.hxx @@ -456,6 +456,7 @@ protected: rtl::Reference<FuPoor> mxOldFunction; std::unique_ptr<ZoomList> mpZoomList; double mfLastZoomScale; + double mfAccumulatedZoom = 0; Point maViewPos; Size maViewSize; diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx index 0cfc4b185b49..e12f65236dd9 100644 --- a/sd/source/ui/view/viewshel.cxx +++ b/sd/source/ui/view/viewshel.cxx @@ -776,7 +776,12 @@ bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWi ::tools::Long nNewZoom; Point aOldMousePos = GetActiveWindow()->PixelToLogic(rCEvt.GetMousePosPixel()); - nNewZoom = nOldZoom + deltaBetweenEvents * 100; + // Accumulate fractional zoom to avoid small zoom changes from being ignored + mfAccumulatedZoom += deltaBetweenEvents; + int nZoomChangePercent = mfAccumulatedZoom * 100; + mfAccumulatedZoom -= nZoomChangePercent / 100.0; + + nNewZoom = nOldZoom + nZoomChangePercent; nNewZoom = std::max<::tools::Long>(pWin->GetMinZoom(), nNewZoom); nNewZoom = std::min<::tools::Long>(pWin->GetMaxZoom(), nNewZoom);