diff options
author | Povilas Kanapickas <povilas@radix.lt> | 2022-12-07 03:13:32 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-12-15 19:36:02 +0000 |
commit | 915e0a3a959325b2d74983035351921ca5f71f8a (patch) | |
tree | cb6000a7224371cbc6562a1d2f6328a8efde28d8 /starmath | |
parent | daa63104b601b7492b62137e77bb0ebf6c6f5b72 (diff) |
starmath: React to touchpad zoom gestures in SmGraphicWidget
Change-Id: Id158d7778ec0c375c143cf9ce492af21b9625c9d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143759
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144233
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/inc/view.hxx | 2 | ||||
-rw-r--r-- | starmath/source/view.cxx | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx index 1905edb02741..41e28a44c3df 100644 --- a/starmath/inc/view.hxx +++ b/starmath/inc/view.hxx @@ -159,6 +159,8 @@ private: AutoTimer aCaretBlinkTimer; rtl::Reference<SmGraphicAccessible> mxAccessible; SmViewShell& mrViewShell; + double mfLastZoomScale = 0; + double mfAccumulatedZoom = 0; }; class SmGraphicController final : public SfxControllerItem diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 3c7c8b1554d3..bdc8b0729335 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -795,8 +795,35 @@ bool SmGraphicWidget::Command(const CommandEvent& rCEvt) mrGraphicWindow.SetZoom(nTmpZoom); bCallBase = false; } + break; + } + case CommandEventId::GestureZoom: + { + const CommandGestureZoomData* pData = rCEvt.GetGestureZoomData(); + if (pData) + { + if (pData->meEventType == GestureEventZoomType::Begin) + { + mfLastZoomScale = pData->mfScaleDelta; + } + else if (pData->meEventType == GestureEventZoomType::Update) + { + double deltaBetweenEvents = (pData->mfScaleDelta - mfLastZoomScale) / mfLastZoomScale; + mfLastZoomScale = pData->mfScaleDelta; + + // Accumulate fractional zoom to avoid small zoom changes from being ignored + mfAccumulatedZoom += deltaBetweenEvents; + int nZoomChangePercent = mfAccumulatedZoom * 100; + mfAccumulatedZoom -= nZoomChangePercent / 100.0; + + sal_uInt16 nZoom = mrGraphicWindow.GetZoom(); + nZoom += nZoomChangePercent; + mrGraphicWindow.SetZoom(nZoom); + } + bCallBase = false; + } + break; } - break; default: break; } |