Skip to content

feat: re-implement UI EventRecorder, EventCounter and EventPlayer (#1122)#1126

Open
AdityaGupta716 wants to merge 11 commits intofury-gl:v2from
AdityaGupta716:feature/ui-event-recorder-counter
Open

feat: re-implement UI EventRecorder, EventCounter and EventPlayer (#1122)#1126
AdityaGupta716 wants to merge 11 commits intofury-gl:v2from
AdityaGupta716:feature/ui-event-recorder-counter

Conversation

@AdityaGupta716
Copy link
Contributor

@AdityaGupta716 AdityaGupta716 commented Feb 26, 2026

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 events
    • EventRecorder: attaches to a ShowManager, captures events to a JSON log
    • EventCounter: subclass of EventRecorder, tallies events by type
    • EventPlayer: replays a recorded session into a ShowManager with optional speed factor
  • fury/ui/tests/test_event_recorder.py — 49 tests covering all classes

Adapted from the v1 EventRecorder/EventCounter, updated for the v2 rendercanvas event system.

@AdityaGupta716 AdityaGupta716 force-pushed the feature/ui-event-recorder-counter branch from 6362f77 to dcaa0cd Compare February 26, 2026 12:00
@AdityaGupta716 AdityaGupta716 marked this pull request as draft February 26, 2026 12:37
@AdityaGupta716 AdityaGupta716 marked this pull request as ready for review February 26, 2026 22:47
@AdityaGupta716 AdityaGupta716 marked this pull request as draft February 26, 2026 22:48
@AdityaGupta716
Copy link
Contributor Author

AdityaGupta716 commented Feb 27, 2026

@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 .

@AdityaGupta716 AdityaGupta716 marked this pull request as ready for review February 27, 2026 21:06
Copy link
Contributor

@maharshi-gor maharshi-gor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +1 to +11
"""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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fury never uses any types so this is not required.

Also fury only supports python version 3.11+ which do not require this change

@ganimtron-10
Copy link
Contributor

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Re-implement UI Event Recorder and Counter

3 participants