Open aranega opened 3 months ago
Thanks @aranega for the PR ❤️ This is something that would benefit issue #23 as you pointed out
I'll take a detailed look later this week
@aranega I'm curious to see the video, but my browser and QuickTime both refuse to play it. Could you kindly check the format?
@olavolav Sure no problem, I think I had the same kind of problems in the past with Firefox (video that refuses to load). I re-encoded it, it should work this time (hopefully)
https://github.com/olavolav/uniplot/assets/2317394/5c67a606-6d37-4e71-8fe7-dd394733eca9
@aranega Apologies for the slow response. I love what you built here! 😄
Having thought about the best way to do this, I think I would like to have a slightly more generic system of lifecycle hooks. I'll have a go at it in the next weeks.
This PR adds a concept of custom widgets that let users create their own interaction with the interactive graph. The implementation is pretty straightforward, it only relies on passing objects here and there to check for registered keys and call the related function/method.
Here is an example of how to create a simple "Exapand" widget that zoom or unzoom only on the x axis and how to register it on the plot:
As other example, here is how to consider WASD keypresses along with the HJKL already existing (as answer to #23)
Here is another example of a simple widget, and how it can be composed into another one to make a "line marker", where you can use the "+", "-" keys to go forward/backward and mark some zones. The "line marker" widget is built on another one "line widget", which can be used without the line marker one, showing that it's possible to create a set of widgets and reuse them (more or less)
The following video shows an small PoC I made loading a MP3, displaying the two channels waveform thanks to uniplot and navigating/marking zones. I didn't include the code of this PoC here as it relies on other modifications I made on uniplot for non-blocking keypress and another kind of widget that do not require a key to be pressed to activate/redraw/update.
https://github.com/olavolav/uniplot/assets/2317394/75624c8f-ce88-4d44-b340-f65132040c56