[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - starmath/inc starmath/source
starmath/inc/view.hxx|2 ++ starmath/source/view.cxx | 29 - 2 files changed, 30 insertions(+), 1 deletion(-) New commits: commit 915e0a3a959325b2d74983035351921ca5f71f8a Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:32 2022 +0200 Commit: Caolán McNamara CommitDate: Thu Dec 15 19:36:02 2022 + 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 Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144233 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara 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 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; }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source
sc/source/ui/view/gridwin.cxx |9 + 1 file changed, 9 insertions(+) New commits: commit 718ee019335aaabb58750adac639efe962f4858d Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:30 2022 +0200 Commit: Caolán McNamara CommitDate: Thu Dec 15 19:34:48 2022 + sc: React to touchpad zoom gestures in ScGridWindow Change-Id: I21f0e6a820149abe4457950e7382bbc7752eeb6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143757 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144231 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 5fe0a4edd7c9..3316afdf95e4 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -3035,6 +3035,15 @@ void ScGridWindow::Command( const CommandEvent& rCEvt ) Window::Command(rCEvt); return; } + +if (nCmd == CommandEventId::GestureZoom) +{ +bool bDone = mrViewData.GetView()->GestureZoomCommand(rCEvt); +if (!bDone) +Window::Command(rCEvt); +return; +} + // #i7560# FormulaMode check is below scrolling - scrolling is allowed during formula input bool bDisable = pScMod->IsFormulaMode() || pScMod->IsModalMode(mrViewData.GetSfxDocShell());
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source
sc/source/ui/inc/tabview.hxx |4 sc/source/ui/view/tabview.cxx | 42 ++ 2 files changed, 46 insertions(+) New commits: commit 7f1f6a929335552e5adb7caba78333e44f6213c3 Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:29 2022 +0200 Commit: Caolán McNamara CommitDate: Thu Dec 15 19:34:14 2022 + sc: React to touchpad zoom gestures in ScTabView Change-Id: I9a946c0caf3aab03a2055740a4f467210dc07b6a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143756 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144230 Reviewed-by: Caolán McNamara diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index f62b2c4f9cba..7fdb0cc3c2c2 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -214,6 +214,9 @@ private: boolbBlockRows:1; // are whole rows selected? boolmbInlineWithScrollbar:1; // should inline with scrollbar? +double mfLastZoomScale = 0; +double mfAccumulatedZoom = 0; + voidInit(); voidDoAddWin( ScGridWindow* pWin ); @@ -458,6 +461,7 @@ public: SC_DLLPUBLIC void ScrollLines( tools::Long nDeltaX, tools::Long nDeltaY ); // active boolScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ); +boolGestureZoomCommand(const CommandEvent& rCEvt); voidScrollToObject( const SdrObject* pDrawObj ); voidMakeVisible( const tools::Rectangle& rHMMRect ); diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index f12327b04a5d..5b2c44ee4875 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -992,6 +992,48 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) return bDone; } +bool ScTabView::GestureZoomCommand(const CommandEvent& rCEvt) +{ +HideNoteMarker(); + +const CommandGestureZoomData* pData = rCEvt.GetGestureZoomData(); +if (!pData) +return false; + +if (aViewData.GetViewShell()->GetViewFrame()->GetFrame().IsInPlace()) +return false; + +if (pData->meEventType == GestureEventZoomType::Begin) +{ +mfLastZoomScale = pData->mfScaleDelta; +return true; +} + +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; + +const Fraction& rOldY = aViewData.GetZoomY(); +sal_uInt16 nOld = static_cast(rOldY * 100); +sal_uInt16 nNew = nOld + nZoomChangePercent; +nNew = std::clamp(nNew, MINZOOM, MAXZOOM); + +if (nNew != nOld) +{ +SetZoomPercentFromCommand(nNew); +} + +return true; +} +return true; +} + IMPL_LINK_NOARG(ScTabView, HScrollLeftHdl, weld::Scrollbar&, void) { ScrollHdl(aHScrollLeft.get());
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sc/source
sc/source/ui/inc/tabview.hxx |2 ++ sc/source/ui/view/tabview.cxx | 31 ++- 2 files changed, 20 insertions(+), 13 deletions(-) New commits: commit 269b058f3eb7b00e651d13b9735f33c1faa32e5b Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:28 2022 +0200 Commit: Caolán McNamara CommitDate: Thu Dec 15 19:33:50 2022 + sc: Extract ScTabView::SetZoomPercentFromCommand() Change-Id: I06ece9a99886d94bf0b3396730951760cb199e97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143755 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144229 Reviewed-by: Caolán McNamara diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index ebb7337d78b7..f62b2c4f9cba 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -254,6 +254,8 @@ private: voidPaintRangeFinderEntry (const ScRangeFindData* pData, SCTAB nTab); +voidSetZoomPercentFromCommand(sal_uInt16 nZoomPercent); + protected: voidUpdateHeaderWidth( const ScVSplitPos* pWhich = nullptr, const SCROW* pPosY = nullptr ); diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 94a9aa144ad6..f12327b04a5d 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -935,6 +935,23 @@ Point ScTabView::GetGridOffset() const // --- Scroll-Bars +void ScTabView::SetZoomPercentFromCommand(sal_uInt16 nZoomPercent) +{ +// scroll wheel doesn't set the AppOptions default + +bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom(); +SetZoomType(SvxZoomType::PERCENT, bSyncZoom); +Fraction aFract(nZoomPercent, 100); +SetZoom(aFract, aFract, bSyncZoom); +PaintGrid(); +PaintTop(); +PaintLeft(); +aViewData.GetBindings().Invalidate( SID_ATTR_ZOOM); +aViewData.GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER); +aViewData.GetBindings().Invalidate( SID_ZOOM_IN); +aViewData.GetBindings().Invalidate( SID_ZOOM_OUT); +} + bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) { HideNoteMarker(); @@ -957,19 +974,7 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) nNew = std::min( MAXZOOM, basegfx::zoomtools::zoomIn( nOld )); if ( nNew != nOld ) { -// scroll wheel doesn't set the AppOptions default - -bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom(); -SetZoomType( SvxZoomType::PERCENT, bSyncZoom ); -Fraction aFract( nNew, 100 ); -SetZoom( aFract, aFract, bSyncZoom ); -PaintGrid(); -PaintTop(); -PaintLeft(); -aViewData.GetBindings().Invalidate( SID_ATTR_ZOOM ); -aViewData.GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); -aViewData.GetBindings().Invalidate( SID_ZOOM_IN); -aViewData.GetBindings().Invalidate( SID_ZOOM_OUT); +SetZoomPercentFromCommand(nNew); } bDone = true;
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sw/source
sw/source/uibase/docvw/edtwin.cxx | 12 1 file changed, 12 insertions(+) New commits: commit 732aa132e37223b4ef9f73cf26018b206ebab56b Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:27 2022 +0200 Commit: Caolán McNamara CommitDate: Thu Dec 15 19:33:28 2022 + sw: React to touchpad zoom gestures in SwEditWin Change-Id: I45a3525f3db47b2ea002a592df144a83ee39fc68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143754 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144228 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 298f4da5fa45..1b59059d11e2 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -5632,6 +5632,18 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) bCallBase = !m_rView.HandleWheelCommands( rCEvt ); break; +case CommandEventId::GestureZoom: +{ +if (m_pSavedOutlineFrame && rSh.GetViewOptions()->IsShowOutlineContentVisibilityButton()) +{ + GetFrameControlsManager().RemoveControlsByType(FrameControlType::Outline, m_pSavedOutlineFrame); +m_pSavedOutlineFrame = nullptr; +} +m_pShadCursor.reset(); +bCallBase = !m_rView.HandleGestureZoomCommand(rCEvt); +break; +} + case CommandEventId::GestureLongPress: case CommandEventId::GestureSwipe: //nothing yet break;
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sw/inc sw/source
sw/inc/view.hxx |3 +++ sw/source/uibase/uiview/viewport.cxx | 30 ++ 2 files changed, 33 insertions(+) New commits: commit 3198bbd9a19d6ebbb2a5da9af9424c4cc3c25d50 Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:26 2022 +0200 Commit: Caolán McNamara CommitDate: Thu Dec 15 19:33:01 2022 + sw: React to touchpad zoom gestures in SwView Change-Id: I337e5d6873f9cf6d78cb53b2ffdb59a33a9465f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143753 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144227 Reviewed-by: Caolán McNamara diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index caaa808b6a24..c3ed0f5808d7 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -235,6 +235,8 @@ class SW_DLLPUBLIC SwView: public SfxViewShell SvxSearchCmdm_eLastSearchCommand; bool m_bWheelScrollInProgress; +double m_fLastZoomScale = 0; +double m_fAccumulatedZoom = 0; boolm_bCenterCursor : 1, m_bTopCursor : 1, @@ -470,6 +472,7 @@ public: static void SetActMark(sal_Int32 nSet); boolHandleWheelCommands( const CommandEvent& ); +boolHandleGestureZoomCommand(const CommandEvent&); // insert frames voidInsFrameMode(sal_uInt16 nCols); diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx index ff4c918c9619..2c66c52a0c96 100644 --- a/sw/source/uibase/uiview/viewport.cxx +++ b/sw/source/uibase/uiview/viewport.cxx @@ -1230,4 +1230,34 @@ bool SwView::HandleWheelCommands( const CommandEvent& rCEvt ) return bOk; } +bool SwView::HandleGestureZoomCommand(const CommandEvent& rCEvt) +{ +const CommandGestureZoomData* pData = rCEvt.GetGestureZoomData(); + +if (pData->meEventType == GestureEventZoomType::Begin) +{ +m_fLastZoomScale = pData->mfScaleDelta; +return true; +} + +if (pData->meEventType == GestureEventZoomType::Update) +{ +double deltaBetweenEvents = (pData->mfScaleDelta - m_fLastZoomScale) / m_fLastZoomScale; +m_fLastZoomScale = pData->mfScaleDelta; + +// Accumulate fractional zoom to avoid small zoom changes from being ignored +m_fAccumulatedZoom += deltaBetweenEvents; +int nZoomChangePercent = m_fAccumulatedZoom * 100; +m_fAccumulatedZoom -= nZoomChangePercent / 100.0; + +sal_uInt16 nFact = m_pWrtShell->GetViewOptions()->GetZoom(); +nFact += nZoomChangePercent; +nFact = std::clamp(nFact, MIN_ZOOM_PERCENT, MAX_ZOOM_PERCENT); +SetZoom(SvxZoomType::PERCENT, nFact); + +return true; +} +return true; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sw/inc sw/source
sw/inc/view.hxx |3 +++ sw/source/uibase/uiview/viewport.cxx |4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) New commits: commit b05c184d52f72a1e8b8d34586eeffe55adcb1857 Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:25 2022 +0200 Commit: Caolán McNamara CommitDate: Thu Dec 15 19:32:37 2022 + sw: Extract SwView::{MIN,MAX}_ZOOM_PERCENT constants Change-Id: Id593752274121ad41dcdeb215be410a3577d890a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143752 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144226 Reviewed-by: Caolán McNamara diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index c2d3772b7578..caaa808b6a24 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -268,6 +268,9 @@ class SW_DLLPUBLIC SwView: public SfxViewShell int m_nMaxOutlineLevelShown = 10; +static constexpr sal_uInt16 MAX_ZOOM_PERCENT = 600; +static constexpr sal_uInt16 MIN_ZOOM_PERCENT = 20; + // methods for searching // set search context SAL_DLLPRIVATE bool SearchAndWrap(bool bApi); diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx index 9b7bb9120f04..ff4c918c9619 100644 --- a/sw/source/uibase/uiview/viewport.cxx +++ b/sw/source/uibase/uiview/viewport.cxx @@ -1197,9 +1197,9 @@ bool SwView::HandleWheelCommands( const CommandEvent& rCEvt ) { sal_uInt16 nFact = m_pWrtShell->GetViewOptions()->GetZoom(); if( 0L > pWData->GetDelta() ) -nFact = std::max( static_cast(20), basegfx::zoomtools::zoomOut( nFact )); +nFact = std::max(MIN_ZOOM_PERCENT, basegfx::zoomtools::zoomOut( nFact )); else -nFact = std::min( static_cast(600), basegfx::zoomtools::zoomIn( nFact )); +nFact = std::min(MAX_ZOOM_PERCENT, basegfx::zoomtools::zoomIn( nFact )); SetZoom( SvxZoomType::PERCENT, nFact ); bOk = true;
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sd/source
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 AuthorDate: Wed Dec 7 03:13:24 2022 +0200 Commit: Caolán McNamara CommitDate: Thu Dec 15 19:32:16 2022 + 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 Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144225 Reviewed-by: Caolán McNamara 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 mxOldFunction; std::unique_ptr mpZoomList; double mfLastZoomScale; +double mfAccumulatedZoom = 0; Point maViewPos; SizemaViewSize; 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);
Re: Touchpad gesture support (e.g. for zooming via touchpad pinch gestures)
Hi Tomaž, On 2022-12-14 16:03, Tomaž Vajngerl wrote: > Hi Povilas, > > On Tue, Dec 13, 2022 at 11:52 PM Povilas Kanapickas <mailto:povi...@radix.lt>> wrote: > > Hello, > > The touchpad zomming support for Libreoffice Writer, Calc, Draw and Math > main documents has been implemented. The code is in > https://gerrit.libreoffice.org/c/core/+/143759/1 > <https://gerrit.libreoffice.org/c/core/+/143759/1> and other 8 > changes in > the chain. > > > Merged, thanks for that. You just missed the branch point and feature > freeze, so the patches are now targeted to be released in Libreoffice 7.6. > Maybe also good to write about your changes into the release notes [1]. Thanks for suggestion, I've just did that. Regards, Povilas
[Libreoffice-commits] core.git: starmath/inc starmath/source
starmath/inc/view.hxx|2 ++ starmath/source/view.cxx | 29 - 2 files changed, 30 insertions(+), 1 deletion(-) New commits: commit 4368c4bf80b2751705c500f2574d9cc3d0ee13a1 Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:32 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Dec 14 13:50:43 2022 + 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 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 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; }
[Libreoffice-commits] core.git: vcl/unx
vcl/unx/gtk3/gtkinst.cxx | 47 +++ 1 file changed, 47 insertions(+) New commits: commit 7d5841b435a6794e30f02b62db15660ffe4ee39e Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:31 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Dec 14 13:50:05 2022 + vcl: Implement touchpad zoom gesture support in GtkInstanceDrawingArea Change-Id: I5ad68ee424fbcc45a3e56045f00ac41cf6c80195 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143758 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index f44240e216bc..ca08ce4d37f6 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -18089,6 +18089,7 @@ private: gulong m_nPopupMenu; gulong m_nScrollEvent; #endif +GtkGesture *m_pZoomGesture; #if GTK_CHECK_VERSION(4, 0, 0) static void signalDraw(GtkDrawingArea*, cairo_t *cr, int /*width*/, int /*height*/, gpointer widget) @@ -18214,6 +18215,38 @@ private: } #endif +bool handleSignalZoom(GtkGesture* gesture, GdkEventSequence* sequence, + GestureEventZoomType eEventType) +{ +gdouble x = 0; +gdouble y = 0; +gtk_gesture_get_point(gesture, sequence, , ); + +double fScaleDelta = gtk_gesture_zoom_get_scale_delta(GTK_GESTURE_ZOOM(gesture)); + +CommandGestureZoomData aGestureData(x, y, eEventType, fScaleDelta); +CommandEvent aCEvt(Point(x, y), CommandEventId::GestureZoom, true, ); +return m_aCommandHdl.Call(aCEvt); +} + +static bool signalZoomBegin(GtkGesture* gesture, GdkEventSequence* sequence, gpointer widget) +{ +GtkInstanceDrawingArea* pThis = static_cast(widget); +return pThis->handleSignalZoom(gesture, sequence, GestureEventZoomType::Begin); +} + +static bool signalZoomUpdate(GtkGesture* gesture, GdkEventSequence* sequence, gpointer widget) +{ +GtkInstanceDrawingArea* pThis = static_cast(widget); +return pThis->handleSignalZoom(gesture, sequence, GestureEventZoomType::Update); +} + +static bool signalZoomEnd(GtkGesture* gesture, GdkEventSequence* sequence, gpointer widget) +{ +GtkInstanceDrawingArea* pThis = static_cast(widget); +return pThis->handleSignalZoom(gesture, sequence, GestureEventZoomType::End); +} + #if GTK_CHECK_VERSION(4, 0, 0) static void signalResize(GtkDrawingArea*, int nWidth, int nHeight, gpointer widget) { @@ -18244,7 +18277,19 @@ public: gtk_drawing_area_set_draw_func(m_pDrawingArea, signalDraw, this, nullptr); #else m_nDrawSignalId = g_signal_connect(m_pDrawingArea, "draw", G_CALLBACK(signalDraw), this); +gtk_widget_add_events(GTK_WIDGET(pDrawingArea), GDK_TOUCHPAD_GESTURE_MASK); #endif + +ensureMouseEventWidget(); +m_pZoomGesture = gtk_gesture_zoom_new(m_pMouseEventBox); + gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(m_pZoomGesture), + GTK_PHASE_TARGET); +// Note that the default zoom gesture signal handler needs to run first to setup correct +// scale delta. Otherwise the first "begin" event will always contain scale delta of infinity. +g_signal_connect_after(m_pZoomGesture, "begin", G_CALLBACK(signalZoomBegin), this); +g_signal_connect_after(m_pZoomGesture, "update", G_CALLBACK(signalZoomUpdate), this); +g_signal_connect_after(m_pZoomGesture, "end", G_CALLBACK(signalZoomEnd), this); + gtk_widget_set_has_tooltip(m_pWidget, true); g_object_set_data(G_OBJECT(m_pDrawingArea), "g-lo-GtkInstanceDrawingArea", this); m_xDevice->EnableRTL(get_direction()); @@ -18433,6 +18478,8 @@ public: virtual ~GtkInstanceDrawingArea() override { +g_clear_object(_pZoomGesture); + ImplGetDefaultWindow()->RemoveEventListener(LINK(this, GtkInstanceDrawingArea, SettingsChangedHdl)); g_object_steal_data(G_OBJECT(m_pDrawingArea), "g-lo-GtkInstanceDrawingArea");
[Libreoffice-commits] core.git: sc/source
sc/source/ui/view/gridwin.cxx |9 + 1 file changed, 9 insertions(+) New commits: commit ccfb36da48a938c7d95b3d6af5862b14721208ef Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:30 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Dec 14 13:49:00 2022 + sc: React to touchpad zoom gestures in ScGridWindow Change-Id: I21f0e6a820149abe4457950e7382bbc7752eeb6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143757 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 5fe0a4edd7c9..3316afdf95e4 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -3035,6 +3035,15 @@ void ScGridWindow::Command( const CommandEvent& rCEvt ) Window::Command(rCEvt); return; } + +if (nCmd == CommandEventId::GestureZoom) +{ +bool bDone = mrViewData.GetView()->GestureZoomCommand(rCEvt); +if (!bDone) +Window::Command(rCEvt); +return; +} + // #i7560# FormulaMode check is below scrolling - scrolling is allowed during formula input bool bDisable = pScMod->IsFormulaMode() || pScMod->IsModalMode(mrViewData.GetSfxDocShell());
[Libreoffice-commits] core.git: sc/source
sc/source/ui/inc/tabview.hxx |4 sc/source/ui/view/tabview.cxx | 42 ++ 2 files changed, 46 insertions(+) New commits: commit 90f5ecbbdb202ec4fbee9e1416f9268aa1dc56ba Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:29 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Dec 14 13:48:41 2022 + sc: React to touchpad zoom gestures in ScTabView Change-Id: I9a946c0caf3aab03a2055740a4f467210dc07b6a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143756 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index f62b2c4f9cba..7fdb0cc3c2c2 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -214,6 +214,9 @@ private: boolbBlockRows:1; // are whole rows selected? boolmbInlineWithScrollbar:1; // should inline with scrollbar? +double mfLastZoomScale = 0; +double mfAccumulatedZoom = 0; + voidInit(); voidDoAddWin( ScGridWindow* pWin ); @@ -458,6 +461,7 @@ public: SC_DLLPUBLIC void ScrollLines( tools::Long nDeltaX, tools::Long nDeltaY ); // active boolScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ); +boolGestureZoomCommand(const CommandEvent& rCEvt); voidScrollToObject( const SdrObject* pDrawObj ); voidMakeVisible( const tools::Rectangle& rHMMRect ); diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index f12327b04a5d..5b2c44ee4875 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -992,6 +992,48 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) return bDone; } +bool ScTabView::GestureZoomCommand(const CommandEvent& rCEvt) +{ +HideNoteMarker(); + +const CommandGestureZoomData* pData = rCEvt.GetGestureZoomData(); +if (!pData) +return false; + +if (aViewData.GetViewShell()->GetViewFrame()->GetFrame().IsInPlace()) +return false; + +if (pData->meEventType == GestureEventZoomType::Begin) +{ +mfLastZoomScale = pData->mfScaleDelta; +return true; +} + +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; + +const Fraction& rOldY = aViewData.GetZoomY(); +sal_uInt16 nOld = static_cast(rOldY * 100); +sal_uInt16 nNew = nOld + nZoomChangePercent; +nNew = std::clamp(nNew, MINZOOM, MAXZOOM); + +if (nNew != nOld) +{ +SetZoomPercentFromCommand(nNew); +} + +return true; +} +return true; +} + IMPL_LINK_NOARG(ScTabView, HScrollLeftHdl, weld::Scrollbar&, void) { ScrollHdl(aHScrollLeft.get());
[Libreoffice-commits] core.git: sc/source
sc/source/ui/inc/tabview.hxx |2 ++ sc/source/ui/view/tabview.cxx | 31 ++- 2 files changed, 20 insertions(+), 13 deletions(-) New commits: commit f87a0480af5b15d673490a5b1736133148ec7333 Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:28 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Dec 14 13:46:49 2022 + sc: Extract ScTabView::SetZoomPercentFromCommand() Change-Id: I06ece9a99886d94bf0b3396730951760cb199e97 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143755 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx index ebb7337d78b7..f62b2c4f9cba 100644 --- a/sc/source/ui/inc/tabview.hxx +++ b/sc/source/ui/inc/tabview.hxx @@ -254,6 +254,8 @@ private: voidPaintRangeFinderEntry (const ScRangeFindData* pData, SCTAB nTab); +voidSetZoomPercentFromCommand(sal_uInt16 nZoomPercent); + protected: voidUpdateHeaderWidth( const ScVSplitPos* pWhich = nullptr, const SCROW* pPosY = nullptr ); diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx index 94a9aa144ad6..f12327b04a5d 100644 --- a/sc/source/ui/view/tabview.cxx +++ b/sc/source/ui/view/tabview.cxx @@ -935,6 +935,23 @@ Point ScTabView::GetGridOffset() const // --- Scroll-Bars +void ScTabView::SetZoomPercentFromCommand(sal_uInt16 nZoomPercent) +{ +// scroll wheel doesn't set the AppOptions default + +bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom(); +SetZoomType(SvxZoomType::PERCENT, bSyncZoom); +Fraction aFract(nZoomPercent, 100); +SetZoom(aFract, aFract, bSyncZoom); +PaintGrid(); +PaintTop(); +PaintLeft(); +aViewData.GetBindings().Invalidate( SID_ATTR_ZOOM); +aViewData.GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER); +aViewData.GetBindings().Invalidate( SID_ZOOM_IN); +aViewData.GetBindings().Invalidate( SID_ZOOM_OUT); +} + bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) { HideNoteMarker(); @@ -957,19 +974,7 @@ bool ScTabView::ScrollCommand( const CommandEvent& rCEvt, ScSplitPos ePos ) nNew = std::min( MAXZOOM, basegfx::zoomtools::zoomIn( nOld )); if ( nNew != nOld ) { -// scroll wheel doesn't set the AppOptions default - -bool bSyncZoom = SC_MOD()->GetAppOptions().GetSynchronizeZoom(); -SetZoomType( SvxZoomType::PERCENT, bSyncZoom ); -Fraction aFract( nNew, 100 ); -SetZoom( aFract, aFract, bSyncZoom ); -PaintGrid(); -PaintTop(); -PaintLeft(); -aViewData.GetBindings().Invalidate( SID_ATTR_ZOOM ); -aViewData.GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER ); -aViewData.GetBindings().Invalidate( SID_ZOOM_IN); -aViewData.GetBindings().Invalidate( SID_ZOOM_OUT); +SetZoomPercentFromCommand(nNew); } bDone = true;
[Libreoffice-commits] core.git: sw/source
sw/source/uibase/docvw/edtwin.cxx | 12 1 file changed, 12 insertions(+) New commits: commit cedf0458966b6e7e4398b45ee77f77053d43e79c Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:27 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Dec 14 13:46:21 2022 + sw: React to touchpad zoom gestures in SwEditWin Change-Id: I45a3525f3db47b2ea002a592df144a83ee39fc68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143754 Tested-by: Tomaž Vajngerl Reviewed-by: Tomaž Vajngerl diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 298f4da5fa45..1b59059d11e2 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -5632,6 +5632,18 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) bCallBase = !m_rView.HandleWheelCommands( rCEvt ); break; +case CommandEventId::GestureZoom: +{ +if (m_pSavedOutlineFrame && rSh.GetViewOptions()->IsShowOutlineContentVisibilityButton()) +{ + GetFrameControlsManager().RemoveControlsByType(FrameControlType::Outline, m_pSavedOutlineFrame); +m_pSavedOutlineFrame = nullptr; +} +m_pShadCursor.reset(); +bCallBase = !m_rView.HandleGestureZoomCommand(rCEvt); +break; +} + case CommandEventId::GestureLongPress: case CommandEventId::GestureSwipe: //nothing yet break;
[Libreoffice-commits] core.git: sw/inc sw/source
sw/inc/view.hxx |3 +++ sw/source/uibase/uiview/viewport.cxx | 30 ++ 2 files changed, 33 insertions(+) New commits: commit 9807fbfb56edd9998d3e8757b11f50cfa6887535 Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:26 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Dec 14 13:44:32 2022 + sw: React to touchpad zoom gestures in SwView Change-Id: I337e5d6873f9cf6d78cb53b2ffdb59a33a9465f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143753 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index caaa808b6a24..c3ed0f5808d7 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -235,6 +235,8 @@ class SW_DLLPUBLIC SwView: public SfxViewShell SvxSearchCmdm_eLastSearchCommand; bool m_bWheelScrollInProgress; +double m_fLastZoomScale = 0; +double m_fAccumulatedZoom = 0; boolm_bCenterCursor : 1, m_bTopCursor : 1, @@ -470,6 +472,7 @@ public: static void SetActMark(sal_Int32 nSet); boolHandleWheelCommands( const CommandEvent& ); +boolHandleGestureZoomCommand(const CommandEvent&); // insert frames voidInsFrameMode(sal_uInt16 nCols); diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx index ff4c918c9619..2c66c52a0c96 100644 --- a/sw/source/uibase/uiview/viewport.cxx +++ b/sw/source/uibase/uiview/viewport.cxx @@ -1230,4 +1230,34 @@ bool SwView::HandleWheelCommands( const CommandEvent& rCEvt ) return bOk; } +bool SwView::HandleGestureZoomCommand(const CommandEvent& rCEvt) +{ +const CommandGestureZoomData* pData = rCEvt.GetGestureZoomData(); + +if (pData->meEventType == GestureEventZoomType::Begin) +{ +m_fLastZoomScale = pData->mfScaleDelta; +return true; +} + +if (pData->meEventType == GestureEventZoomType::Update) +{ +double deltaBetweenEvents = (pData->mfScaleDelta - m_fLastZoomScale) / m_fLastZoomScale; +m_fLastZoomScale = pData->mfScaleDelta; + +// Accumulate fractional zoom to avoid small zoom changes from being ignored +m_fAccumulatedZoom += deltaBetweenEvents; +int nZoomChangePercent = m_fAccumulatedZoom * 100; +m_fAccumulatedZoom -= nZoomChangePercent / 100.0; + +sal_uInt16 nFact = m_pWrtShell->GetViewOptions()->GetZoom(); +nFact += nZoomChangePercent; +nFact = std::clamp(nFact, MIN_ZOOM_PERCENT, MAX_ZOOM_PERCENT); +SetZoom(SvxZoomType::PERCENT, nFact); + +return true; +} +return true; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
[Libreoffice-commits] core.git: sw/inc sw/source
sw/inc/view.hxx |3 +++ sw/source/uibase/uiview/viewport.cxx |4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) New commits: commit 0280538af13617145987663ad6407190939794f2 Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:25 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Dec 14 13:41:34 2022 + sw: Extract SwView::{MIN,MAX}_ZOOM_PERCENT constants Change-Id: Id593752274121ad41dcdeb215be410a3577d890a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143752 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx index c2d3772b7578..caaa808b6a24 100644 --- a/sw/inc/view.hxx +++ b/sw/inc/view.hxx @@ -268,6 +268,9 @@ class SW_DLLPUBLIC SwView: public SfxViewShell int m_nMaxOutlineLevelShown = 10; +static constexpr sal_uInt16 MAX_ZOOM_PERCENT = 600; +static constexpr sal_uInt16 MIN_ZOOM_PERCENT = 20; + // methods for searching // set search context SAL_DLLPRIVATE bool SearchAndWrap(bool bApi); diff --git a/sw/source/uibase/uiview/viewport.cxx b/sw/source/uibase/uiview/viewport.cxx index 9b7bb9120f04..ff4c918c9619 100644 --- a/sw/source/uibase/uiview/viewport.cxx +++ b/sw/source/uibase/uiview/viewport.cxx @@ -1197,9 +1197,9 @@ bool SwView::HandleWheelCommands( const CommandEvent& rCEvt ) { sal_uInt16 nFact = m_pWrtShell->GetViewOptions()->GetZoom(); if( 0L > pWData->GetDelta() ) -nFact = std::max( static_cast(20), basegfx::zoomtools::zoomOut( nFact )); +nFact = std::max(MIN_ZOOM_PERCENT, basegfx::zoomtools::zoomOut( nFact )); else -nFact = std::min( static_cast(600), basegfx::zoomtools::zoomIn( nFact )); +nFact = std::min(MAX_ZOOM_PERCENT, basegfx::zoomtools::zoomIn( nFact )); SetZoom( SvxZoomType::PERCENT, nFact ); bOk = true;
[Libreoffice-commits] core.git: sd/source
sd/source/ui/inc/ViewShell.hxx |1 + sd/source/ui/view/viewshel.cxx |7 ++- 2 files changed, 7 insertions(+), 1 deletion(-) New commits: commit 45d861a38d7cd3031bd577fd954b11e5d7a99f8d Author: Povilas Kanapickas AuthorDate: Wed Dec 7 03:13:24 2022 +0200 Commit: Tomaž Vajngerl CommitDate: Wed Dec 14 13:41:17 2022 + 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 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 mxOldFunction; std::unique_ptr mpZoomList; double mfLastZoomScale; +double mfAccumulatedZoom = 0; Point maViewPos; SizemaViewSize; 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);
Re: Touchpad gesture support (e.g. for zooming via touchpad pinch gestures)
Hello, The touchpad zomming support for Libreoffice Writer, Calc, Draw and Math main documents has been implemented. The code is in https://gerrit.libreoffice.org/c/core/+/143759/1 and other 8 changes in the chain. Cheers, Povilas On 2022-08-25 13:15, Povilas Kanapickas wrote: > Hello, > > I would like to implement support for touchpad gesture handling to > LibreOffice. This is useful e.g. for zooming views using two-finger > pinch touchpad gesture or rotating objects using two-finger rotate gesture. > > I have implemented this functionality in GIMP and would like to do the > same for LibreOffice. In LibreOffice case the implementation will be > more complex, as there are more backends than just GTK, but this will > just require more work. > > There is a proof of concept implementation that wires touchpad gestures > on GTK to the ViewShell widget. As a result it's possible to use > touchpad pinch gesture to zoom in-out the main slide in Impress. > > https://gerrit.libreoffice.org/c/core/+/138791/1 (note that > implementation is split across 5 changes in the chain). > > Please let me know what do you think about this problem and the proof of > concept solution. > > I would like to eventually add touchpad gesture support to all UI > elements of LibreOffice where that makes sense. > > Cheers, > Povilas >
[Libreoffice-commits] core.git: compilerplugins/clang include/vcl sc/source sd/source sw/source vcl/inc vcl/source vcl/unx
compilerplugins/clang/unusedmethods.results |2 +- include/vcl/commandevent.hxx| 12 ++-- sc/source/ui/app/inputwin.cxx |4 ++-- sd/source/ui/inc/slideshow.hxx |4 ++-- sd/source/ui/slideshow/slideshow.cxx|2 +- sd/source/ui/slideshow/slideshowimpl.cxx|2 +- sd/source/ui/slideshow/slideshowimpl.hxx|2 +- sd/source/ui/view/viewshel.cxx |4 ++-- sw/source/uibase/docvw/edtwin.cxx |2 +- vcl/inc/salwtype.hxx|4 ++-- vcl/source/window/commandevent.cxx |6 +++--- vcl/source/window/winproc.cxx | 16 vcl/unx/gtk3/gtkframe.cxx |4 ++-- 13 files changed, 32 insertions(+), 32 deletions(-) New commits: commit d752cb42473547872741c74a70809f28f9fe789c Author: Povilas Kanapickas AuthorDate: Fri Sep 2 00:04:42 2022 +0300 Commit: Noel Grandin CommitDate: Mon Sep 5 16:22:31 2022 +0200 vcl: Rename LongPress event to GestureLongPress We have 5 gesture types: GestureZoom, GestureRotate, GesturePan, GestureSwipe and LongPress. For consistency all of these will use Gesture as a prefix to reduce confusion and for easier grepping throughout the codebase. Change-Id: I8b9e245d011203a19c1172f9833c172f65382cab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139244 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/compilerplugins/clang/unusedmethods.results b/compilerplugins/clang/unusedmethods.results index 7c0f0279d085..98c1d36bd64a 100644 --- a/compilerplugins/clang/unusedmethods.results +++ b/compilerplugins/clang/unusedmethods.results @@ -2047,7 +2047,7 @@ include/vcl/commandevent.hxx:256 include/vcl/commandevent.hxx:276 CommandGestureSwipeData::CommandGestureSwipeData() include/vcl/commandevent.hxx:293 - CommandLongPressData::CommandLongPressData() + CommandGestureLongPressData::CommandGestureLongPressData() include/vcl/cursor.hxx:96 _Bool vcl::Cursor::operator!=(const vcl::Cursor &) const include/vcl/customweld.hxx:45 diff --git a/include/vcl/commandevent.hxx b/include/vcl/commandevent.hxx index d8c2b702987e..d5b043ddb97a 100644 --- a/include/vcl/commandevent.hxx +++ b/include/vcl/commandevent.hxx @@ -39,7 +39,7 @@ class CommandDialogData; class CommandMediaData; class CommandSelectionChangeData; class CommandGestureSwipeData; -class CommandLongPressData; +class CommandGestureLongPressData; class CommandGesturePanData; class CommandGestureZoomData; class CommandGestureRotateData; @@ -92,7 +92,7 @@ public: CommandMediaData* GetMediaData() const; const CommandSelectionChangeData* GetSelectionChangeData() const; const CommandGestureSwipeData* GetGestureSwipeData() const; -const CommandLongPressData* GetLongPressData() const; +const CommandGestureLongPressData* GetLongPressData() const; const CommandGesturePanData*GetGesturePanData() const; const CommandGestureZoomData* GetGestureZoomData() const; const CommandGestureRotateData* GetGestureRotateData() const; @@ -291,17 +291,17 @@ public: }; -class VCL_DLLPUBLIC CommandLongPressData +class VCL_DLLPUBLIC CommandGestureLongPressData { double mnX; double mnY; public: -CommandLongPressData() +CommandGestureLongPressData() : mnX(0) , mnY(0) { } -CommandLongPressData(double nX, double nY) +CommandGestureLongPressData(double nX, double nY) : mnX(nX) , mnY(nY) { @@ -384,7 +384,7 @@ enum class CommandEventId PrepareReconversion = 19, QueryCharPosition = 20, GestureSwipe= 21, -LongPress = 22, +GestureLongPress= 22, GesturePan = 23, GestureZoom = 24, GestureRotate = 25, diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 55e40f0f25d2..6b695c05bebb 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1764,9 +1764,9 @@ bool ScTextWnd::Command( const CommandEvent& rCEvt ) { //don't call InputChanged for CommandEventId::GestureSwipe } -else if ( nCommand == CommandEventId::LongPress ) +else if ( nCommand == CommandEventId::GestureLongPress ) { -//don't call InputChanged for CommandEventId::LongPress +//don't call InputChanged for CommandEventId::GestureLongPress } else if ( nCommand == CommandEventId::ModKeyChange ) { diff --git a/sd/source/ui/inc/slideshow.hxx b/sd/source/ui/inc/slideshow.hxx index 2f127f4610a3..afbfee68469b 100644 --- a/sd/source/ui/inc/slideshow.hxx +++ b/sd/source/ui/inc/slideshow.hxx @@ -49,7 +49,7 @@ namespace vcl { class Window; } class SfxRequest; class WorkWindow; class CommandGestureSwipeData
[Libreoffice-commits] core.git: compilerplugins/clang include/vcl sc/source sd/source sw/source vcl/inc vcl/source vcl/unx
compilerplugins/clang/unusedfields.writeonly.results |2 +- compilerplugins/clang/unusedmethods.results |2 +- include/vcl/commandevent.hxx | 12 ++-- sc/source/ui/app/inputwin.cxx|4 ++-- sd/source/ui/inc/slideshow.hxx |4 ++-- sd/source/ui/slideshow/slideshow.cxx |2 +- sd/source/ui/slideshow/slideshowimpl.cxx |2 +- sd/source/ui/slideshow/slideshowimpl.hxx |2 +- sd/source/ui/view/viewshel.cxx |4 ++-- sw/source/uibase/docvw/edtwin.cxx|2 +- vcl/inc/salwtype.hxx |4 ++-- vcl/source/window/commandevent.cxx |6 +++--- vcl/source/window/winproc.cxx| 16 vcl/unx/gtk3/gtkframe.cxx|4 ++-- 14 files changed, 33 insertions(+), 33 deletions(-) New commits: commit 35319adcc28f197b73e146f9ba233e20616fd11f Author: Povilas Kanapickas AuthorDate: Fri Sep 2 00:04:41 2022 +0300 Commit: Noel Grandin CommitDate: Mon Sep 5 16:21:49 2022 +0200 vcl: Rename Swipe event to GestureSwipe We have 5 gesture types: GestureZoom, GestureRotate, GesturePan, Swipe and LongPress. For consistency all of these will use Gesture as a prefix to reduce confusion and for easier grepping throughout the codebase. Change-Id: I8b9e245d011203a19c1172f9833c172f65382caa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139243 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/compilerplugins/clang/unusedfields.writeonly.results b/compilerplugins/clang/unusedfields.writeonly.results index 33f995f77007..ccc4881de531 100644 --- a/compilerplugins/clang/unusedfields.writeonly.results +++ b/compilerplugins/clang/unusedfields.writeonly.results @@ -1077,7 +1077,7 @@ vcl/inc/salwtype.hxx:226 vcl/inc/salwtype.hxx:239 SalInputContext mpFont rtl::Reference vcl/inc/salwtype.hxx:246 -SalSwipeEvent mnVelocityY double +SalGestureSwipeEvent mnVelocityY double vcl/inc/scanlinewriter.hxx:35 vcl::ScanlineWriter mpCurrentScanline sal_uInt8 * vcl/inc/svdata.hxx:464 diff --git a/compilerplugins/clang/unusedmethods.results b/compilerplugins/clang/unusedmethods.results index 1dd04177ee82..7c0f0279d085 100644 --- a/compilerplugins/clang/unusedmethods.results +++ b/compilerplugins/clang/unusedmethods.results @@ -2045,7 +2045,7 @@ include/vcl/commandevent.hxx:249 include/vcl/commandevent.hxx:256 _Bool CommandMediaData::GetPassThroughToOS() const include/vcl/commandevent.hxx:276 - CommandSwipeData::CommandSwipeData() + CommandGestureSwipeData::CommandGestureSwipeData() include/vcl/commandevent.hxx:293 CommandLongPressData::CommandLongPressData() include/vcl/cursor.hxx:96 diff --git a/include/vcl/commandevent.hxx b/include/vcl/commandevent.hxx index 9708ab818101..d8c2b702987e 100644 --- a/include/vcl/commandevent.hxx +++ b/include/vcl/commandevent.hxx @@ -38,7 +38,7 @@ class CommandModKeyData; class CommandDialogData; class CommandMediaData; class CommandSelectionChangeData; -class CommandSwipeData; +class CommandGestureSwipeData; class CommandLongPressData; class CommandGesturePanData; class CommandGestureZoomData; @@ -91,7 +91,7 @@ public: const CommandDialogData*GetDialogData() const; CommandMediaData* GetMediaData() const; const CommandSelectionChangeData* GetSelectionChangeData() const; -const CommandSwipeData* GetSwipeData() const; +const CommandGestureSwipeData* GetGestureSwipeData() const; const CommandLongPressData* GetLongPressData() const; const CommandGesturePanData*GetGesturePanData() const; const CommandGestureZoomData* GetGestureZoomData() const; @@ -275,15 +275,15 @@ public: sal_uLong GetEnd() const { return mnEnd; } }; -class VCL_DLLPUBLIC CommandSwipeData +class VCL_DLLPUBLIC CommandGestureSwipeData { double mnVelocityX; public: -CommandSwipeData() +CommandGestureSwipeData() : mnVelocityX(0) { } -CommandSwipeData(double nVelocityX) +CommandGestureSwipeData(double nVelocityX) : mnVelocityX(nVelocityX) { } @@ -383,7 +383,7 @@ enum class CommandEventId SelectionChange = 18, PrepareReconversion = 19, QueryCharPosition = 20, -Swipe = 21, +GestureSwipe= 21, LongPress = 22, GesturePan = 23, GestureZoom = 24, diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx index 384753ad0745..55e40f0f25d2 100644 --- a/sc/source/ui/app/inputwin.cxx +++ b/sc/source/ui/app/inputwin.cxx @@ -1760,9 +1760,9 @@ bool ScTextWnd::Command( const CommandEvent& rCEvt ) { //don't
[Libreoffice-commits] core.git: include/vcl
include/vcl/GestureEventPan.hxx |5 + 1 file changed, 1 insertion(+), 4 deletions(-) New commits: commit 231342ef6a913f0a5c9dfea3bd28830e92a3fc98 Author: Povilas Kanapickas AuthorDate: Fri Sep 2 00:04:40 2022 +0300 Commit: Noel Grandin CommitDate: Mon Sep 5 16:20:51 2022 +0200 vcl: Use #pragma once on GestureEventPan.hxx The header guard macro name no longer matches file name. Instead of updating, just use #pragma once. Change-Id: I2dfb3fc0d73f5de7f7b31c4b0fb9a3ba5f2966af Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139242 Tested-by: Noel Grandin Reviewed-by: Noel Grandin diff --git a/include/vcl/GestureEventPan.hxx b/include/vcl/GestureEventPan.hxx index 23ad80986d1f..4ce0866a91f3 100644 --- a/include/vcl/GestureEventPan.hxx +++ b/include/vcl/GestureEventPan.hxx @@ -8,8 +8,7 @@ * */ -#ifndef INCLUDED_VCL_GESTUREEVENT_HXX -#define INCLUDED_VCL_GESTUREEVENT_HXX +#pragma once #include @@ -56,6 +55,4 @@ public: } }; -#endif // INCLUDED_VCL_GESTUREEVENT_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
[Libreoffice-commits] core.git: bin/find-can-be-private-symbols.functions.results compilerplugins/clang desktop/source include/vcl vcl/inc vcl/source
bin/find-can-be-private-symbols.functions.results |2 - compilerplugins/clang/constantparam.numbers.results |2 - compilerplugins/clang/unusedenumconstants.writeonly.results |4 +- compilerplugins/clang/unusedfields.only-used-in-constructor.results |6 +-- compilerplugins/clang/unusedfields.untouched.results|6 +-- desktop/source/lib/init.cxx | 10 ++--- include/vcl/GestureEventPan.hxx | 20 +- include/vcl/commandevent.hxx| 15 --- include/vcl/svapp.hxx |5 +- vcl/inc/salwtype.hxx|6 +-- vcl/source/app/svapp.cxx|9 ++-- vcl/source/control/imp_listbox.cxx |2 - vcl/source/edit/vclmedit.cxx|2 - vcl/source/treelist/svimpbox.cxx|2 - vcl/source/window/commandevent.cxx |6 +-- vcl/source/window/window2.cxx | 10 ++--- vcl/source/window/winproc.cxx | 16 17 files changed, 63 insertions(+), 60 deletions(-) New commits: commit 99b85a2eda006a59306042dad5b0b1de116febf3 Author: Povilas Kanapickas AuthorDate: Fri Sep 2 00:04:39 2022 +0300 Commit: Noel Grandin CommitDate: Mon Sep 5 16:20:03 2022 +0200 vcl: Rename Gesture event to GesturePan We have 5 gesture types: GestureZoom, GestureRotate, Gesture (for panning), Swipe and LongPress. For consistency all of these will use Gesture as a prefix to reduce confusion and for easier grepping throughout the codebase. Change-Id: I8b9e245d011203a19c1172f9833c172f65382ca9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139241 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/bin/find-can-be-private-symbols.functions.results b/bin/find-can-be-private-symbols.functions.results index 477c1971f137..89e04cb7696a 100644 --- a/bin/find-can-be-private-symbols.functions.results +++ b/bin/find-can-be-private-symbols.functions.results @@ -267,7 +267,7 @@ ComboBox::SetWidthInChars(int) ComboBox::setMaxWidthChars(int) CommandEvent::CommandEvent() CommandEvent::GetAutoScrollData() const -CommandEvent::GetGestureData() const +CommandEvent::GetGesturePanData() const CommandExtTextInputData::CommandExtTextInputData(CommandExtTextInputData const&) CommandWheelData::CommandWheelData() CompressGraphicsDialog::Compress(SvStream&) diff --git a/compilerplugins/clang/constantparam.numbers.results b/compilerplugins/clang/constantparam.numbers.results index 34a32601044d..4dab02d8179c 100644 --- a/compilerplugins/clang/constantparam.numbers.results +++ b/compilerplugins/clang/constantparam.numbers.results @@ -1487,7 +1487,7 @@ include/vcl/print.hxx:667 int i_nMaxValue 1000 include/vcl/svapp.hxx:752 -struct ImplSVEvent * Application::PostGestureEvent(enum VclEventId,class vcl::Window *,const class GestureEvent *) +struct ImplSVEvent * Application::PostGestureEvent(enum VclEventId,class vcl::Window *,const class GestureEventPan *) enum VclEventId nEvent 130 include/vcl/texteng.hxx:132 diff --git a/compilerplugins/clang/unusedenumconstants.writeonly.results b/compilerplugins/clang/unusedenumconstants.writeonly.results index b4f02f215137..e22323c9d683 100644 --- a/compilerplugins/clang/unusedenumconstants.writeonly.results +++ b/compilerplugins/clang/unusedenumconstants.writeonly.results @@ -2900,9 +2900,9 @@ include/vcl/formatter.hxx:120 enum Formatter::valueState valueDirty include/vcl/gdimtf.hxx:48 enum MtfConversion N8BitGreys -include/vcl/GestureEvent.hxx:25 +include/vcl/GestureEventPan.hxx:25 enum PanningOrientation Horizontal -include/vcl/GestureEvent.hxx:26 +include/vcl/GestureEventPan.hxx:26 enum PanningOrientation Vertical include/vcl/GraphicObject.hxx:40 enum GraphicAdjustmentFlags ALL diff --git a/compilerplugins/clang/unusedfields.only-used-in-constructor.results b/compilerplugins/clang/unusedfields.only-used-in-constructor.results index 858713811d6b..d22fb2d35d4d 100644 --- a/compilerplugins/clang/unusedfields.only-used-in-constructor.results +++ b/compilerplugins/clang/unusedfields.only-used-in-constructor.results @@ -373,11 +373,11 @@ include/svx/ClassificationDialog.hxx:37 include/svx/imapdlg.hxx:91 SvxIMapDlg aIMapItem SvxIMapDlgItem include/vcl/commandevent.hxx:310 -CommandGestureData mfX const double +CommandGesturePanData mfX const double include/vcl/commandevent.hxx:311 -CommandGestureData mfY const double +CommandGesturePanData mfY const double include/vcl/commandevent.hxx:314 -CommandGestureData meOri
Re: Touchpad gesture support (e.g. for zooming via touchpad pinch gestures)
On 2022-08-26 10:30, Tomaž Vajngerl wrote: > Hi Povilas, > > On Fri, Aug 26, 2022 at 12:04 AM Povilas Kanapickas <mailto:povi...@radix.lt>> wrote: > > Hi Tomaž, > > I can do either approach as you please. The reason why I created > separate event types for each gesture type was the experience when > implementing touchpad gestures for the X server. Putting all data into a > single struct becomes hard to manage in the end, because it's not > obvious what data each logical event carries and as consequence code > becomes error prone and harder to refactor. > > > Right, this is always an issue, but then I thought we could do something > inside GestureEvent to make this easier (some data class hierarchy for > each gesture or something like that). > > > > Please let me know if I should just put everything into the Gesture > class though. You know better which approach will be easier to maintain > in the specific case of LibreOffice project. > > > I merged those patches, so I guess I'm fine with that. :) There are > already separate LongPress and Swipe events too. We can always change it > later - it's not a big deal. Thanks. Would you mind if I rename LongPress and Swipe to GestureLongPress and GestureSwipe for consistency? Thanks, Povilas
[Libreoffice-commits] core.git: sd/source
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 AuthorDate: Thu Aug 25 00:18:32 2022 +0300 Commit: Caolán McNamara 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 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 mxCurrentFunction; rtl::Reference mxOldFunction; std::unique_ptr mpZoomList; +double mfLastZoomScale; Point maViewPos; SizemaViewSize; 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(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; }
[Libreoffice-commits] core.git: vcl/inc vcl/unx
vcl/inc/unx/gtk/gtkframe.hxx |5 + vcl/unx/gtk3/gtkframe.cxx| 43 +++ 2 files changed, 48 insertions(+) New commits: commit e6bed4293814dd58f0a7d050e8057e717d03faab Author: Povilas Kanapickas AuthorDate: Thu Aug 25 00:18:31 2022 +0300 Commit: Caolán McNamara CommitDate: Fri Aug 26 22:32:29 2022 +0200 vcl: implement touchpad rotate gesture support on gtk backend This change is enough to support both touchpad and touchscreen gestures, but currently GDK_TOUCH_MASK is not enabled, so only touchpad gestures are supported. Change-Id: Ia36b64cd891321d3a5420ea81dca236c936d9af3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138790 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index 52f256082832..29e1899df9de 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -353,6 +353,10 @@ class GtkSalFrame final : public SalFrame static bool signalZoomUpdate(GtkGesture*, GdkEventSequence*, gpointer); static bool signalZoomEnd(GtkGesture*, GdkEventSequence*, gpointer); +static bool signalRotateBegin(GtkGesture*, GdkEventSequence*, gpointer); +static bool signalRotateUpdate(GtkGesture*, GdkEventSequence*, gpointer); +static bool signalRotateEnd(GtkGesture*, GdkEventSequence*, gpointer); + #if !GTK_CHECK_VERSION(4, 0, 0) static gboolean signalConfigure( GtkWidget*, GdkEventConfigure*, gpointer ); #endif @@ -440,6 +444,7 @@ public: std::vector m_aMouseSignalIds; GtkGesture *m_pZoomGesture; +GtkGesture *m_pRotateGesture; void grabPointer(bool bGrab, bool bKeyboardAlso, bool bOwnerEvents); diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx index a387f9979d47..65f113ab1c33 100644 --- a/vcl/unx/gtk3/gtkframe.cxx +++ b/vcl/unx/gtk3/gtkframe.cxx @@ -714,6 +714,7 @@ GtkSalFrame::~GtkSalFrame() g_signal_handler_disconnect(G_OBJECT(pEventWidget), handler_id); g_clear_object(_pZoomGesture); +g_clear_object(_pRotateGesture); #if !GTK_CHECK_VERSION(4, 0, 0) if( m_pFixedContainer ) @@ -1030,6 +1031,13 @@ void GtkSalFrame::InitCommon() g_signal_connect_after(m_pZoomGesture, "update", G_CALLBACK(signalZoomUpdate), this); g_signal_connect_after(m_pZoomGesture, "end", G_CALLBACK(signalZoomEnd), this); +m_pRotateGesture = gtk_gesture_rotate_new(GTK_WIDGET(pEventWidget)); + gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(m_pRotateGesture), + GTK_PHASE_TARGET); +g_signal_connect(m_pRotateGesture, "begin", G_CALLBACK(signalRotateBegin), this); +g_signal_connect(m_pRotateGesture, "update", G_CALLBACK(signalRotateUpdate), this); +g_signal_connect(m_pRotateGesture, "end", G_CALLBACK(signalRotateEnd), this); + //Drop Target Stuff #if GTK_CHECK_VERSION(4,0,0) GtkDropTargetAsync* pDropTarget = gtk_drop_target_async_new(nullptr, GdkDragAction(GDK_ACTION_ALL)); @@ -4545,6 +4553,23 @@ namespace pThis->CallCallbackExc(SalEvent::GestureZoom, ); return true; } + +bool handleSignalRotate(GtkGesture* gesture, GdkEventSequence* sequence, gpointer frame, +GestureEventRotateType eEventType) +{ +gdouble x = 0; +gdouble y = 0; +gtk_gesture_get_point(gesture, sequence, , ); + +SalGestureRotateEvent aEvent; +aEvent.meEventType = eEventType; +aEvent.mnX = x; +aEvent.mnY = y; +aEvent.mfAngleDelta = gtk_gesture_rotate_get_angle_delta(GTK_GESTURE_ROTATE(gesture)); +GtkSalFrame* pThis = static_cast(frame); +pThis->CallCallbackExc(SalEvent::GestureRotate, ); +return true; +} } bool GtkSalFrame::signalZoomBegin(GtkGesture* gesture, GdkEventSequence* sequence, gpointer frame) @@ -4562,6 +4587,24 @@ bool GtkSalFrame::signalZoomEnd(GtkGesture* gesture, GdkEventSequence* sequence, return handleSignalZoom(gesture, sequence, frame, GestureEventZoomType::End); } +bool GtkSalFrame::signalRotateBegin(GtkGesture* gesture, GdkEventSequence* sequence, +gpointer frame) +{ +return handleSignalRotate(gesture, sequence, frame, GestureEventRotateType::Begin); +} + +bool GtkSalFrame::signalRotateUpdate(GtkGesture* gesture, GdkEventSequence* sequence, + gpointer frame) +{ +return handleSignalRotate(gesture, sequence, frame, GestureEventRotateType::Update); +} + +bool GtkSalFrame::signalRotateEnd(GtkGesture* gesture, GdkEventSequence* sequence, + gpointer frame) +{ +return handleSignalRotate(gesture, sequence, frame, GestureEven
[Libreoffice-commits] core.git: vcl/inc vcl/unx
vcl/inc/unx/gtk/gtkframe.hxx |7 ++ vcl/unx/gtk3/gtkframe.cxx| 49 ++- 2 files changed, 55 insertions(+), 1 deletion(-) New commits: commit f2bd19f6720239db228cd4388be8e928505c51b6 Author: Povilas Kanapickas AuthorDate: Thu Aug 25 00:18:30 2022 +0300 Commit: Caolán McNamara CommitDate: Fri Aug 26 22:32:03 2022 +0200 vcl: implement touchpad zoom gesture support on gtk backend Note that this does not support touchscreen gestures. Enabling support for touchscreen gestures requires enabling GDK_TOUCH_MASK which has higher regression potential for touchscreen users, so it has not been done yet. Change-Id: I1baab36804230484394e638bf8bfb8c7a7ddabe0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138789 Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index 57072134c414..52f256082832 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -348,6 +348,11 @@ class GtkSalFrame final : public SalFrame static gboolean signalWindowState( GtkWidget*, GdkEvent*, gpointer ); #endif + +static bool signalZoomBegin(GtkGesture*, GdkEventSequence*, gpointer); +static bool signalZoomUpdate(GtkGesture*, GdkEventSequence*, gpointer); +static bool signalZoomEnd(GtkGesture*, GdkEventSequence*, gpointer); + #if !GTK_CHECK_VERSION(4, 0, 0) static gboolean signalConfigure( GtkWidget*, GdkEventConfigure*, gpointer ); #endif @@ -434,6 +439,8 @@ public: guint m_nHudAwarenessId; std::vector m_aMouseSignalIds; +GtkGesture *m_pZoomGesture; + void grabPointer(bool bGrab, bool bKeyboardAlso, bool bOwnerEvents); static GtkSalDisplay* getDisplay(); diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx index dbd868c6fd6a..a387f9979d47 100644 --- a/vcl/unx/gtk3/gtkframe.cxx +++ b/vcl/unx/gtk3/gtkframe.cxx @@ -712,6 +712,9 @@ GtkSalFrame::~GtkSalFrame() GtkWidget *pEventWidget = getMouseEventWidget(); for (auto handler_id : m_aMouseSignalIds) g_signal_handler_disconnect(G_OBJECT(pEventWidget), handler_id); + +g_clear_object(_pZoomGesture); + #if !GTK_CHECK_VERSION(4, 0, 0) if( m_pFixedContainer ) gtk_widget_destroy( GTK_WIDGET( m_pFixedContainer ) ); @@ -1018,6 +1021,15 @@ void GtkSalFrame::InitCommon() gtk_widget_add_controller(pEventWidget, pScrollController); #endif +m_pZoomGesture = gtk_gesture_zoom_new(GTK_WIDGET(pEventWidget)); + gtk_event_controller_set_propagation_phase(GTK_EVENT_CONTROLLER(m_pZoomGesture), + GTK_PHASE_TARGET); +// Note that the default zoom gesture signal handler needs to run first to setup correct +// scale delta. Otherwise the first "begin" event will always contain scale delta of infinity. +g_signal_connect_after(m_pZoomGesture, "begin", G_CALLBACK(signalZoomBegin), this); +g_signal_connect_after(m_pZoomGesture, "update", G_CALLBACK(signalZoomUpdate), this); +g_signal_connect_after(m_pZoomGesture, "end", G_CALLBACK(signalZoomEnd), this); + //Drop Target Stuff #if GTK_CHECK_VERSION(4,0,0) GtkDropTargetAsync* pDropTarget = gtk_drop_target_async_new(nullptr, GdkDragAction(GDK_ACTION_ALL)); @@ -1139,7 +1151,7 @@ void GtkSalFrame::InitCommon() gtk_widget_add_events( m_pWindow, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | - GDK_SCROLL_MASK + GDK_SCROLL_MASK | GDK_TOUCHPAD_GESTURE_MASK ); #endif @@ -4515,6 +4527,41 @@ void GtkSalFrame::signalWindowState(GdkToplevel* pSurface, GParamSpec*, gpointer } #endif +namespace +{ +bool handleSignalZoom(GtkGesture* gesture, GdkEventSequence* sequence, gpointer frame, + GestureEventZoomType eEventType) +{ +gdouble x = 0; +gdouble y = 0; +gtk_gesture_get_point(gesture, sequence, , ); + +SalGestureZoomEvent aEvent; +aEvent.meEventType = eEventType; +aEvent.mnX = x; +aEvent.mnY = y; +aEvent.mfScaleDelta = gtk_gesture_zoom_get_scale_delta(GTK_GESTURE_ZOOM(gesture)); +GtkSalFrame* pThis = static_cast(frame); +pThis->CallCallbackExc(SalEvent::GestureZoom, ); +return true; +} +} + +bool GtkSalFrame::signalZoomBegin(GtkGesture* gesture, GdkEventSequence* sequence, gpointer frame) +{ +return handleSignalZoom(gesture, sequence, frame, GestureEventZoomType::Begin); +} + +bool GtkSalFrame::signalZoomUpdate(GtkGesture* gesture, GdkEventSequence* sequence, gpointer frame) +{ +retur
[Libreoffice-commits] core.git: 2 commits - include/vcl vcl/inc vcl/source
include/vcl/GestureEventRotate.hxx | 46 include/vcl/GestureEventZoom.hxx | 46 include/vcl/commandevent.hxx | 41 + vcl/inc/salwtype.hxx | 20 ++ vcl/source/window/commandevent.cxx | 15 +++ vcl/source/window/winproc.cxx | 70 + 6 files changed, 238 insertions(+) New commits: commit 85b65b90ac10d39190097af87a2de609e87eea9c Author: Povilas Kanapickas AuthorDate: Thu Aug 25 00:18:29 2022 +0300 Commit: Tomaž Vajngerl CommitDate: Fri Aug 26 09:12:54 2022 +0200 vcl: implement rotate gesture infrastructure This change implements internal infrastructure to pass rotate gestures from low-level sources to the consuming GUI widgets. The API follows the established begin-update-update-...-end event convention that is used on various platforms. The API should be enough to support bouth touchpad and touchscreen gestures, as long as the underlying low-level source exposes enough information. The hardware drivers usually expose touchpad gestures already recognized whereas touchscreen gestures come as a set of moving touchpoints and application needs to figure out their meaning itself. Many toolkits recognize both and offer a unified higher-level interface that can be used by us. Change-Id: Iae667b3248d6f78bfb1eef755af6bc996432b6a7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138788 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/include/vcl/GestureEventRotate.hxx b/include/vcl/GestureEventRotate.hxx new file mode 100644 index ..39f4b310f973 --- /dev/null +++ b/include/vcl/GestureEventRotate.hxx @@ -0,0 +1,46 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include + +enum class GestureEventRotateType +{ +Begin, +Update, +End +}; + +class VCL_DLLPUBLIC GestureEventRotate +{ +public: +sal_Int32 mnX = 0; +sal_Int32 mnY = 0; + +GestureEventRotateType meEventType = GestureEventRotateType::Begin; + +// The difference of between the current gesture scale and the scale at the beginning of the +// gesture. +double mfAngleDelta = 0; + +GestureEventRotate() = default; + +GestureEventRotate(sal_Int32 nInitialX, sal_Int32 nInitialY, GestureEventRotateType eEventType, + double fAngleDelta) +: mnX(nInitialX) +, mnY(nInitialY) +, meEventType(eEventType) +, mfAngleDelta(fAngleDelta) +{ +} +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/commandevent.hxx b/include/vcl/commandevent.hxx index 71694cc6f087..7b3199b18ccd 100644 --- a/include/vcl/commandevent.hxx +++ b/include/vcl/commandevent.hxx @@ -29,6 +29,7 @@ #include #include #include +#include class CommandExtTextInputData; class CommandWheelData; @@ -41,6 +42,7 @@ class CommandSwipeData; class CommandLongPressData; class CommandGestureData; class CommandGestureZoomData; +class CommandGestureRotateData; enum class CommandEventId; @@ -93,6 +95,7 @@ public: const CommandLongPressData* GetLongPressData() const; const CommandGestureData* GetGestureData() const; const CommandGestureZoomData* GetGestureZoomData() const; +const CommandGestureRotateData* GetGestureRotateData() const; }; class VCL_DLLPUBLIC CommandExtTextInputData @@ -341,6 +344,23 @@ public: {} }; +class VCL_DLLPUBLIC CommandGestureRotateData +{ +public: +const double mfX = 0; +const double mfY = 0; +const GestureEventRotateType meEventType = GestureEventRotateType::Begin; +const double mfAngleDelta = 0; + +CommandGestureRotateData(double fX, double fY, GestureEventRotateType eEventType, + double fAngleDelta) +: mfX(fX) +, mfY(fY) +, meEventType(eEventType) +, mfAngleDelta(fAngleDelta) +{} +}; + enum class CommandEventId { NONE= 0, @@ -366,6 +386,7 @@ enum class CommandEventId LongPress = 22, Gesture = 23, GestureZoom = 24, +GestureRotate = 25, }; #endif // INCLUDED_VCL_COMMANDEVENT_HXX diff --git a/vcl/inc/salwtype.hxx b/vcl/inc/salwtype.hxx index d920a16dc5d4..7b66ef5a2d45 100644 --- a/vcl/inc/salwtype.hxx +++ b/vcl/inc/salwtype.hxx @@ -27,6 +27,7 @@ #include #include #include +#include class LogicalFontInstance; class SalGraphics; @@ -93,6 +94,7 @@ enum class SalEvent { ExternalGesture, Gesture
Re: Touchpad gesture support (e.g. for zooming via touchpad pinch gestures)
Hi Tomaž, On 2022-08-25 20:23, Tomaž Vajngerl wrote: > Hi, > > On Thu, Aug 25, 2022 at 12:16 PM Povilas Kanapickas <mailto:povi...@radix.lt>> wrote: > > Hello, > > I would like to implement support for touchpad gesture handling to > LibreOffice. This is useful e.g. for zooming views using two-finger > pinch touchpad gesture or rotating objects using two-finger rotate > gesture. > > I have implemented this functionality in GIMP and would like to do the > same for LibreOffice. In LibreOffice case the implementation will be > more complex, as there are more backends than just GTK, but this will > just require more work. > > There is a proof of concept implementation that wires touchpad gestures > on GTK to the ViewShell widget. As a result it's possible to use > touchpad pinch gesture to zoom in-out the main slide in Impress. > > https://gerrit.libreoffice.org/c/core/+/138791/1 > <https://gerrit.libreoffice.org/c/core/+/138791/1> (note that > implementation is split across 5 changes in the chain). > > Please let me know what do you think about this problem and the proof of > concept solution. > > > Looks great. > > The reason why GestureEvent is called so generally is that there should > only be one common gesture event for all types of gestures - even if > that would also mean it would have all the member variables of all the > gestures - for simplicity. But I guess that approach is also ok... Thanks a lot for very fast reply. I can do either approach as you please. The reason why I created separate event types for each gesture type was the experience when implementing touchpad gestures for the X server. Putting all data into a single struct becomes hard to manage in the end, because it's not obvious what data each logical event carries and as consequence code becomes error prone and harder to refactor. Please let me know if I should just put everything into the Gesture class though. You know better which approach will be easier to maintain in the specific case of LibreOffice project. Thanks a lot, Povilas
Touchpad gesture support (e.g. for zooming via touchpad pinch gestures)
Hello, I would like to implement support for touchpad gesture handling to LibreOffice. This is useful e.g. for zooming views using two-finger pinch touchpad gesture or rotating objects using two-finger rotate gesture. I have implemented this functionality in GIMP and would like to do the same for LibreOffice. In LibreOffice case the implementation will be more complex, as there are more backends than just GTK, but this will just require more work. There is a proof of concept implementation that wires touchpad gestures on GTK to the ViewShell widget. As a result it's possible to use touchpad pinch gesture to zoom in-out the main slide in Impress. https://gerrit.libreoffice.org/c/core/+/138791/1 (note that implementation is split across 5 changes in the chain). Please let me know what do you think about this problem and the proof of concept solution. I would like to eventually add touchpad gesture support to all UI elements of LibreOffice where that makes sense. Cheers, Povilas
Povilas Kanapickas license statement
All of my past & future contributions to LibreOffice may be licensed under the MPLv2/LGPLv3+ dual license. Regards, Povilas Kanapickas
License statement
All of my past and future contributions to LibreOffice may be licensed under the MPL/LGPLv3+ dual license. Cheers, Povilas ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [Libreoffice] [PATCH] removed a lot of dead code and bogus comments
I was also interested in things like the UI string changes in binfilters - what was all that about ? :-) That was certainly not intended. It seems my editor has screwed up as it somehow didn't like some files. It couldn't open them using UTF-8, so I forced another encoding. That might be the reason for these differences, however I still don't understand how could that cause any changes to the files. Regards, Povilas ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice