Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Improper usage of backingAlignedRect:options: #68

Closed
indragiek opened this Issue Feb 26, 2013 · 4 comments

Comments

Projects
None yet
2 participants
Contributor

indragiek commented Feb 26, 2013

NSTextView+RBLAntialiasingAdditions uses NSView's -backingAlignedRect:options to align the frame of the text view to the backing store. The docs for this method state the following:

Returns a backing store pixel aligned rectangle in window coordinates.

Unless this is a documentation mistake on Apple's part (or something I'm missing), I don't think this is the desired behaviour, in that we want view coordinates and not window coordinates. The documentation also states:

Uses the NSIntegralRectWithOptions function to produce a backing store pixel aligned rectangle from the given input rectangle in window coordinates.

It seems like using NSIntegralRectWithOptions on its own would make sense here, as it returns the aligned rectangle without modifying the coordinate space.

Contributor

jspahrsummers commented Feb 26, 2013

You're correct that there's a bug here, but a better fix might be to convert the rect to/from the window's coordinate space for alignment.

NSIntegralRectWithOptions is suboptimal because it won't align to half-points on retina displays. -backingAlignedRect:options: doesn't suffer from the same issue because it uses the actual screen density (via the window).

Contributor

indragiek commented Feb 26, 2013

Good idea. Seems like this would probably be a fairly commonly used method. Maybe it should be added to Rebel as a category on NSView?

Contributor

jspahrsummers commented Feb 26, 2013

Sure, sounds reasonable.

Contributor

indragiek commented Feb 26, 2013

Great, will submit a PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment