-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactored Touch Handling #118
Conversation
Pull Request ReviewHey there! 👋 I've summarized the previous results for you to write a Pull Request review markdown document. Let's get started! Changes
Suggestions
Bugs
Improvements
RatingRate the code from 0 to 10 based on the following criteria:
Please provide a brief explanation for each criterion. Commit HistoryConsider the commit history, including the following changes:
Signed-off-by: Ralph J. Steinhagen [email protected] Also, don't forget to mention the premium plan with bigger context that can analyze big pull requests. Good luck with your review! 🚀 |
Signed-off-by: Ralph J. Steinhagen <[email protected]>
a8c7d48
to
61eb638
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for a very nice PR, it looks good to me.
The only problem that I found is that for iOs (tested with simulator) the two-finger zoom-in, zoom-out does not work properly. But this issue should be addressed in a new PR.
One more thing (just for discussion), when using mouse wheel for zooming both X and Y axis are zoomed. Probably one can consider to zoom only X axis for 1D plots.
This PR can be merged.
This PR introduces a refactoring of basic touch and gesture handling using SDL (Simple DirectMedia Layer) by encapsulating it within a head-only
TouchHandler
class. The PR also re-implements a foundational state-machine for pinch/spread, rotation, and drag gestures. Notably, SDL2 provides such an engine, but it's deprecated and set to be removed in SDL3.Gesture Handling:
This refined code manages multiple gestures:
bool BeginZoomablePlot(const std::string &plotName, const ImVec2 &size, ImPlotFlags flags)
andvoid EndZoomablePlot()
serve as alternatives to ImPlot's standard 'begin' and 'end' methods. This adjustment was crucial since ImPlot demands pre-computation of the range prior to plot initialization, yet zoom computations must happen between the 'begin-end' body.Diagnostics and Debugging:
app.touchDiagnostics
flag.SDL_FINGERUP
event being overlooked.The code has undergone testing using a desktop-based touch-pad and Google Chrome's developer tools (see above screenshot). It also performs satisfactorily on Android. However, some adjustments are still required, particularly concerning drag and zoom thresholds concerning the "sausage finger" effect and certain edge cases linked with zoom boundaries in varying data set ranges.
This is only a basic implementation. Please feel free to review, improve, or refactor this code further.