Re: NSView vs CALayer
Christiaan Hofman <[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sep 29, 2009, at 18:46, parfeon wrote: > > > > Christiaan Hofman-2 wrote: >> >> >> On Sep 29, 2009, at 18:03, parfeon wrote: >> >>> >>> >>> Christiaan Hofman-2 wrote: >>>> >>>> >>>> On Sep 29, 2009, at 12:32, parfeon wrote: >>>> >>>>> >>>>> Hello everyone. >>>>> >>>>> Working on project which draws some parts of its UI with >>>>> CoreAnimation >>>>> CALayers. Currently i need create some cover view, which will >>>>> appear >>>>> over >>>>> whole UI (that NSView always there, coz it will response on user >>>>> drag n >>>>> drop). >>>>> I'm stumbled with such problem as shown on screen >>>>> >>>>> http://www.nabble.com/file/p25659257/nsviewvscalayer.png >>>>> >>>>> http://img44.imageshack.us/i/nsviewvscalayer.png/ >>>>> >>>>> Transparent view overlays the view in which I used CALayers for >>>>> drawing. >>>>> Dunno why, but when I change that subview (with CALayers) to any >>>>> other (w/o >>>>> CoreAnimation drawing... some standard IB elements) everything >>>>> looks >>>>> great. >>>>> >>>>> >>>>> Can someone help me with this? >>>>> >>>>> Thanks >>>> >>>> I really can't understand your message and in particular what your >>>> specific problem is. But the basic fact is that layer-hosting views >>>> cannot have subviews, so I guess that's where you run into. >>>> >>>> Christiaan >>>> >>>> _______________________________________________ >>>> MacOSX-dev mailing list >>>> [email protected] >>>> http://www.omnigroup.com/mailman/listinfo/macosx-dev >>>> >>>> >>> Quoted from: >>> http://www.nabble.com/NSView-vs-CALayer-tp25659257p25663495.html >>> >>> >>> My bad. Will try to explain all what I have done. Currently I want >>> try to >>> make behavior of window like in Transmission when You drag >>> over .torrent >>> file (appears blacj cover with info on center) >>> >>> 1. I have XIB with such structure as shown on image: >>> http://img21.imageshack.us/img21/2967/mainxibstructure.png . I've >>> placed >>> there split view (2 views inside). Left view used for displaying >>> source list >>> (as we can see here >>> http://www.nabble.com/file/p25659257/nsviewvscalayer.png) and the >>> right view >>> i used for displaying information (Place Holder). And also there >>> over that >>> split view "Drag&Drop Layer" (custom NSView where with CA I'm >>> drawing >>> transparent background); >>> 2. After application do launch, my code placing inside "Place >>> Holder" (with >>> addSubview:) new custom view (instance of NSView placed in other XIB >>> file); >>> 3. On awakeFromNib that custom view creates CALayers and draws there >>> content >>> (background and buttons). On 'self' of custom view I'm setting >>> setLayer to >>> "baseLayer" (which holds all graphics) and then call >>> setWantsLayer:YES; >>> 4. And at the end we can see picture as I shown: >>> http://www.nabble.com/file/p25659257/nsviewvscalayer.png It look's >>> like >>> "Drag&Drop Layer" cut out piece of custom view inside "Place >>> Holder". >>> >>> Here is the code which I use to insert custom view inside "Place >>> Holder": >>> >>> - (void)changeViewTo:(id)view{ >>> if(currentView != [view view]) >>> currentView = nil; >>> >>> if([[placeHolderView subviews] count] == 0){ >>> [placeHolderView addSubview:[view view]]; >>> else >>> [placeHolderView replaceSubview:[[placeHolderView subviews] >>> objectAtIndex:0] with:[view view]]; >>> >>> currentView = [view view]; >>> >>> [currentView setFrame:[[currentView superview] frame]]; >>> >>> [currentView setFrameOrigin:NSMakePoint(0,0)]; >>> [currentView setAutoresizingMask:NSViewWidthSizable | >>> NSViewHeightSizable]; >>> } >>> >>> currentView - is type of NSView >>> placeHolderView - is IBOutlet on "Place Holder" view of NSView class >>> >>> But when I'm adding inside placeHolder other custom view (which is >>> inside >>> loaded XIB) we can see this picture >>> http://img182.imageshack.us/img182/1951/nsviewvsnsview.png In that >>> view >>> placed standard elements, which not drawn in real time. >>> >>> Sp till now I can't understand what I'm doing wrong. Can someone >>> help with >>> this? >> >> You still did not say what your problem is. What do you get? What do >> you expect? What do you want to get? What do you think is wrong? >> There's a lot of things going on, and I don't know which part is >> relevant. And your Engrish also does not help. >> >> Perhaps you should try to reduce your problem to a much simpler >> model. >> >> Is the transparent overlay that partially covers the window the >> CADragnDropView? In that case your setup makes no sense, because the >> splitview and dragndropview are overlapping sibling views, which is >> not supported and generally results in a mess. >> >> Christiaan >> >> _______________________________________________ >> MacOSX-dev mailing list >> [email protected] >> http://www.omnigroup.com/mailman/listinfo/macosx-dev >> >> > > > Yes, problem lies in that, what I can't make DragNDrop to be > transparent for > view with content (I show that on screenshot). Ok, I got it, but why > DragNDrop view is transparent when showing different views (with > content > which not drown with CA). I'm just little bit confused about this, > at one > hand it's work with other views, at another it doesn't want work > correct > with another custom view. Thats why i thought what there something > wrong in > methods which I use to draw or place this view. You should not be confused: it's wrong, the result is undefined, so it just does not work. It is irrelevant in which way it goes wrong. Christiaan