Re: Technology recommendations for animation/display
On Mar 24, 2012, at 06:54 PM, Evadne Wu e...@monoceroi.com wrote: Why not both. Create a common model and use Core Animation to back the on-screen view, but when you need to draw, tell the model objects to draw themselves using Quartz. -ev I am considering this approach, and also re-looking at all the core animation and ns animation options, and have a few follow up questions: 1. One of the problems with using NSViews for an application like mine where I want to display a whole lot of sibling subviews that have to be in a particular order, has been that even though you can use -addSubview:positioned:relativeTo:, that didn't actually guarantee the order that the views were drawn. Now when I am reading through the Choosing the Animation Technology for Your Application documentation, I see that it says Both layers and layer-backed views support overlapping of layers/views with other layers/views outside of the sublayer/subview. Does that mean that when you add subviews when using layer backed views, they are actually guaranteed to honor their order (i.e. addSubview will draw the new subview in front of its siblings, and addSubview:positioned:relativeTo: will actually always draw in that order, and if you ask for subviews of a view, the order of the subviews will be the order in which they are actually drawn)? If so, it appears that I may be able to use layer backed views instead of a layer hosting view, which would mean that I wouldn't have to use a separate overlay window for editing text etc, which would solve a lot of problems. I might need to do some testing with layer backed views... 2. If I use layer backed views instead of a single layer hosting view, will that mean that I will be able to print properly (e.g shadows on the views print properly)? 3. I have played around with layer hosting before, but very little with layer backed views. Using layer hosting, I would have tried to use CAShapeLayer for my connector curves (though I have had trouble with these drawing strange things in the past), but if I am using layer backed views, I would need to be able to redraw the view during the animation. How would I do this? Is there some way to tell core animation that this view needs to redraw itself during the animation? I don't see anything that calls back to the layer saying that it is at a certain animation proportion. I see there is a needsDisplayOnBoundsChange property, but in some cases the bounds don't change. Could I just add an animatable property to the view which goes from 0.0 to 1.0, and then query that to find out how far through the animation it is, and force the view to display? Are there any other gotcha's with layer backed views to achieve the things I need? Thanks Ken. On Mar 24, 2012, at 3:02 PM, Kenneth Baxter k.b.bax...@mac.com wrote: Hi, I am developing an application where I need to be able to handle the following requirements: - Deployment: MacOS X 10.6 and later. May want to develop an iPad version later. - Type of application: Display and manipulation of graphical objects on a canvas. - Number of graphical objects: up to about 2,000 - Canvas needs to display solid color, gradient, or tiled image - The entire canvas with all the graphical objects on it need to be able to smoothly zoom and pan - Many of the graphical objects need to display text on them this must be high resolution rendering to look good - The text on graphical objects needs to be editable (I'm ok with putting a view overlay over it in order to accomplish this if necessary) - The graphical objects need to be able to be displayed with shadows and reflections. - The entire canvas and all the displayed objects must be printable at high resolution (i.e. PDF). - We need to animate movement of quite a number of the objects at once. - The objects that are moving have curved connection lines drawn to other objects that stay stationary, and those curves need to animate as the connected objects move. I am looking for recommendations on the best technology to use for this. ... ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Technology recommendations for animation/display
OK, so it looks as if I have found the answer to whether I would be able to use layer backed views, and the answer is that even with layer backing turned on, you can not guarantee the drawing order of overlapping sibling views: http://stackoverflow.com/questions/466297/is-there-a-proper-way-to-handle-overlapping-nsview-siblings This is really annoying because it will require a lot of work to work around, and also since sibling view layering apparently works on IOS, it would have been nice to use that paradigm on OSX. So this means that I have to either: A) See whether having a single view and using the NS animation options and animation proxies will give me the performance and functionality I need, or B) Try to work out the issues with drawing a tiled background canvas layer seamlessly with animated scrolling, resizing and scaling; drawing high quality text; the bug with large layers causing flickering; the problems with CAShapeLayers not always animating paths correctly; smooth scaling and pixel alignment of all the sublayers; having to have completely separate overlay windows for things like text editing which need to react to scrolling and scaling and synchronize them with the main view etc. Option B sounds scary because it includes a couple of bugs that I am aware of but have don't have a workaround for, and lots of work, so even though conceptually it would be nice to use CALayer (or even better, layer backed views if there was some way to get them to order siblings properly), it seems that if the performance is acceptable, I may just have to go with option A. While core animation would be nice, and in the future, 3d transforms etc might be nice, at the moment, my objects just need scale, opacity, and position animations. I guess the next thing to do is some testing with a full screen test app with a few hundred virtual views animating around, and see what sort of performance I get... If there are any comments on these options, or suggestions for other approaches, I'm all ears... Ken ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Technology recommendations for animation/display
On 27/03/2012, at 12:54 PM, Kenneth Baxter wrote: If there are any comments on these options, or suggestions for other approaches, I'm all ears... CALayer has a 'zPosition' property which should allow you to set the order for sibling layers. --Graham ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Technology recommendations for animation/display
Yes, that works if you are using pure CALayers - no problem there, but if you are using layer backed views, it doesn't work - see e.g. http://www.cocoabuilder.com/archive/cocoa/294950-problem-using-zposition-on-layer-backed-views.html ...so it still looks as if layer backed views are out... Ken On Mar 27, 2012, at 01:05 PM, Graham Cox graham@bigpond.com wrote: On 27/03/2012, at 12:54 PM, Kenneth Baxter wrote: If there are any comments on these options, or suggestions for other approaches, I'm all ears... CALayer has a 'zPosition' property which should allow you to set the order for sibling layers. --Graham ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Technology recommendations for animation/display
On Mar 26, 2012, at 8:17 PM, Kenneth Baxter wrote: Yes, that works if you are using pure CALayers - no problem there, but if you are using layer backed views, it doesn't work - see e.g. http://www.cocoabuilder.com/archive/cocoa/294950-problem-using-zposition-on-layer-backed-views.html ...so it still looks as if layer backed views are out… To be clear, you can do a limited number of things with layer-backed views. You can override -makeBackingLayer, for example, and customize the view's layer's appearance. But AppKit has its own internal understanding of zPosition that will conflict with yours when you least expect it. You _can_ safely have a layer-hosting view (call -setLayer: before calling -setWantsLayer:) as a subview of a layer-backed view (call -setWantsLayer: without calling -setLayer:). You _cannot_ have a layer-backed view as a subview of a layer-hosting view, nor should you add, remove, or manipulate the layers and sublayers of a layer-backed view. --Kyle Sluder ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Technology recommendations for animation/display
Hi, I am developing an application where I need to be able to handle the following requirements: - Deployment: MacOS X 10.6 and later. May want to develop an iPad version later. - Type of application: Display and manipulation of graphical objects on a canvas. - Number of graphical objects: up to about 2,000 - Canvas needs to display solid color, gradient, or tiled image - The entire canvas with all the graphical objects on it need to be able to smoothly zoom and pan - Many of the graphical objects need to display text on them this must be high resolution rendering to look good - The text on graphical objects needs to be editable (I'm ok with putting a view overlay over it in order to accomplish this if necessary) - The graphical objects need to be able to be displayed with shadows and reflections. - The entire canvas and all the displayed objects must be printable at high resolution (i.e. PDF). - We need to animate movement of quite a number of the objects at once. - The objects that are moving have curved connection lines drawn to other objects that stay stationary, and those curves need to animate as the connected objects move. I am looking for recommendations on the best technology to use for this. The following are my thoughts so far, based on trying a few things: 1. Using an NSView and just drawing on that, I can get scaling and printing for free, but I can't use subviews for each of the graphical objects because you can't set the z order of sibling subviews, so I would have to create my own layer system which just draws to the view that I am using - easy enough, and I've done that before. But of course with this system, I miss out on all the benefits of core animation, and have to create my own custom animation code (presumably with NSAnimation), and it's all just standard view drawing, which I presume isn't making use of much by way of GPU acceleration etc. 2. Using CALayers at initial sight may appear to be the obvious thing for something graphical like this, but I have observed a number of issues with it. For my background, using tiled layers seems to not work too well when you have large texture images being tiled, and you can see the tiles being drawn. Scaling seems to be an issue as everything gets scaled and then redrawn, and looks blurry in the middle, and I have to take the scale factor into account with every piece of drawing code, including scaling fonts and even inline images in text etc. Also, printing is a problem, though I have found some code that goes through and extracts CG drawing commands and sends them to a PDF context, which gets me most of the way there, except that it seems to have trouble with translucent colors in some circumstances (especially on gradients), and can't draw shadows. I can't add a subview for the text editing, so have to create an overlay invisible window and position it right, and pass on scroll and zoom events etc just to have an editable subview that I can use for text editing. Also, I've come across some issues where a graphical object is over 10,000 pixels in one dimension in certain circumstances and on older computers in particular, the entire graphics buffer seems to get screwed up, and it flickers while it redraws (and the redraw is slow). Apple have acknowledged this issue, and it may well have already been fixed in 10.7+, but is IMHO very unlikely to be fixed in 10.6, so I'd have to find a workaround for that. Also, no matter what I do, the text drawing seems to never be as crisp as it is when I draw straight on my view in the NSView case. And despite having CAShapeLayer now, it sometimes seems to draw my curves doing crazy things during animations. So quite a lot of debugging to do. So should I go with NSView based drawing, where I know that the drawing and printing is going to work just right, and I have to code my own animations for zooming, scrolling, and moving objects around? Would I be able to get good enough performance doing this to get smooth animations? Are there any other downsides to this? Or should I go with Core Animation, and sort out the issues with drawing the tiled background, zooming smoothly, printing with shadows, text quality, having to have overlay windows, drawing everything scaled, etc, in order to be using the latest technologies and get the advantages of core animation? Or is there some other or hybrid option that I am not thinking of? Which approach would be easiest to port later to iPad? Any advice on this would be great! Thanks, Ken. ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com