Home » U++ Library support » U++ Core » Animate does not really animate
Animate does not really animate [message #28565] |
Tue, 07 September 2010 13:25 |
frankdeprins
Messages: 99 Registered: September 2008 Location: Antwerp - Belgium
|
Member |
|
|
Hello,
Lately, I was wondering why the GUIEFFECT_SLIDE produces such a flickering and messy effect, rather than a nice and smooth sliding.
The first thing I discovered, in the Animate function (CtrlLib.cpp), is that there is a grow/shrink factor calculated:
Now, since t is always <= 200, this q is always 0 except just before the loop is aborted. And, thus, no shrinking or growing is actually performed until the loop is aborted, because the 200msec are used up. After which the control is set to the target size. So actually, instead of a slide effect, there is just a delay of 200 msec and then the control gets the full target size.
I got a much smoother result by replacing the growing factor by the following code:
if(r.left > target.left)
r.left -= ((r.left - target.left)* t) /200;
if(r.top > target.top)
r.top -= ((r.top - target.top) * t) /200;
if(r.right < target.right)
r.right += ((target.right - r.right) * t) / 200;
if(r.bottom < target.bottom)
r.bottom += ((target.bottom - r.bottom) * t) / 200;
if(r.GetWidth() > target.GetWidth())
r.right = (r.left + ((r.GetWidth() - target.GetWidth()) * t) / 200);
if(r.GetHeight() > target.GetHeight())
r.bottom = (r.top + ((r.GetHeight() - target.GetHeight()) * t) / 200);
But, then there was something else: after the sliding effect, the popped control flashed once more. As far as I understand the code of the Drop procedure in controls like PopupTable, I guess the reason is that the popped up control is briefly removed and recreated. I wonder if that cannot be avoided. If not, one could use LockWindowUpdate on windows around this removing/recreating. I don't know if such a thing exists on other platforms.
Best regards,
frank
[Updated on: Thu, 09 September 2010 09:47] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu May 16 10:53:45 CEST 2024
Total time taken to generate the page: 0.02549 seconds
|