Re: NSScroller
Re: NSScroller
- Subject: Re: NSScroller
- From: David Blanton <email@hidden>
- Date: Thu, 7 Jan 2010 22:22:15 -0700
Let me cogitate on your superb answer for a bit. I'll be back. Thanks.
On Jan 7, 2010, at 10:14 PM, Graham Cox wrote:
On 08/01/2010, at 3:58 PM, David Blanton wrote:
If a scroll view's content view is larger than the scroll view then
the scroll view generates scrollers - correct?
Let me try to get to some of the REALLY
1. I want to always make the content view some factor larger than
the scroll view to keep the scroller knobs a uniform size.
For this I'd perhaps consider subclassing NSScroller and override -
setKnobProportion: to call super with some constant value regardless
of what is passed in. That will keep the knob a constant size. If
the content view is some fixed proportion of the visible view, this
will just happen anyway, but I'm unsure just how sensible this would
be.
2. If the user scrolls I want to tell my model how much was
scrolled so it can regenerate a bitmap for display.
Sounds very hacky.
What would probably be better is wait until the view needs to draw
something, then figure out if that part has been cached as a bitmap
yet. If so, you can just draw it. If not, you can generate the
bitmap there and then and then just draw it. This way your document/
data model needs to know nothing about the view, in keeping with
good MVC design. Instead, it waits for the view to ask it for data
for some portion, and then it has the information about what part of
the view is being drawn. This approach automatically takes care of
scrolling, zooming, sizing and so forth without any hacks. The view
just makes its dirty rects available to the data model when it is
requesting data. If it slows down drawing too much initially, you
could use the "no cache data available" state to trigger creation of
that data, maybe in a background thread, then redraw it when it is
available. In the meantime you'd have to draw something else, such
as a blank background or a pattern denoting "no data yet" perhaps.
3. If the window size changes apply a factor to the content view to
achieve 1 above.
OK, if that makes sense for the app. Sounds a bit weird, but what do
I know? What happens if the user does some work in the corner of the
content area then makes the window smaller? Wouldn't that lose that
work?
--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