[ANN] Cocoa Animation class

I’ve written a somewhat “smart” class to use Cocoa’s NSViewAnimation API to fade/move/resize Xojo controls and windows.

More info here: http://www.tempel.org/RB/CocoaAnimation

Feel free to comment here, though I may not read answer here after a day or two - I’m not often in this forum.

Thank you :slight_smile:

Awesome! I’ve wanted to mess with NSAnimations, but haven’t had time. One question, using an Ease Out curve seems to invert the animation or sort of randomize it. Is there something else that needs to be set for that to work? or does it work smoothly for you?

I don’t know, Jim. Have you read the Cocoa docs on that? Or any indication that it works differently with a plain ObjC program?

Looks like it might be “expected” behavior…
I found an old post about it in 10.4.8 and this referring to “working properly without need to change Start and End KeyFrames”

I think that for it to work in your model, you’d need to recalculate the start and end and the offset for EaseOut mode…
if I swap the start and end ie

dim startingRectValue as Ptr = valueWithRect (NSClassFromString ("NSValue"), endingFrame) setObjectPtrForKeyString dict, startingRectValue, "NSViewAnimationStartFrameKey" dim newRectValue as Ptr = valueWithRect (NSClassFromString ("NSValue"), startingFrame) setObjectPtrForKeyString dict, newRectValue, "NSViewAnimationEndFrameKey"

then the motion is in the right direction, but the rectangle jumps back to the starting point at the end of the first animation…

Same result swapping FadeIn for FadeOut… the control fade’s out and in as it should be, but the control becomes non-visible at the end of the animation…

This is only in EaseOut mode. The others work great as they are.

Great! Thanks a lot for sharing, Thomas!
I haven’t checked the code, therefore I am not sure on the reason, but resizing the rectangle crops the right border on my Mac while the resize is in progress. Is this intentional?
Edit: Ignore that: I’ve overhead that in your instructions. But don’t ignore the appreciation!

Thomas excellent work and thank you very much for sharing!

That’s because I manually set the destination pos+size at the end of the animation (because Xojo’s control properties don’t update themselves automatically). The code is in TTsCocoaAnimationPrivate.updateControlProperties - disable that or fix it for your swapped start/end values and it might work.