Paralayout icon indicating copy to clipboard operation
Paralayout copied to clipboard

Make it possible to do rounding calculations off of @MainActor when scale is known

Open dfed opened this issue 1 year ago • 0 comments

#132 left us in a place where we cannot do pixel rounding at constant scales when off of @MainActor. I expected this would be fine, but upon an attempt to adopt of latest master I've realized that nonisolated delegate methods can be hampered by this approach.

This PR introduces the concept of CGFloatProviding, to which CGFloat and Int both conform. Both of these types no longer conform to ScaleFactorProviding, and for every method that takes a scaleFactor: ScaleFactorProviding I have created a duplicate, non-@MainActor-bound method that takes a scale: CGFloatProviding and made the scaleFactor-taking method call through to this new scale-taking method.

This PR creates a good amount of duplicated API surface – I'm not convinced this is the best possible approach. Very open to feedback, but I do think we'll want to solve this problem before creating the next release.

dfed avatar Sep 03 '24 17:09 dfed