feat: re-implement UI EventRecorder, EventCounter and EventPlayer (#1122)#1126
feat: re-implement UI EventRecorder, EventCounter and EventPlayer (#1122)#1126AdityaGupta716 wants to merge 11 commits intofury-gl:v2from
Conversation
6362f77 to
dcaa0cd
Compare
|
@maharshi-gor @ganimtron-10 Please review :)and abt that 1 failing check it seems to pass locally maybe its some rendering issue specific to the windows runner and if u think there should be changes somewhere plz remind i will be happy to change . |
maharshi-gor
left a comment
There was a problem hiding this comment.
Hello @AdityaGupta716 Thanks for the initiation.
This PR uses a lot of classes and types.
Fury does not include any classes. Please review this and update the PR accordingly.
fury/ui/tests/test_event_recorder.py
Outdated
| """Tests for fury.ui.event_recorder. | ||
|
|
||
| Follows the FURY v2 test style (no display required — all mocked). | ||
| Event API matches rendercanvas EventEmitter (dict-based) + pygfx actors | ||
| (object-based). | ||
|
|
||
| Run from repo root: | ||
| python -m pytest fury/ui/tests/test_event_recorder.py -v | ||
| """ | ||
|
|
||
| from __future__ import annotations |
There was a problem hiding this comment.
Fury never uses any types so this is not required.
Also fury only supports python version 3.11+ which do not require this change
|
Hi @AdityaGupta716, Continuing on @maharshi-gor's comment, we don't use Mocks for testing. Also, it would be better to have this event recorder integrated with some UI elements so we can actually trigger and replay events to test things properly. About the failing tests you'll need to look into those. They are specific to your PR and aren't happening elsewhere, so they are likely caused by your changes. Also, since they are failing on Windows, they probably passed locally if you're using a different OS. |
…ventions - Remove all type annotations (List, Dict, Optional, Callable, from __future__) - Replace frozen dataclass RecordedEvent with plain immutable class using __slots__ - Attach to real pygfx WorldObject actors via add_event_handler/remove_event_handler - EventPlayer replays via handle_event with real pygfx event objects (to_pygfx_event) - Tests: replace all Mocks and test classes with plain def test_* functions - Tests: use real gfx.Mesh, gfx.PointerEvent, gfx.KeyboardEvent, gfx.WheelEvent - Export EventRecorder, EventCounter, EventPlayer from fury/ui/__init__.pyi - All 45 tests pass, all pre-commit checks pass (ruff, mypy, numpydoc, codespell)
Closes #1122
Re-implements the UI event recording and replay system for FURY v2.
Changes
fury/ui/event_recorder.py— New module with:RecordedEvent: frozen dataclass for serializing rendercanvas eventsEventRecorder: attaches to a ShowManager, captures events to a JSON logEventCounter: subclass of EventRecorder, tallies events by typeEventPlayer: replays a recorded session into a ShowManager with optional speed factorfury/ui/tests/test_event_recorder.py— 49 tests covering all classesAdapted from the v1 EventRecorder/EventCounter, updated for the v2 rendercanvas event system.