Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Single vs. multiple NSView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Single vs. multiple NSView



On Jul 21, 2004, at 4:51 AM, Ricky Sharp wrote:
- background image (opaque; fills entire window)
- some other image (transparent areas, so composited in)
- button widgets (also with transparent areas, drop shadows)
- help tag, but only if I need to grow my own solution. This could either be done as a custom NSView or an overlay window.

From this, it sounds less like your views will overlap and more like they'll form a containment hierarchy. NSView will do a lot of work for you in this case.

I'd probably start out with NSViews and then refactor to use NSCells instead if I found I actually needed the extra performance. However, if you're targeting Panther and later, there are additional ways to improve view performance beyond just switching to cells or other lighter-weight mechanisms.

For example, -[NSView getRectsBeingDrawn:count:] from within -drawRect: will get you an array of dirty rectangles to redraw in a view, so you aren't redrawing the whole thing every time. You can also use the parameter to -drawRect: to reject objects that don't need to be redrawn. And of course you could use -setNeedsDisplayInRect: instead of just -setNeedsDisplay: to invalidate a portion of a view.

Another idea: Say you can divide your screen into a "playfield" and "controls." Your controls are relatively static, but your playfield is very dynamic. You can make your controls real controls or views, but make your playfield just one view that manages all of its own drawing internally and get the best of both worlds.

-- Chris

--
Chris Hanson <email@hidden>
http://www.livejournal.com/users/chanson/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Single vs. multiple NSView (From: Ricky Sharp <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.