From 9988200bf2b85a41d7bd5ab17acae429fd0360c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 11 Oct 2024 23:30:04 +0200 Subject: [PATCH] Platform: test the Sdl2Application::multiGestureEvent() as well. The distance reported by it is useless for any practical purpose because it doesn't report a ratio of the current and previous radius between all points, but rather the distance. Which, well, have fun using for any sort of zooming. (And yeah, given that the MultiGestureEvent is gone in SDL3, I spent quite some time looking at what it actually did in order to reimplement that functionality on my end, and it felt *extremely weird* to me that it always considered just that single point, never the others in order to calculate any sort of radius. This is why, because it never considered any sort of radius between the points, so the "Multi" in there is highly questionable!) So this test is just to make the uselessness easy to verify, nothing more. --- src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp b/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp index 3ae58db5a..977e30652 100644 --- a/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp +++ b/src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp @@ -210,10 +210,14 @@ struct Sdl2ApplicationTest: Platform::Application { /* For testing event coordinates */ void mousePressEvent(MouseEvent& event) override { Debug{} << "mouse press event:" << event.position() << Int(event.button()); + _gestureDistance = {}; + _gestureRotation = {}; } void mouseReleaseEvent(MouseEvent& event) override { Debug{} << "mouse release event:" << event.position() << Int(event.button()); + _gestureDistance = {}; + _gestureRotation = {}; } void mouseMoveEvent(MouseMoveEvent& event) override { @@ -224,6 +228,12 @@ struct Sdl2ApplicationTest: Platform::Application { Debug{} << "mouse scroll event:" << event.offset() << event.position(); } + void multiGestureEvent(MultiGestureEvent& event) override { + Debug{} << "multi gesture:" << event.center() << "rotation:" << Deg{_gestureRotation} << Debug::nospace << ", relative" << Deg{event.relativeRotation()} << Debug::nospace << ", distance" << _gestureDistance << Debug::nospace << ", relative" << event.relativeDistance() << Debug::nospace << ", fingers" << event.fingerCount(); + _gestureDistance += event.relativeDistance(); + _gestureRotation += Rad(event.relativeRotation()); + } + void keyPressEvent(KeyEvent& event) override { Debug{} << "key press event:" << event.key() << "keycode:" << SDL_Keycode(event.key()) << event.keyName() << "scancode:" << event.event().key.keysym.scancode #ifndef CORRADE_TARGET_EMSCRIPTEN @@ -340,6 +350,8 @@ struct Sdl2ApplicationTest: Platform::Application { #ifndef CORRADE_TARGET_EMSCRIPTEN bool _vsync = false; #endif + Float _gestureDistance{}; + Rad _gestureRotation{}; }; Sdl2ApplicationTest::Sdl2ApplicationTest(const Arguments& arguments): Platform::Application{arguments, NoCreate} {