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

Mixing signatures for ScreenToX between int and Point #3460

Closed
tznind opened this issue May 8, 2024 · 7 comments
Closed

Mixing signatures for ScreenToX between int and Point #3460

tznind opened this issue May 8, 2024 · 7 comments

Comments

@tznind
Copy link
Collaborator

tznind commented May 8, 2024

ScreenToContent uses Point
ScreenToViewport uses int,int
ScreenToFrame uses int,int

image

Is it possible to please standardize these? or is there a reason they are not consistent.

It makes debugging screen pointer issues difficult if you are trying to switch between the two methods to see which is more correct.

@tig tig added the enhancement label May 8, 2024
@tig
Copy link
Collaborator

tig commented May 8, 2024

I agree.

Your preference? Point or two int?

@tznind
Copy link
Collaborator Author

tznind commented May 8, 2024 via email

@dodexahedron
Copy link
Collaborator

dodexahedron commented May 8, 2024

It's pretty common in a lot of UI frameworks to expose both a coordinate pair (so Point, here) as well as the component coordinates, as ints, with the actual value being stored in the Point and the ints just retrieving that coordinate from the point for get and mutating the Point on set (it's immutable, so that means re-assignment - use the with { X = value; } method for that).

I'd suggest, to help with this sort of thing in general, and to force us to be consistent (plus for testing and other benefits), an IPositionable or otherwise appropriately named interface be created that has exactly those 3 properties, with both get and set accessors on all 3.

Implementations in types declaring the interface should store just the Point as a private field and the properties do the above operations.

We really need more interfaces, in general, for formality, consistency, testing, and consumer flexibility, without dependency on implementation.

@dodexahedron
Copy link
Collaborator

Oh also, a pretty important thing about immutable types as properties:

The get accessor for any property that is an immutable type should be readonly get instead of just get, so that the compiler will disallow attempts to write to the returned item - which is important because it's a copy, as properties cannot return by reference.

@tig
Copy link
Collaborator

tig commented May 8, 2024

See #3461

@tig
Copy link
Collaborator

tig commented May 8, 2024

Note, as part of

... we need to change MouseEvent to hold a Point

@dodexahedron
Copy link
Collaborator

Emphatic agree on that one. 👍

tig added a commit that referenced this issue May 11, 2024
@tig tig closed this as completed May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: ✅ Done
Development

No branches or pull requests

3 participants