Re: NSImageView and ZoomFactors
Re: NSImageView and ZoomFactors
- Subject: Re: NSImageView and ZoomFactors
- From: Kyle Sluder <email@hidden>
- Date: Thu, 19 Aug 2010 19:56:41 -0700
On Thu, Aug 19, 2010 at 4:54 PM, Quincey Morris
<email@hidden> wrote:
> On Aug 19, 2010, at 12:44, Brian Postow wrote:
>
>> ah, so, the way to zoom is to leave the NSImageView on NSImageScaleProportionallyUpOrDown, and then change the size of the frame! That gives me scrollbars!
>
> I had to go out for a while before finishing my last post, but I wanted to point out that you likely *don't* want to be using NSImageView at all for this. The problem is that you seem to want to be doing additional drawing (you mentioned selection rectangles) earlier, but consider that you almost certainly don't want such drawing to be scaled along with the image. There are 3 ways to deal with this:
It sounds as if you're conflating bounds transformation scaling with
NSImageView size-to-fit-frame scaling. It's usually the case that you
don't want to rely on a scaled bounds coordinate system to draw zoomed
UI for the precise reason you mentioned: you need to untransform any
additional drawing, including any subview drawing. It is much cleaner
and simpler to use a custom zoom factor and scale your drawing within
-drawRect:.
As for using NSImageView size-to-fit-frame scaling, and using
NSImageView in general, as long as Brian isn't attempting to do his
adornments within a -drawRect: override of an NSImageView subclass, it
might be appropriate for simple uses. You scale the frame, not the
bounds, of the image view, so all the coordinate systems make sense,
which means you can do adornment drawing in subviews of the image
view.
In fact, that's one common way of doing selection rectangles: use a
subview to draw your selection lasso. Another common technique, useful
when your adornment drawing needs to span multiple views (and I
believe the only way to solve this before overlapping sibling views
were made legal) is to use a borderless NSWindow. This has the
advantage that it uses Quartz Extreme to composite the selection lasso
with the window contents, plus you can do things like fade out the
lasso when the user releases the mouse (kind of like Finder in 10.6)
without having to do any complicated timer drawing in your main
content view—all the fade animation stuff remains in your lasso
window.
FWIW, I believe overlapping drawing became supported on 10.5, not 10.6.
--Kyle Sluder
_______________________________________________
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