Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically transform cursor hotspot user asks to flip cursor image #17540

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mgi388
Copy link
Contributor

@mgi388 mgi388 commented Jan 26, 2025

Objective

Solution

  • When the image needs to be transformed, also transform the hotspot. If the image does not need to be transformed (i.e. fast path), no hotspot transformation is applied.

Testing

  • Ran the example: cargo run --example custom_cursor_image --features=custom_cursor.
  • Add unit tests for the hotspot transform function.
  • I also ran the example I have in my bevy_cursor_kit crate, which I think is a good illustration of the reason for this PR.
  • In the following videos, there is an arrow pointing up. The button hover event fires as I move the mouse over it.
  • When I press Y, the cursor flips.
  • In the first video, on bevy@main before this PR, notice how the hotspot is wrong after flipping and no longer hovering the button. The arrow head and hotspot are no longer synced.
  • In the second video, on the branch of this PR, notice how the hotspot gets flipped as soon as I press Y and the cursor arrow head is in the correct position on the screen and still hovering the button. Speaking back to the objective listed at the start: The user originally defined the source hotspot for the arrow. Later, they decide they want to flip the cursor vertically: It's nice that Bevy can automatically flip the source hotspot for them at the same time it flips the source image.

First video (main):

before.mov

Second video (this PR):

after.mov

@mgi388 mgi388 force-pushed the custom-cursor-transform-hotspot branch from cd1f457 to 4a4f5ad Compare January 26, 2025 02:58
@mgi388
Copy link
Contributor Author

mgi388 commented Jan 26, 2025

@eero-lehtinen 🙏

@BenjaminBrienen BenjaminBrienen added A-Input Player input via keyboard, mouse, gamepad, and more C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 26, 2025
@mgi388
Copy link
Contributor Author

mgi388 commented Jan 26, 2025

@BenjaminBrienen looks like cursors / this one's A-Windowing FYI :) https://github.com/bevyengine/bevy/pulls?q=is%3Apr+author%3Amgi388+is%3Aclosed

@BenjaminBrienen BenjaminBrienen added A-Windowing Platform-agnostic interface layer to run your app in and removed A-Input Player input via keyboard, mouse, gamepad, and more labels Jan 26, 2025
@eero-lehtinen
Copy link
Contributor

Thanks for the quality PRs 👍

crates/bevy_winit/src/custom_cursor.rs Outdated Show resolved Hide resolved
crates/bevy_winit/src/custom_cursor.rs Outdated Show resolved Hide resolved
@mgi388 mgi388 force-pushed the custom-cursor-transform-hotspot branch from 7d91a12 to b317a72 Compare January 26, 2025 20:25
@BenjaminBrienen BenjaminBrienen added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants