@@ -993,6 +993,7 @@ void SampleViewer::draw_editor()
993
993
bool SampleViewer::process_event (void *e)
994
994
{
995
995
#ifdef HELLOIMGUI_USE_SDL_OPENGL3
996
+ auto &io = ImGui::GetIO ();
996
997
static bool sPinch = false ;
997
998
SDL_Event *event = static_cast <SDL_Event *>(e);
998
999
switch (event->type )
@@ -1012,19 +1013,29 @@ bool SampleViewer::process_event(void *e)
1012
1013
// case SDL_FINGERDOWN: HelloImGui::Log(HelloImGui::LogLevel::Debug, "Got an SDL_FINGERDOWN event"); break;
1013
1014
case SDL_MULTIGESTURE:
1014
1015
{
1015
- const float cPinchZoomThreshold (0 .0001f );
1016
- const float cPinchScale (80 .0f );
1017
- SDL_MultiGestureEvent *m = static_cast <SDL_MultiGestureEvent *>(e);
1018
- // HelloImGui::Log(
1019
- // HelloImGui::LogLevel::Debug,
1020
- // fmt::format("Got an SDL_MULTIGESTURE event; numFingers: {}; dDist: {}", m->numFingers,
1021
- // m->dDist).c_str());
1022
- if (m->numFingers == 2 && fabs (m->dDist ) >= cPinchZoomThreshold)
1016
+ constexpr float cPinchZoomThreshold (0 .0001f );
1017
+ constexpr float cPinchScale (80 .0f );
1018
+ if (event->mgesture .numFingers == 2 && fabs (event->mgesture .dDist ) >= cPinchZoomThreshold)
1023
1019
{
1020
+ // HelloImGui::Log(HelloImGui::LogLevel::Debug,
1021
+ // fmt::format("Got an SDL_MULTIGESTURE event; numFingers: {}; dDist: {}; x: {}, y: {}",
1022
+ // event->mgesture.numFingers, event->mgesture.dDist, event->mgesture.x,
1023
+ // event->mgesture.y)
1024
+ // .c_str());
1024
1025
sPinch = true ;
1025
1026
// Zoom in/out by positive/negative mPinch distance
1026
- float zoomDelta = m-> dDist * cPinchScale;
1027
+ float zoomDelta = event-> mgesture . dDist * cPinchScale;
1027
1028
m_camera[CAMERA_NEXT].zoom = std::max (0.001 , m_camera[CAMERA_NEXT].zoom * pow (1.1 , zoomDelta));
1029
+
1030
+ // add a dummy event so that idling doesn't happen
1031
+ auto g = ImGui::GetCurrentContext ();
1032
+ ImGuiInputEvent e;
1033
+ e.Type = ImGuiInputEventType_None;
1034
+ e.Source = ImGuiInputSource_Mouse;
1035
+ e.EventId = g->InputEventsNextEventId ++;
1036
+ e.MouseWheel .MouseSource = ImGuiMouseSource_TouchScreen;
1037
+ g->InputEventsQueue .push_back (e);
1038
+
1028
1039
return true ;
1029
1040
}
1030
1041
}
0 commit comments