Skip to content

Track rotation with the hover region on rotatable widgets - #124

Merged
SunkenInTime merged 1 commit into
mainfrom
fix-rotated-hover-region
Aug 10, 2026
Merged

Track rotation with the hover region on rotatable widgets#124
SunkenInTime merged 1 commit into
mainfrom
fix-rotated-hover-region

Conversation

@SunkenInTime

@SunkenInTime SunkenInTime commented Aug 10, 2026

Copy link
Copy Markdown
Owner

What

Moves the handle-revealing MouseRegion inside Transform.rotate on RotatableWidget.

Why

The hover region previously wrapped the rotation transform, so its hit area never rotated with the visual. On a rotated ability (e.g. a view cone), hovering the drawn widget could fail to reveal the rotation handles, while hovering the empty space of the unrotated footprint revealed them — hover felt detached from what's on screen.

With the region inside the transform, the pointer hit area is the same shape the user sees. The translucent/non-opaque behavior is preserved so spatially separated handles stay reachable and pointer targets underneath aren't blocked.

Testing

  • flutter analyze clean

Summary by CodeRabbit

  • Bug Fixes
    • Improved hover detection for rotated widgets so it accurately follows their visible bounds.
    • Preserved translucent hit testing and consistent pointer enter/exit behavior.

The MouseRegion that reveals rotation handles sat outside the
Transform.rotate, so its hit area stayed pinned to the unrotated
footprint: hovering a rotated cone missed, and empty space where the
widget used to be lit up. Moving the region inside the rotation keeps
hover aligned with what is actually drawn.
@SunkenInTime

Copy link
Copy Markdown
Owner Author

@greptileai review

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

RotatableWidget now places MouseRegion inside Transform.rotate. Hover detection follows the rotated visual bounds while preserving existing pointer behavior.

Changes

Rotated hover detection

Layer / File(s) Summary
Rotate the hover region
lib/widgets/draggable_widgets/ability/rotatable_widget.dart
Transform.rotate now wraps MouseRegion. Existing translucent hit testing and enter/exit behavior remain unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 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 title clearly describes the main change: aligning the hover region with rotation on rotatable widgets.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-rotated-hover-region

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.

🧹 Nitpick comments (1)
lib/widgets/draggable_widgets/ability/rotatable_widget.dart (1)

112-122: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a non-zero-rotation regression test.

Flutter's Transform.rotate uses transformed hit testing by default, so this behavior needs coverage at a non-zero angle. (api.flutter.dev)

The existing test in test/rotatable_widget_hover_test.dart uses rotation: 0 in Lines 16-90. It would pass if MouseRegion remained outside Transform.rotate. Add a case with a non-zero rotation. Move the mouse to a point inside the rotated target or handle area but outside the unrotated bounds. Assert ShapeIndicatorFade.visible and handleDragStarted.

🤖 Prompt for 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.

In `@lib/widgets/draggable_widgets/ability/rotatable_widget.dart` around lines 112
- 122, Add a regression test in rotatable_widget_hover_test.dart using a
non-zero rotation, positioning the mouse inside the rotated target or handle
area but outside its unrotated bounds. Assert that ShapeIndicatorFade.visible
becomes true and handleDragStarted is triggered, covering transformed hit
testing through Transform.rotate.
🤖 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.

Nitpick comments:
In `@lib/widgets/draggable_widgets/ability/rotatable_widget.dart`:
- Around line 112-122: Add a regression test in rotatable_widget_hover_test.dart
using a non-zero rotation, positioning the mouse inside the rotated target or
handle area but outside its unrotated bounds. Assert that
ShapeIndicatorFade.visible becomes true and handleDragStarted is triggered,
covering transformed hit testing through Transform.rotate.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ea0a2f23-cde1-45af-8eae-55ba474722ce

📥 Commits

Reviewing files that changed from the base of the PR and between aef7569 and ada406e.

📒 Files selected for processing (1)
  • lib/widgets/draggable_widgets/ability/rotatable_widget.dart

@greptile-apps

greptile-apps Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Moves the hover region inside the rotation transform so pointer hit testing follows the widget’s displayed orientation while retaining translucent interaction behavior.

No product defect was established from the changed code.

T-Rex validation blocked

The required Flutter toolchain is unavailable: flutter, dart, and fvm are not installed, and the local SDK, package configuration, and Pub cache are absent. Both the existing hover test and an authored rotated hover, target-drag, and handle-drag test stopped before execution with flutter: not found.

Confidence Score: 5/5

No correctness or security defect was identified in the reviewed change.

The transform and hover-region ordering directly aligns the pointer region with the rendered widget while preserving the existing translucent hit-test configuration. Runtime widget validation could not execute because the Flutter toolchain is unavailable, but no final finding was established.

Files Needing Attention: No additional files require changes. lib/widgets/draggable_widgets/ability/rotatable_widget.dart should be exercised with the focused widget tests after Flutter 3.44.4 is available.

T-Rex T-Rex Logs

What T-Rex did

  • T-Rex attempted to run flutter test test/rotatable_widget_hover_test.dart in /home/user/repo, but Flutter was not found and the process exited with code 127.
  • T-Rex attempted to run flutter test trex-artifacts/rotated-mouse-region-validation-test.dart in /home/user/repo, but Flutter was not found and the process exited with code 127.
  • Environment diagnostics showed that Flutter, Dart, FVM, the local Flutter SDK, package configuration, and the Pub cache are absent, preventing hover and drag tests from being exercised.
  • The before/after evidence pair and the exact focused-test source were saved in trex-artifacts for review.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "Track rotation with the hover region on ..." | Re-trigger Greptile

@SunkenInTime
SunkenInTime merged commit a521efa into main Aug 10, 2026
3 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.

1 participant