Animation for better UI in Mac OS Yosemite

See this here:

[quote]Animating Views and Windows

The NSViewAnimation class is a subclass of NSAnimation that provides a convenient way to animate aspects of your view and window objects, including the following:

Change the position of the frame.
Change the size of the frame
Change the opacity of the object and fade it in or out.[/quote]

In other words: As far as I see it (but gratefully accept correcting words), CAAnimation is for layers, but NSViewAnimation should be the right one for a window.

Normally 0 is top of the window.
With NSRect 0 is on bottom of the window ?
(see Window.Title)

What’s normal? :wink:
In Xojo, for the sake of unity between platforms, screen y 0 starts at the upper border. On OS X, it starts at the bottom line. Some objects even have a flipped property to change y direction without recalculating it against screen.height.

The tutorial is out - check out the code in this edition of the xDev mag http://www.xdevmag.com

[quote=171806:@Oliver Osswald]The idea is, that the Window fades out, rearranges to new size, position and contents and then fades in again with the new settings.
This worked very well until Yosemite. The vibrancy thing has killed that effect and OverlayWindowMBS is not working nicely there.

Is there a way to this with Core Animation?[/quote]
This exact scenario is covered in the tutorial.

There is a way to slow down or accelerate the animation with these declares ?

You have to wrap the animation in an NSAnimationContext. I think I have examples (and you can pick out the declares) in OSXLib

Thanks Ulrich. I catched you maclib sample but can’t compile becuase there is a compiler stop on this code:

ObjCBlocks. This item does not exsist

Any idea ??

[quote=312322:@Carlo De Simone]Thanks Ulrich. I catched you maclib sample but can’t compile becuase there is a compiler stop on this code:

ObjCBlocks. This item does not exsist

Any idea ??[/quote]
You need to install Joe Ranieri’s OBJC blocks plugin for the macOS part: https://xojo.io/f0e2dc7227f3
Here’s the forum discussion about it: https://forum.xojo.com/3586-obj-c-blocks-as-callbacks/0
Do not be alarmed that newer version warning might appear from tine to time. I check compatibility with the recent betas and it can happen that this version will be used for save accidentally.

thank. I tested the sample. very Interesting, but very unstable…
very good start , but can’t be used in production.

I didn’t try to convince you to use the library instead of the light-weight declares. But you can find the declares needed for the – in this case named AppleAnimationContext –, and you can use the examples to see how to change the duration of an animation.
Besides: What instability do you mean?

[quote=171632:@jim mckay]No problem, these sort of things are fun to play with. I’ve added Window resizing and RectControl FadeIn/FadeOut to the example. I also added an example of checking whether properties are animatable (eg frameOrigin, bounds, alphaValue etc)

I do agree though that if you’re looking for anything more that a simple point to point animation, you’ll need to dig into CoreAnimation. The default animator is really only intended for the most basic UI animations.[/quote]

Thanks Jim for sharing this usefull code. But this works only in 32bit compiled apps. In 64bit It crashes. There is an updated version for 64bit ? I have updated structures using cgfloat type instead of single…there is no more crash in 64bit but controls movments and fade effect does’nt apply correctly …

You need to change alpha to cgfloat too: https://dl.dropboxusercontent.com/u/21200221/Xojo/AnimatingControls/AnimatingControls.zip

Thanks Ulrich. Perfect! Now works like a charm.