diff --git a/lib/aux_vis.cpp b/lib/aux_vis.cpp index 8c886ade..6e597a6f 100644 --- a/lib/aux_vis.cpp +++ b/lib/aux_vis.cpp @@ -1356,8 +1356,9 @@ void KeyCtrlP() #endif } -void KeyQPressed() +void KeyQPressed(SDL_Keymod state) { + if (state & KMOD_SHIFT) { return Window::SwitchSolution(); } wnd->signalQuit(); visualize = 0; } diff --git a/lib/aux_vis.hpp b/lib/aux_vis.hpp index 98f48cb0..eb68471e 100644 --- a/lib/aux_vis.hpp +++ b/lib/aux_vis.hpp @@ -68,7 +68,7 @@ void TouchPinch(SDL_MultiGestureEvent & e); void KeyCtrlP(); void KeyS(); -void KeyQPressed(); +void KeyQPressed(SDL_Keymod); void ToggleThreads(); void ThreadsPauseFunc(SDL_Keymod); void ThreadsStop(); diff --git a/lib/glwindow.hpp b/lib/glwindow.hpp index b0da9d50..c9abd6ff 100644 --- a/lib/glwindow.hpp +++ b/lib/glwindow.hpp @@ -95,11 +95,15 @@ class GLWindow void setOnIdle(IdleDelegate func) { onIdle = func; } void setOnExpose(Delegate func) { onExpose = func; } + void setOnKeyDown(SDL_Keycode key, KeyDelegate func) + { + onKeyDown[key] = [func](SDL_Keymod) { func(SDL_GetModState()); }; + } + void setOnKeyDown(SDL_Keycode key, Delegate func) { onKeyDown[key] = [func](SDL_Keymod) { func(); }; } - void setOnKeyDown(SDL_Keycode key, KeyDelegate func) { onKeyDown[key] = func; } void setOnMouseDown(SDL_Mousebutton btn, MouseDelegate func) { onMouseDown[btn] = func; } void setOnMouseUp(SDL_Mousebutton btn, MouseDelegate func) { onMouseUp[btn] = func; } diff --git a/lib/window.cpp b/lib/window.cpp index 3b850b15..b2e42132 100644 --- a/lib/window.cpp +++ b/lib/window.cpp @@ -270,3 +270,9 @@ void Window::SwitchQuadSolution() locwin->SwitchQuadSolution((DataState::QuadSolution)iqs); SendExposeEvent(); } + +void Window::SwitchSolution() +{ + if (locwin->data_state.cgrid_f) { SwitchComplexSolution(); } + if (locwin->data_state.quad_f) { SwitchQuadSolution(); } +} diff --git a/lib/window.hpp b/lib/window.hpp index 9e81cc06..feb2a7f9 100644 --- a/lib/window.hpp +++ b/lib/window.hpp @@ -93,6 +93,10 @@ struct Window /// @note: Use with caution when the update is compatible /// @see SetNewMeshAndSolution() void ResetMeshAndSolution(DataState &ss); + +public: + /// Switch the function representation for key handlers + static void SwitchSolution(); }; #endif // GLVIS_WINDOW_HPP