How does the layout support of Cappuccino work? For example the centering and the automatik resizing.
The autoresizing masks are more or less implemented in this method:
http://github.com/280north/cappuccino/blob/master/AppKit/CPView.j#L987
On a more conceptual level, all views in Cappuccino are absolutely positioned. By not relying on the browser to lay things out, we always know exactly where everything is, and can make decisions accordingly.
Are you asking for an explanation on how to use the feature (one good place is this tutorial: http://cappuccino.org/learn/tutorials/automatic-layout/ ), or are you asking how it is implemented?
Related
I'm wondering how to implement views similar to the conversation views in mail (for Lion).
http://images.apple.com/macosx/whats-new/images/mail_conversation_screen.jpg
I want the effect where it looks like a sheet of paper laying on the background.
I'm thinking that it may just be a view based table view.
A nudge in the right direction would be fine. Just need to know where to look to find out how to do it.
Thanks in advance.
It could be a view based table view or just a normal container view with some simple tiling logic (ie, "roll through each subview and set their frames"). The effect you're looking for, though, can be easily accomplished with layer-backed views with a background shadow enabled.
There are several perfectly valid approaches to this goal (the layout and drawing parts). Pick one, start down the path, then post questions as problems arise.
How would I change from one view to another with a slide transition?
Thanks.
Place them side by side, and use NSViewAnimation to perform the animation.
This may turn out tricky if the views' size can change. Doubly so if the two views are not the same size as each other.
Marcus Zarra gives a good example of how to use Core Animation to achieve this effect in his post on how to implement a wizard. It's very simple to do using subviews and a CATransition.
Implement all the actual drawing using CALayers. (Having not used Core Animation myself, I can't get more specific.) Put them in a single view, hosting that layer hierarchy, and use Core Animation to perform the slide transition.
This may not work so well if the views are not display-only—that is, if they host controls that the user can interact with. Layers are more or less display-only, since you can't put a view in a layer, and only views, not layers, are responders.
I'm working on a Snow Leopard app and I'm doing some view animations (swapping them) and I've seen some older examples using NSViewAnimation. I'm wondering if these are completely obsoleted by Core Animation?
It seems fairly simple for me to use
[[myView animator] setFrame:newSwapFrame];
But I'm just wondering if I'm missing something, or if NSViewAnimation is still relevant (other than for backwards compatibility).
Generally you should move to Core Animation for 10.5+ code. NSViewAnimation is fairly primitive and doesn't make as efficient use of the hardware. I can't think of any advantages of staying with NSViewAnimation other than 10.4 compatibility.
There are some cases where Core Animation is not suitable. For example, you can't put a WebView in a layer-backed view without funky things happening.
Also, text fields in layer-backed views don't use subpixel anti-aliasing, which can be a deal breaker.
If you're not using layer-backed views then your example of just using the animatable property support is definitely easier than using NSAnimation.
If you need to get window screenshot later (as example, to make transition animation between two window states), the Core Animated views (view with CAAnimation) may not been grabbed.
But CAAnimation is always working fast, and NSAnimation may slowing if CPU is too busy.
I would like to create an effect than an image zooms up from a thumbnail size to full screen.
I am not sure what's the right steps to achieve this. Should I create a transparent full screen window and animate a layer on top of it?
Take a look at this CoreGraphics example. Specifically, take a look at the "grow" and "shrink" animations. That's how Apple does it, and that's what you'll want to do too.
Your solution of a transparent window with a CALayer inside is probably the best supported way to do it.
One thing that seems like it should be a good solution (at least it's the first thing I thought of when I wanted to do this) but isn't is NSView's enterFullScreenMode:withOptions:. If memory serves, it was originally meant to do what you're talking about here, but the animation was taken out and it generally doesn't work that well now.
How difficult would it be to use core animation to make an NSView slide in an out of view like a sheet? Generally speaking, what would be involved in accomplishing this? I've been reading through the CA documentation, but it's been hard for me to pinpoint which parts are relevant to what I want to do since I have no experience with the framework.
Any tips at all would be much appreciated.
Thanks.
Since you're talking of a NSView, you're probably using Cocoa's animation support, not CA directly. In this case, you just need to set the view's frame through the view's animator object:
[theView setFrame:offscreenFrame];
[[theView animator] setFrame:finalFrame];
Unfortunately, Cocoa view animation interacts badly with the more advanced features of CA, like setting an easing. You might have more luck using NSViewAnimation instead, which is not Core Animation-backed and allows for a little more flexibility.