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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to