Re: Best way to do static overlay over scrolling content?
Re: Best way to do static overlay over scrolling content?
- Subject: Re: Best way to do static overlay over scrolling content?
- From: Quincey Morris <email@hidden>
- Date: Wed, 20 Jul 2011 02:18:54 -0700
On Jul 20, 2011, at 00:55, Daniel Vollmer wrote:
> When you scroll sideways, the "title" of each graph stays in place, whereas the rest of the content scrolls as usual. Currently, I simply redraw the whole graph (well, the visible bit). This strikes me as rather inefficient, because I essentially need to redraw the complete visible portion onScroll instead of only the freshly revealed bit.
> There are some things I can think of, but I'm unsure on which would be the most appropriate way:
> - Put an NSTextLabel inside the NSScrollView's contentView and dynamically reposition it into the visibleRect.
> - Add a largely transparent subview to the NSScrollView (so it's the same size as the visible portion) and draw all titles in there, transforming coordinates as needed.
>
> Preferably, the compositing would only happen once when the visibleRect changes, not each frame (so the transparent blend doesn't each too much graphics memory bandwidth).
>
> Has anyone got any experience with this or suggestions on which way would be most appropriate?
You only really need to redraw the graph *titles* as a whole on scrolling, not the whole thing. Judicious use of 'setNeedsDisplayInRect:' and 'getRectsBeingDrawn:count:' (or something related) should allow your 'drawRect:' to avoid redrawing the whole view.
I'd like to suggest, though, as food for thought, that the *real* reason you're finding this awkward is that there's a UI problem. You are, to some extent, abusing the horizontal scroll bar. From your screen shot, it looks to a naive eye like the horizontal scroll bar would scroll the whole view, including the labels (if that made any sense, which it probably doesn't in this case). The action you're actually providing is moving the origins of the graphs, not scrolling. Something along the lines of a slider seems like it would make more sense than a scroll bar.
If the graphs really do represent a scrollable "view" from the user's point of view, then I think your idea of an overlay view would make sense, but I'd suggest you "float" it visually, like a HUD. That is, the text titles would be slightly transparent, and they would cast a shadow on the scroll view. That way it would be clearer to the user that the titles are just annotations, not part of the scrolling content.
_______________________________________________
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