• 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
Re: NSRulerView and inches
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSRulerView and inches


  • Subject: Re: NSRulerView and inches
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 21 Jan 2010 12:00:36 -0800

On Jan 21, 2010, at 04:30, Milen Dzhumerov wrote:

> I'm been involved with an app that has the ability to create documents in various dimensions, including a way where you specify the width and height in inches + the PPI. So, for example, the user can specify a document of size 5in x 5in with 300 PPI. From this definition, I'll have a document of size 1500 points by 1500 points although I'll have to redefine how many points equal one inch for the ruler view.
>
> As NSRulerView already has the definition of 1 inch = 72 points, am I right that I'll have to create a new unit with a random name (could use a UUID) and "in" abbreviation that's defined from the PPI selected by the user? So, in the example case I'll send a msg similar to [NSRulerView registerUnitWithName:@"random unused unit name" abbreviation:NSLocalizedString(@"in", @"Inches abbreviation string") unitToPointsConversionFactor:300.0 stepUpCycle:upArray stepDownCycle:downArray].

No, the first "P" in PPI isn't "points" but "pixels". A 5in x 5in x 300 PPI document is 1500 pixels by 1500 pixels.

By contrast, rulers work in [Postscript] points -- 1/72.0 in. Registering a new unit with the parameters you describe would make your inches 4 times too large, approximately.

It doesn't look like you need any new ruler definitions for your situation. In your data model, keep your sizes and locations in whatever units make the most sense, then expect to *transform* the values to view units (which depend, at least, on the view's zoom factor). In general, it's awkward to let the view do the scaling automatically (by manipulating the relationship between its bounds and its frame), because you often want to draw your view contents scaled in both size and location, but your UI widgetry (such as selection handles) using unscaled sizes on scaled locations.

The details depend on your application, but it's vital to start by clearing separating the data model coordinate system from the view's logical and actual coordinate systems.


_______________________________________________

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

  • Follow-Ups:
    • Re: NSRulerView and inches
      • From: Graham Cox <email@hidden>
References: 
 >NSRulerView and inches (From: Milen Dzhumerov <email@hidden>)

  • Prev by Date: Re: NSOutlineView + selectionIndexPaths binding
  • Next by Date: Re: Uploading image via HTTP POST
  • Previous by thread: NSRulerView and inches
  • Next by thread: Re: NSRulerView and inches
  • Index(es):
    • Date
    • Thread