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

Always compute pointer position with current zoom #5380

Closed
wants to merge 1 commit into from

Conversation

timstr
Copy link
Contributor

@timstr timstr commented Nov 17, 2024

This addresses out-of-date pointer positions during changing zoom factors by performing the same zoom-based scaling per-frame when the current zoom factor is known, rather than baking in the zoom factor during the most recent pointer move.

Before:

Screencast.from.2024-11-16.04.09.08.PM.webm

After:

Screencast.from.2024-11-16.04.13.54.PM.webm

See #5379 for discussion and more details

Copy link

Preview available at https://egui-pr-preview.github.io/pr/5380-pointer_current_zoom
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

}

/// If it is a good idea to show a tooltip, where is pointer?
#[inline(always)]
pub fn hover_pos(&self) -> Option<Pos2> {
self.latest_pos
self.latest_pos.map(|p| p / self.zoom_factor)
Copy link
Owner

Choose a reason for hiding this comment

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

This all feels like the wrong solution to me.

In egui, everything is in the same global coordinate space called ui points.

If self.latest_post needs dividing with zoom_factor, that's a bug in how latest_pos is set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your eyes. Indeed my actual problem was already solved, I just hadn't looked around enough. Closing this MR and the linked issue now.

@timstr timstr closed this Nov 27, 2024
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.

Incorrect pointer position during changing zoom factor
2 participants