Skip to content

feat(annotations): broadcast stroke events to plugin_events_group#299

Open
richardssam wants to merge 1 commit into
AcademySoftwareFoundation:developfrom
richardssam:pr/annotation-stroke-events
Open

feat(annotations): broadcast stroke events to plugin_events_group#299
richardssam wants to merge 1 commit into
AcademySoftwareFoundation:developfrom
richardssam:pr/annotation-stroke-events

Conversation

@richardssam

@richardssam richardssam commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Broadcasts in-progress annotation stroke geometry to plugin_events_group()
so Python plugins can render partial strokes directly from event data, instead
of polling/scanning bookmarks.

AnnotationBasePtr is not Python-bound, so Python plugins can't subscribe to
live_edit_event_group directly. This serialises the cumulative in-progress
stroke via Annotation::serialise() and broadcasts it as a JsonStore
alongside (event_atom, annotation_data_atom, user_id, stroke_completed).
Shapes (Square/Circle/Arrow/Line/Ellipse) are broadcast only on pen-up, since a
shape isn't meaningful until the drag completes.

Also updates subscribe_to_plugin_events (plugin_base.py) to pass the plugin's
actor as the owner actor (3rd arg): BroadcastActor forwards via
send_as(current_sender(), ...), so a Python subscriber sees the owning actor
as sender, not the broadcast group — the 2-arg form silently dropped
plugin_events_ messages.

Depends on #303

The plugin_base.py change relies on the owner-actor routing added in
#303 (EventToPythonThreadLockerActor / add_message_callback 3rd arg).
Please review/merge #303 first.

Changes

  • annotations_core_plugin.cpp: broadcast serialised stroke geometry via
    plugin_events_group(); shapes only on pen-up.
  • plugin_base.py: subscribe_to_plugin_events passes the owner actor as the
    3rd arg to add_message_callback.

This was developed with the assistance of claude code.

AnnotationBasePtr is not Python-bound, so Python plugins cannot
subscribe to live_edit_event_group directly. Serialize the cumulative
in-progress stroke via Annotation::serialise() and broadcast it as a
JsonStore alongside (event_atom, annotation_data_atom, user_id,
stroke_completed) via plugin_events_group(), so Python plugins can
render partial strokes directly from event geometry instead of
polling/hot-scanning bookmarks. Shapes (Square/Circle/Arrow/Line/
Ellipse) are only broadcast on pen-up, since a shape isn't a
meaningful annotation until the drag completes.

Also fix subscribe_to_plugin_events: BroadcastActor forwards messages
via send_as(current_sender(), subscriber, msg), so a Python subscriber
sees the owning actor as the sender, not the broadcast group. The
2-arg add_message_callback() only registered the group's address, so
plugin_events_ messages were silently dropped. Pass the plugin's actor
as the owner_actor (3rd arg), mirroring the same fix already applied
to subscribe_to_event_group.

Signed-off-by: Sam.Richards@taurich.org <Sam.Richards@taurich.org>
@richardssam richardssam force-pushed the pr/annotation-stroke-events branch from af98db1 to 12d28cd Compare July 4, 2026 19:01
@richardssam

Copy link
Copy Markdown
Contributor Author

Ted, this is dependant on #303 being approved. So if that is no good, I'll probably need to rethink this.

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.

1 participant