Can siblings followed by siblings overlap?

I am a bit confused. Apple Documentation states the following:

Note. For performance reasons, Cocoa does not provide sister views or guarantee the correct invalidity and drawing behavior when the siblings' views overlap. If you want the view to be facing a different view, you must make the front view a subview (or descendant) of the back view.

So, in accordance with this, the opinions of the sister should not overlap, otherwise the behavior is undefined.

In Cocoa, the slide show demo application , however, has NSView siblings' native siblings overlap , and this seems to work just fine:

Cocoa Slides screenshot

So, the wrong Cocoa Slides code example, and is it just a coincidence that it works, or outdated documentation? Deprecated since 10.5, that is?

+11
cocoa core-animation calayer nsview
May 23 '12 at 12:37 a.m.
source share
5 answers

Overlapping views work fine, with layer support or not, on Leopard and higher.

+7
May 23 '12 at 23:20
source share

After some research, it seems that the Apple documentation is really out of date.

It is believed that the overlapping younger brothers of NSView may overlap with 10.5.

This discussion from 2009 , including Apple engineers David Duncan and Corbin Dunn , finally provides some clear answers:

Overlapping views works on Leopard, but doesn't work before. The documentation is out of date.

I have a group of views, each of which has smaller views inside, which should be presented with overlapping compared to the same directly in the window so that they can be seen from each other. In my preliminary tests, I made each big look the same background. He planned to bring everyone to the front when necessary, reordering the z-order. Is there a future (or present) in this application?

This will work on Leopard.

Source: http://www.cocoabuilder.com/archive/cocoa/228191-nsview-behaves-different-on-10-4-vs-10-5.html#228983

Update : James Dempsey also responded on Twitter :

My understanding is that the sister's matching views are in order with 10.5, with layer support or not.

+6
May 23 '12 at 12:37 a.m.
source share

Views with Layer-layer support are layered by OpenGL (well, Quartz composer, but it helps to think of each layer as a polygon with the OpenGL texture on it), so they always supported the correct overlap.

The thread on CocoaBuilder / Cocoa -Dev does not mention layers at all. This means that he talks about regular NSViews without CALayer support (more precisely, only with CALayer for the entire window).

One of the mentioned exceptions is OpenGLView (again, without layers), which always composes an OpenGL rectangle on top of the window, destroying any sub-points. I donโ€™t think that creating NSOpenGLView works with layer support, but instead you can use an OpenGL layer that will compose correctly between other layers.

Another exception is layers on top of views that do not support the layer, which makes sense, since all views that do not support the layer efficiently exchange one layer, which, of course, is below any of its sublayers (which layer is the supported hosting view in the parent a view that does not support the layer should be).

In short, it works with 10.5 for non-layered and since then forever for viewing with reservations with reservations when mixing and matching or using OpenGL.

PS - I am not 100% sure, however, the statement about overlapping non-elementary representations should be accepted as canonical. This is an unofficial expression made by an Apple engineer. Everything could change, and errors could be detected that would not work. I usually use layers when I need the correct overlap.

+4
May 23 '12 at 12:58
source share

This might be useful to someone: I had a problem with flickering overlapping non-layered subviews on MacOS 10.7+. In my application, views were used to display information about the selected graphic object (selection frame, zoom control points, etc.), so they had some kind of animation that they introduced in my case.

Matching siblings really seem to work just fine even without a layer, but in simpler cases. I had a bunch of animated views, each with its own timer - and she clicked. I found two solutions: either turn on the layers , or synchronize the animation by switching to one common timer and updating all views at the same time.

At least this trick helped in my application since I did not want to use layers.

+2
Feb 19 '13 at 7:56
source share

The NSView brothers are usually allowed to overlap. One thing that might hit you is how NSScrollView works by default. When you have a vanilla NSScrollView that overlaps your sisterโ€™s looks, things break down.

This is because of NSClipView, which only draws a portion of the scroll and copies material that has not changed. When you have sister views that overlap the scroll view, this optimization does not work, and the views seem to scroll, although they are only siblings.

To make overlapping sibling views work even when they are not supported by the layer, you need to disable this optimization:

[scrollView.contentView setCopiesOnScroll:NO]; 
+1
May 30 '15 at 18:33
source share



All Articles