Skip to content

feat: add pen icon when remote drawing#327

Merged
iparaskev merged 10 commits into
gethopp:mainfrom
theodkp:feat/remote-drawing-pen-icon
Jun 29, 2026
Merged

feat: add pen icon when remote drawing#327
iparaskev merged 10 commits into
gethopp:mainfrom
theodkp:feat/remote-drawing-pen-icon

Conversation

@theodkp

@theodkp theodkp commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

closes #219

  • Now uses pen icon instead of finger icon when remote user is in drawing mode.
  • Adds coverage for the new pen cursor badge, matching the existing pointer badge tests.

Summary by CodeRabbit

  • New Features

    • Pencil cursor icon shown while drawing.
    • Per-controller visual cursor override so a controller’s cursor appearance can differ from its input mode.
  • Improvements

    • Cursor visuals consistently reflect drawing, pointer, normal and disabled states driven by drawing mode.
    • User badge rendering adds a dedicated pencil badge for clearer cursor identity.

@theodkp theodkp requested a review from iparaskev as a code owner June 6, 2026 01:02
@netlify

netlify Bot commented Jun 6, 2026

Copy link
Copy Markdown

Deploy Preview for hoppdocs ready!

Name Link
🔨 Latest commit 86ddc6f
🔍 Latest deploy log https://app.netlify.com/projects/hoppdocs/deploys/6a42e5fcd42c5b0008d3a42c
😎 Deploy Preview https://deploy-preview-327--hoppdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a pencil badge variant and renderer, pre-renders and stores a pencil cursor image, introduces a controller visual-mode override, and wires drawing-mode events to update controller cursor visuals.

Changes

Pencil cursor support

Layer / File(s) Summary
Badge rendering infrastructure
core/src/utils/svg_renderer.rs
UserBadgeKind enum replaces the boolean pointer flag. render_user_badge_to_png now accepts UserBadgeKind. Adds BadgeLayout and render_pencil_user_badge_to_png. Tests updated and a pencil badge test added.
Cursor asset loading and mode support
core/src/graphics/cursor.rs
Adds CursorMode::Pencil and Cursor.pencil_cursor/pencil_hotspot. Cursor::new renders pencil badge PNG and stores handle+dimensions; draw selects pencil asset for CursorMode::Pencil and applies hotspot offsets.
Visual mode override system
core/src/input/mouse.rs
ControllerCursor gains visual_mode_override: Option<CursorMode>, visual_mode() getter, and setter. CursorController::set_controller_visual_mode(identity, mode) added; update_cursors() uses visual_mode() for rendering.
Drawing mode integration
core/src/graphics/participant.rs, core/src/lib.rs
ParticipantsManager::set_drawing_mode() maps drawing modes to cursor visuals (DrawPencil, ClickAnimationPointer, DisabledNormal, Any→unchanged). UserEvent::DrawingMode handler computes an optional CursorMode, toggles pointer-enabled state, and calls set_controller_visual_mode().

Sequence Diagram(s)

sequenceDiagram
  participant DrawingModeEvent as UserEvent::DrawingMode
  participant MainHandler as lib.rs Handler
  participant CursorController
  participant Controller as ControllerCursor
  participant Renderer as ParticipantsManager/Renderer
  DrawingModeEvent->>MainHandler: dispatch(DrawingMode)
  MainHandler->>MainHandler: map DrawingMode -> Option<CursorMode>
  MainHandler->>CursorController: set_controller_visual_mode(identity, visual_mode)
  CursorController->>Controller: set_visual_mode_override(mode)
  CursorController->>CursorController: update_cursors()
  CursorController->>Controller: visual_mode()
  Controller-->>CursorController: override or underlying mode
  CursorController->>Renderer: set_cursor_mode(mode)
  Renderer->>Renderer: draw cursor image using asset for mode
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • gethopp/hopp#257: Both PRs modify cursor rendering to be driven by CursorMode using pre-rendered PNG badges.

Poem

🐰 I nibble pixels, make a mark,
A pencil badge to brighten dark,
Controllers now may show a pen,
When sharers draw, they see it then,
Small hops, big strokes — joy again.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: add pen icon when remote drawing' directly describes the main change: adding a pen/pencil cursor icon when remote users are drawing, which aligns with the core modifications across all files.
Linked Issues check ✅ Passed The PR successfully implements all requirements from issue #219: adds pencil cursor support (new CursorMode::Pencil), updates cursor rendering to show pen icon during remote drawing, and includes test coverage for the new badge variant.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the pencil/pen cursor feature for remote drawing: cursor mode enum extension, cursor geometry handling, drawing mode mapping, event loop integration, SVG badge rendering, and test updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/src/input/mouse.rs`:
- Around line 1042-1052: set_controller_visual_mode updates the controller
visual state via controllers_cursors and controller.set_visual_mode_override but
does not trigger a redraw, so the cursor badge can remain stale; after modifying
the controller (inside the if block or immediately after the loop) call the
appropriate redraw trigger on the UI surface (e.g. self.request_redraw() or
self.window.request_redraw()/self.queue_redraw(), depending on the available
API) so the cursor is repainted; reference set_controller_visual_mode,
controllers_cursors, and set_visual_mode_override when locating where to add the
redraw call.

In `@core/src/lib.rs`:
- Around line 1215-1229: The code incorrectly mutates pointer state when
drawing_mode is DrawingMode::Any; change the pointer update logic so
DrawingMode::Any is a no-op: compute visual_mode as currently done
(DrawingMode::Any -> None) but only call
cursor_controller.set_controller_pointer(...) for modes that explicitly set
pointer behavior (e.g., DrawingMode::Draw(_) -> true and
DrawingMode::ClickAnimation -> true, DrawingMode::Disabled -> false), and skip
calling set_controller_pointer for DrawingMode::Any; keep the subsequent call to
cursor_controller.set_controller_visual_mode(sid.as_str(), visual_mode) as-is.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3c4b0ef7-09d6-4bb0-b6df-38a6716cd4fb

📥 Commits

Reviewing files that changed from the base of the PR and between 2283d82 and 836ecd6.

📒 Files selected for processing (5)
  • core/src/graphics/cursor.rs
  • core/src/graphics/participant.rs
  • core/src/input/mouse.rs
  • core/src/lib.rs
  • core/src/utils/svg_renderer.rs

Comment thread core/src/input/mouse.rs Outdated
Comment thread core/src/lib.rs Outdated

@iparaskev iparaskev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@theodkp thanks for the PR. Generally looks good. One issue is that the pencil has offset from where the draw line ends.

Image

We could either flip the pencil in the svg or maybe when the mode is pencil hardcode an offset in draw in cursor.rs.

Comment thread core/src/graphics/participant.rs Outdated
Comment thread core/src/input/mouse.rs Outdated
Comment thread core/src/input/mouse.rs Outdated
}

fn visual_mode(&self) -> CursorMode {
self.visual_mode_override.unwrap_or(self.mode)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am fine with leaving this as is but I think we can do better. Instead of having two member for tracking the same thing we can just merge the visual mode with mode. This will need more refactoring as we have many functions who assume there are only two cursor modes. If you don't want to give it a go I am fine with leaving a todo comment here and we can improve later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Happy to do this

Comment thread core/src/lib.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the implementation of set_drawing_mode we should also call set_cursor_mode.

@iparaskev

Copy link
Copy Markdown
Contributor

@theodkp If the scope of this has grown and you don't have time to finish it, no worries, I'm happy to make the finishing touches and merge it.

@theodkp

theodkp commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Yeah that would be great thanks! @iparaskev

@iparaskev iparaskev merged commit 0735a99 into gethopp:main Jun 29, 2026
18 of 19 checks passed
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.

feat: change the cursor to a pen in the sharer view when drawing

2 participants