Re: Layering NSViews -- why isn't this recommended?
Re: Layering NSViews -- why isn't this recommended?
- Subject: Re: Layering NSViews -- why isn't this recommended?
- From: Christopher Lloyd <email@hidden>
- Date: Thu, 07 Jun 2001 02:29:38 -0400
Hi, There is nothing wrong with overlapping views and it is perfectly
acceptable to have them, they are just more expensive to draw because the
view system can't take shortcuts when figuring out which views to draw and
in what order. If you adhere to the strict parent/child relationship with
no overlapping siblings, when one view changes it does not need to figure
out which sibling views overlap and draw them too, it can just do a
straight parent,child draw. If you know none of your views overlap you can
make things faster by enabling optimized drawing for the whole window with
-[NSWindow useOptimizedDrawing:] (This is not a big optimization).
I am not familiar with what exactly you want to do but my guess is that an
NSView is overkill. If you have a lot of them in the same "area" on the
screen, put them all in one view and use an NSImage/NSPoint pair for each
card. It's more work, but will probably lead to a more optimal arrangement
down the road...
Ahhh, what happened to all those old NeXT game examples!
Hope this helps,
Chris
At 10:29 PM 6/6/2001 -0500, you wrote:
I've been trying to create a pile of cards that are offset -- so each card
is to the right and below the one beneath it (ala Eric's Solitaire, which
I believe used to ship with the Mac at one time). My Cards are subclasses
of NSImageView.
My plan is to
1) make a Card class (subclass of NSImageView)
2) place those Cards in a Window's contentView using a method in NSView
that sounded promising, addSubview:positioned:relativeTo:.
It seems to work, but the documentation has this dire warning:
"addSubview:positioned:relativeTo:, allows you to specify the ordering of
NSViews that may overlap (though laying out NSViews so that they overlap
isn't recommended)."
Does anybody know why this isn't recommended? And otherwise, how can I
accomplish this? In Java there's a JLayeredPane; is there any equivalent
in the Application Kit?