-
Notifications
You must be signed in to change notification settings - Fork 79
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
Ensure same intersection bounds are always used #218
Conversation
puffin_egui/src/lib.rs
Outdated
@@ -689,7 +689,7 @@ impl ProfilerUi { | |||
}; | |||
|
|||
let frame_rect = Rect::from_min_max( | |||
Pos2::new(x, rect.top()), | |||
Pos2::new(x - 0.5 * frame_spacing, rect.top() + 0.5 * frame_spacing), | |||
Pos2::new(x + frame_width, rect.bottom()), | |||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could maybe move the expand2
up to here, like:
); | |
) | |
.expand2(vec2(0.5 * frame_spacing, 0.0)) |
but inlining the expansion is probably fine too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean instead of doing the subtraction and addition on line 692?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right - my impression was that this inlined the equivalent of doing the .expand2
which was removed where checking if the mouse_pos
is contained in the frame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I can change that, I also noticed the addition is wrong as it adds to the Y component of the min position. So changing to .expand2
seems like a good solution 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but on second glance maybe not - this now just expands the min
position not the max
position, so expand2
wouldn't be equivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function not expanding max is what's wrong that I mentioned in my comment above, I'm fixing that as well.
Edit: It should expand both min and max. And when rendering the frame rect should be shrunken to not create a solid chunk of rects. (Something I also noticed now with correct expansion)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I realized afterwards that the bars were getting filled out visually if I tried using expand2 up-front and yeah the follow up to reduce the visual rect makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a nit comment about maybe moving the previous expand2
up, but either way this looks good to me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me.
I tested with the self profiling and clicking the left/right pixels seems to work as expected now and the bars are still visually spaced like they were before.
Checklist
Description of Changes
This ensures the bounds for a
frame_rect
is always the same when checking for intersection in puffin_egui.Also removed unnecessary call to
response.hovered()
.Related Issues
Fixes #217