• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
backingAlignedRect: doesn't align in magnified views
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

backingAlignedRect: doesn't align in magnified views


  • Subject: backingAlignedRect: doesn't align in magnified views
  • From: Leonardo <email@hidden>
  • Date: Fri, 03 May 2013 19:52:40 +0200
  • Thread-topic: backingAlignedRect: doesn't align in magnified views

I have subclassed a NSView and placed it within a window.
In this NSView I have to align my NSBezier rect to the pixel grid and stroke
a perfect and aligned 1 pixel width rect.
So, in the documentView's drawRect: method, I do

[[NSGraphicsContext currentContext] setShouldAntialias:NO];
[NSBezierPath setDefaultLineWidth:0.0];
NSRect anyRect = NSMakeRect(50, 113.25, 110, 70.5);
NSRect alignedRect = [self backingAlignedRect:anyRect
options:NSAlignAllEdgesInward];
[NSBezierPath strokeRect:alignedRect];

It works when the clipView's is not magnified (scale 1:1), but if I magnify
the view calling

[self scaleUnitSquareToSize:NSMakeSize(scaleFactor, scaleFactor)];

from within the magnifyWithEvent: method, I get, sometimes, a 2 width pixels
line (wrong!). Is it a bug or do I miss something? For instance, when the
view's mScaleFactor is 5.057041 (frame.size / bounds.size), I get a 2 pixels
width line (wrong), and I get this log

mScaleFactor 5.057041;
anyRect 50.000000, 113.250000, 110.000000, 70.500000
alignedRect 50.063373, 113.390257, 109.747964, 70.199148

My screen is not retina. My screen's DPI is 133.
Any solution will be welcome.


Regards
-- Leonardo


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: delaying forced sleep after initial 30 seconds delay
  • Next by Date: Re: delaying forced sleep after initial 30 seconds delay
  • Previous by thread: Re: Enable Unique Selection
  • Next by thread: NSDocument saveDocumentWithDelegate deadlocked during App termination
  • Index(es):
    • Date
    • Thread