diff options
author | Povilas Kanapickas <povilas@radix.lt> | 2022-08-25 00:18:29 +0300 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2022-08-26 09:12:54 +0200 |
commit | 85b65b90ac10d39190097af87a2de609e87eea9c (patch) | |
tree | e3a8c381e43da7237bf04f1f61ee868166e4699a /vcl | |
parent | 474414919c102f2973d2ed9815f997fdb1f30d9c (diff) |
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 <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/salwtype.hxx | 10 | ||||
-rw-r--r-- | vcl/source/window/commandevent.cxx | 7 | ||||
-rw-r--r-- | vcl/source/window/winproc.cxx | 35 |
3 files changed, 52 insertions, 0 deletions
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 <tools/long.hxx> #include <vcl/GestureEvent.hxx> #include <vcl/GestureEventZoom.hxx> +#include <vcl/GestureEventRotate.hxx> class LogicalFontInstance; class SalGraphics; @@ -93,6 +94,7 @@ enum class SalEvent { ExternalGesture, Gesture, GestureZoom, + GestureRotate, }; struct SalAbstractMouseEvent @@ -273,6 +275,14 @@ struct SalGestureZoomEvent double mfScaleDelta = 0; }; +struct SalGestureRotateEvent +{ + GestureEventRotateType meEventType = GestureEventRotateType::Begin; + tools::Long mnX = 0; + tools::Long mnY = 0; + double mfAngleDelta = 0; +}; + typedef void (*SALTIMERPROC)(); #endif // INCLUDED_VCL_INC_SALWTYPE_HXX diff --git a/vcl/source/window/commandevent.cxx b/vcl/source/window/commandevent.cxx index aeedcc79c197..5fdb5e9e41a1 100644 --- a/vcl/source/window/commandevent.cxx +++ b/vcl/source/window/commandevent.cxx @@ -203,5 +203,12 @@ const CommandGestureZoomData* CommandEvent::GetGestureZoomData() const return nullptr; } +const CommandGestureRotateData* CommandEvent::GetGestureRotateData() const +{ + if (mnCommand == CommandEventId::GestureRotate) + return static_cast<const CommandGestureRotateData*>(mpData); + else + return nullptr; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index 945cae89e76e..d98b8c2fae42 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -33,6 +33,7 @@ #include <vcl/event.hxx> #include <vcl/GestureEvent.hxx> #include <vcl/GestureEventZoom.hxx> +#include <vcl/GestureEventRotate.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <vcl/cursor.hxx> @@ -1848,6 +1849,34 @@ static bool ImplHandleGestureZoomEvent(vcl::Window* pWindow, const SalGestureZoo return aHandler.HandleEvent(); } +namespace { + +class HandleGestureRotateEvent : public HandleGestureEvent +{ +private: + CommandGestureRotateData m_aGestureData; + +public: + HandleGestureRotateEvent(vcl::Window* pWindow, const SalGestureRotateEvent& rEvent) + : HandleGestureEvent(pWindow, Point(rEvent.mnX, rEvent.mnY)) + , m_aGestureData(rEvent.mnX, rEvent.mnY, rEvent.meEventType, rEvent.mfAngleDelta) + { + } + + virtual bool CallCommand(vcl::Window* pWindow, const Point& /*rMousePos*/) override + { + return ImplCallCommand(pWindow, CommandEventId::GestureRotate, &m_aGestureData); + } +}; + +} + +static bool ImplHandleGestureRotateEvent(vcl::Window* pWindow, const SalGestureRotateEvent& rEvent) +{ + HandleGestureRotateEvent aHandler(pWindow, rEvent); + return aHandler.HandleEvent(); +} + static void ImplHandlePaint( vcl::Window* pWindow, const tools::Rectangle& rBoundRect, bool bImmediateUpdate ) { // system paint events must be checked for re-mirroring @@ -2908,6 +2937,12 @@ bool ImplWindowFrameProc( vcl::Window* _pWindow, SalEvent nEvent, const void* pE bRet = ImplHandleGestureZoomEvent(pWindow, *pGestureEvent); } break; + case SalEvent::GestureRotate: + { + const auto * pGestureEvent = static_cast<SalGestureRotateEvent const *>(pEvent); + bRet = ImplHandleGestureRotateEvent(pWindow, *pGestureEvent); + } + break; default: SAL_WARN( "vcl.layout", "ImplWindowFrameProc(): unknown event (" << static_cast<int>(nEvent) << ")" ); break; |