Re: Layer Backed Views and CoreAnimation neither animate nor stay in place
On 27.06.2008, at 14:56, Chilton Webb wrote: (1) If I specify that I want anything other than the main view to have a layer, that view will instantly 'pop' to the foreground in the window. However, its actual view remains in the same place in the view hierarchy. As far as I've seen so far, whenever a new layer is created, it is inserted in the front. The only way I've found to fix it is to set the zPosition of each view's layer manually. However, luckily that seems to work :-) Cheers, -- Uli Kusterer The Witnesses of TeachText are everywhere... http://www.zathras.de ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Layer Backed Views and CoreAnimation neither animate nor stay in place
On Jul 5, 2008, at 8:34 AM, Uli Kusterer wrote: On 27.06.2008, at 14:56, Chilton Webb wrote: (1) If I specify that I want anything other than the main view to have a layer, that view will instantly 'pop' to the foreground in the window. However, its actual view remains in the same place in the view hierarchy. As far as I've seen so far, whenever a new layer is created, it is inserted in the front. The only way I've found to fix it is to set the zPosition of each view's layer manually. However, luckily that seems to work :-) You can use -insertSublayer:[atIndex: | below: | above:] to put a layer in a specific ordering in the layer tree. This is generally cheaper than changing the zPosition, as a change in zPosition forces the sublayer list to be depth sorted. -- David Duncan Apple DTS Animation and Printing [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Layer Backed Views and CoreAnimation neither animate nor stay in place
Hi Chilton You better do the addition of subviews and setting up the core animation stuff in the view's awakeFromNib rather than its initWithFrame: method. Since the view is getting loaded from the nib, chances are that your settings within initWithFrame get overridden by the settings in the nib as a part of nib loading process. I am not sure if this is the reason though!. HTH Shripada Message: 11 Date: Fri, 27 Jun 2008 05:56:25 -0700 From: Chilton Webb [EMAIL PROTECTED] Subject: Layer Backed Views and CoreAnimation neither animate nor stay in place To: cocoa-dev@lists.apple.com Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1 Hi, I am absolutely confused regarding something simple in layer backed view animation, and it's been haunting me for many months now. So I have constructed a sample project that illustrates the 3 problems I run into most frequently. I'm hoping someone will point to some place in the docs I've missed, and explain why I'm having what I see as simple problems, so often. Here's the completed, zipped sample project. It's 63k. http://homepage.mac.com/chilton/.Public/SubViewDepthTest.zip The symptoms: (1) If I specify that I want anything other than the main view to have a layer, that view will instantly 'pop' to the foreground in the window. However, its actual view remains in the same place in the view hierarchy. (2) If I set [self setWantsLayer:YES] anywhere except where it is currently uncommented, the animations don't work at all. The window performs the update instantly, and without animating it! This seems very wrong. I would expect that I could set it at the end of my initialization at least, after I've built up my other layers, so that the tree would populate correctly. If I do that, no animation, but at least the view is replaced in the right stacking order. (3) Even when everything else is working right, the first time I perform my animation method, the animation does not work. Instead, it quickly swaps out the old view with the new one, and displays it in the foreground, on top of all other views, even if all other views are layer backed. This is obviously *not* 'replacing' the view in the order I want. After that, it animates properly, but on top of the other views instead of behind them. All I want is to animate the swapping out of the middle layer. What on Earth am I doing wrong? The very simple sample project is above, and the two main classes used are below. The first does all the work, the second is just there to look pretty. ANY SUGGESTIONS/CRITICISMS/COMMENTS GREATLY APPRECIATED!!! Thank you, -Chilton Webb --- Robosoft Technologies - Come home to Technology Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Layer Backed Views and CoreAnimation neither animate nor stay in place
Hi, I am absolutely confused regarding something simple in layer backed view animation, and it's been haunting me for many months now. So I have constructed a sample project that illustrates the 3 problems I run into most frequently. I'm hoping someone will point to some place in the docs I've missed, and explain why I'm having what I see as simple problems, so often. Here's the completed, zipped sample project. It's 63k. http://homepage.mac.com/chilton/.Public/SubViewDepthTest.zip The symptoms: (1) If I specify that I want anything other than the main view to have a layer, that view will instantly 'pop' to the foreground in the window. However, its actual view remains in the same place in the view hierarchy. (2) If I set [self setWantsLayer:YES] anywhere except where it is currently uncommented, the animations don't work at all. The window performs the update instantly, and without animating it! This seems very wrong. I would expect that I could set it at the end of my initialization at least, after I've built up my other layers, so that the tree would populate correctly. If I do that, no animation, but at least the view is replaced in the right stacking order. (3) Even when everything else is working right, the first time I perform my animation method, the animation does not work. Instead, it quickly swaps out the old view with the new one, and displays it in the foreground, on top of all other views, even if all other views are layer backed. This is obviously *not* 'replacing' the view in the order I want. After that, it animates properly, but on top of the other views instead of behind them. All I want is to animate the swapping out of the middle layer. What on Earth am I doing wrong? The very simple sample project is above, and the two main classes used are below. The first does all the work, the second is just there to look pretty. ANY SUGGESTIONS/CRITICISMS/COMMENTS GREATLY APPRECIATED!!! Thank you, -Chilton Webb // SubViewDepthTest.m // SubViewDepthTest // // Created by Chilton Webb on 6/26/08. // // (1) If I specify that I want anything other than the main view to have a layer, // that view will instantly 'pop' to the foreground in the window. However, // its actual view remains in the same place in the view hierarchy. // // (2) If I set [self setWantsLayer:YES] anywhere except where it is currently uncommented, // the animations don't work at all. The window performs the update instantely, // without animating it. // // (3) The first time we perform this method, this animation does not work, // it quickly swaps out the old view with the new one, and displays it in the foreground. // #import SubViewDepthTest.h @implementation SubViewDepthTest - (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { CATransition *transition = [CATransition animation]; [transition setType:kCATransitionPush]; [transition setSubtype:kCATransitionFromLeft]; NSDictionary *ani = [NSDictionary dictionaryWithObject:transition forKey:@subviews]; [self setAnimations:ani]; // (2) If I set this here, the animations don't work. // [self setWantsLayer:YES]; // Set up our views ColoredSubView *sv1 = [[ColoredSubView alloc] initWithFrame:NSMakeRect(0,0,frame.size.width,frame.size.height)]; [sv1 setColor:[NSColor redColor]]; [self addSubview:sv1]; ColoredSubView *sv2 = [[ColoredSubView alloc] initWithFrame:NSMakeRect(50,50,frame.size.width,frame.size.height)]; [sv2 setColor:[NSColor greenColor]]; [self addSubview:sv2]; ColoredSubView *sv3 = [[ColoredSubView alloc] initWithFrame:NSMakeRect(100,100,frame.size.width,frame.size.height)]; [sv3 setColor:[NSColor blueColor]]; [self addSubview:sv3]; // (2) If I set this here, the animations don't work, but the stacking order is right. // [self setWantsLayer:YES]; // Clean up [sv1 release]; [sv2 release]; [sv3 release]; } return self; } - (IBAction) testSwap:(id) sender { // (2) If I set this anywhere else, the animations don't work. [self setWantsLayer:YES]; // (3) See notes above ColoredSubView *svx = [[ColoredSubView alloc] initWithFrame:NSMakeRect(50,50,200,200)]; [svx setColor:[self anothercolor]]; [[self animator] replaceSubview:[[self subviews] objectAtIndex:1] with: svx]; [svx release]; } - (NSColor *) anothercolor { static unsigned i; NSColor *color; i++; if (i == 1) {
Re: Layer Backed Views and CoreAnimation neither animate nor stay in place
On Jun 27, 2008, at 08:56, Chilton Webb wrote: (3) Even when everything else is working right, the first time I perform my animation method, the animation does not work. Instead, it quickly swaps out the old view with the new one, and displays it in the foreground, on top of all other views, even if all other views are layer backed. This is obviously *not* 'replacing' the view in the order I want. After that, it animates properly, but on top of the other views instead of behind them. I'm surprised it doesn't work as intended. Maybe it's a bug in the replaceSubview:with: method. If you change your testSwap: method to the following it should maintain the view ordering: - (IBAction) testSwap:(id) sender { // (2) If I set this anywhere else, the animations don't work. // [self setWantsLayer:YES]; // (3) See notes above ColoredSubView *svx = [[ColoredSubView alloc] initWithFrame:NSMakeRect(50,50,200,200)]; [svx setColor:[self anothercolor]]; // [[self animator] replaceSubview:[[self subviews] objectAtIndex:1] with: svx]; NSView *viewToReplace = [[self subviews] objectAtIndex:1]; [[self animator] addSubview:svx positioned:NSWindowAbove relativeTo:viewToReplace]; [[viewToReplace animator] removeFromSuperview]; [svx release]; } It looks like you'll have to add this as well: - (void)awakeFromNib { [self setWantsLayer:YES]; } Your transition probably won't work as intended with this solution though (it works fine with the default fade animation, however), so to get the effect you want you may need to position the new view outside the visible boundaries of the superview and then use something like this to perform the transition: [NSAnimationContext beginGrouping]; [NSAnimationContext setDuration:0.5]; [[svx animator] setFrameOrigin:destinationFrameOrigin]; [[viewToReplace animator] setFrameOrigin:somewhereOutsideVisibleBoundaries]; [NSAnimationContext endGrouping]; [viewToReplace performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.5]; (I'm not sure that the transition you specified would work with replaceSubview:with: either. It seems to perform the animation on the entire superview, not just the subview being changed.) /brian smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]