Re: Large over 100K pixel high ruler scroll view
Re: Large over 100K pixel high ruler scroll view
- Subject: Re: Large over 100K pixel high ruler scroll view
- From: Graham Cox <email@hidden>
- Date: Wed, 24 Aug 2011 10:21:53 +1000
On 24/08/2011, at 9:56 AM, Conrad Shultz wrote:
> You are right about the coordinate space, but remember that
> NSScrollView does not handle zooming (scaling?) - that is up to you.
I have a view subclass that simplifies this task http://apptre.net/gczoomview.htm
Drop this into a NSScrollView and it gets you a lot for free (NSScrollView itself will happily accommodate the zoom automatically, and if you have rulers showing, they also adjust properly).
I'm not sure about the 10,000 pixel limit - I've never run into it. But I believe that pertains to the view's frame, not its bounds. The bounds is the logical content dimension, not the area shown on screen, which is much smaller for a view that can be scrolled. One reason for a limit is that if the view has to be buffered in a bitmap, a 10,000 limit sets a practical limit on how much memory that could require. But such a buffer only needs to buffer the frame, not the bounds.
So In IB, set up your scrollview and content view within, setting it to some arbitrary size. When you actually load the nib, you can set the bounds to the same dimension as the content (in -awakeFromNib for example), and all should be well. Carefully use the parameter to -drawRect: to load only the part of the image that is requested and you should find it all works efficiently - the only part of the image ever in (video) memory is what you see - all the rest is somewhere else (disk, e.g.)
Note that when you zoom a view, the frame and the bounds have a further difference, which not only describes the scroll offset, but the scale factor as well. A highly zoomed-in view vastly exceeds the 10,000 pixel limit, yet works just fine.
--Graham
_______________________________________________
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