What is the algorithm of window transition animation effect used in DWM

297 Views Asked by At

When min/maximizing windows on Windows, DWM applies the transition effect so the window gradually resizes, changes its transparency and moves. I want to mimic this effect on thumbnails, so I want to know the animation algorithm and its parameters (duration, transparency and size/position change step, etc.).

1

There are 1 best solutions below

2
Wisblade On

These kind of graphical animations are rarely documented, just because it's quite usual to be allowed to disable them first, and sometimes, they adapt themselves to hardware's capabilities and/or theme. It's not really an "algorithm" per se but rather a cosmetic thingy.

So your best shot is to implement quite the same, BUT with a bunch load of parameters - each time you need a constant, you set it as a parameter within a global structure that contains them all.

You resize first the window?

  • Parameterize the number of steps.
  • Parameterize the delay between each step.
  • If window moves, set the same steps/delay parameterization for each axis.

Then you change transparency?

  • Get current transparency, set number of steps and delay.
  • Parameterize the final transparency.
  • What if current transparency is lower than final transparency?

Then moving window:

  • Which final speed do you want? A parameter for that.
  • Minimum/maximum number of steps.
  • Where is window supposed to move to? Another (X,Y) parameter.

Want to do the three simultaneously?

  • Add one or two parameters to do some effects simultaneously, or sequentially.
  • To achieve that, you'll need some helper functions to "get next step" for each implemented effet, so that you can do them simultaneously easily by calling (or not calling!) each individual "next step" within your loop.

And so on...

After that, you just have to try it several times, and adjust your parameters accordingly. Obviously, having a little GUI allowing you to do it in real time without recompiling your code is better and easier.