-
Notifications
You must be signed in to change notification settings - Fork 57
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
Adding relative_position
#323
base: main
Are you sure you want to change the base?
Conversation
I am kinda unsure about the Inside / Outside thing because you will mostly use this with mouse events and they are as far as I know only sent if its "inside" the view, aren't they? |
Mouse events can be sent to the view when outside of its bounds if the view has captured mouse events. This is typically done when a view is draggable so that the |
Thats my thought. So what do you say is better? Leave it as it is or make it just directly return a |
I like how you had it with the enum. But it depends on how we expect this to be used. Essentially we're encoding 2 pieces of information into one here, the relative position and also whether it's inside/outside. Does it become inconvenient if all you need is one or the other? Another potential solution is to have a separate method for checking if the relative position is inside the bounds of the view. I think |
yeah but boundingbox can only check for containing other boundingboxes. and this seems pretty clean to me (here are my two usages): WindowEvent::MouseDown(_) => {
if let RelativeResult::Inside((rel_x, rel_y)) =
cx.relative_position(cx.mouse.cursorx, cx.mouse.cursory)
{
// implementation
}
}
WindowEvent::MouseMove(x, y) => {
let (rel_x, rel_y) = cx.relative_position(*x, *y).unwrap();
// implementation
} |
But for .unwrap() I force the user to a for them maybe unused isInside check |
I think for this we could rename it to something like |
relative_position
forEventContext
returningRelativeResult
bounds
helper forEventContext