Post

At minimum, you have a screen coordinate space (which is almost never what you want to use), a window coordinate space, and a Compose root coordinate space. Each of those can be measured in dps or pixels, and sometimes it matters if those pixels are integers or floats.

And then every single node has its own local coordinate space, after layouts and padding and scrolling and translations are each applied. Keeping track of what coordinate system you want to be working in is tricky when you start having complicated interactions that move across boundaries.

I wonder if there'd be a way to add type-safety somehow that would make it better, without adding too much friction. Having Offset as a type is great, but it's also just as important to keep track of what you have an Offset _from_

You would need a different type for each frame of reference though I think - that'd work for the most important reference frames, but probably wouldn't scale well if you wanted to make sure two arbitrary composables were talking to each other properly.

0 reposts2 likes

I saw your other post and was reminded that I'm also facing this challenge in telephoto: converting between the viewport coordinate space and the canvas/content space. bsky.app/profile/vany...

Alex Vanyo@vanyo.dev

After figuring out how to make the coordinates work, it's so satisfying to use a live-updating drag and drop that previews where the dropped content will go.