Browse Source

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.
pull/651/head
Vladimír Vondruš 2 years ago
parent
commit
9988200bf2
  1. 12
      src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp

12
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} {

Loading…
Cancel
Save