CtrlLib: Improved Animate (thanks Frank De prins)

git-svn-id: svn://ultimatepp.org/upp/trunk@2681 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2010-09-10 13:40:02 +00:00
parent ea175bb23c
commit 2f4b309d3e

View file

@ -15,15 +15,29 @@ void Animate(Ctrl& c, const Rect& target, int type)
type = GUI_PopUpEffect();
Rect r0 = c.GetRect();
dword time0 = GetTickCount();
int anitime = 150;
if(type)
for(;;) {
dword t = (GetTickCount() - time0);
if(t > 200)
if(t > anitime)
break;
if(type == GUIEFFECT_SLIDE) {
int q = 25 * t / 200;
q *= q;
Rect r = r0;
if(r.left > target.left)
r.left -= ((r.left - target.left)* t) / anitime;
if(r.top > target.top)
r.top -= ((r.top - target.top) * t) / anitime;
if(r.right < target.right)
r.right += ((target.right - r.right) * t) / anitime;
if(r.bottom < target.bottom)
r.bottom += ((target.bottom - r.bottom) * t) / anitime;
if(r.GetWidth() > target.GetWidth())
r.right = (r.left + ((r.GetWidth() - target.GetWidth()) * t) / anitime);
if(r.GetHeight() > target.GetHeight())
r.bottom = (r.top + ((r.GetHeight() - target.GetHeight()) * t) / anitime);
#if 0
int q = 25 * t / 200;
q *= max(q - 10, 1);
if(r.left > target.left)
r.left = max(r.left - q, target.left);
if(r.top > target.top)
@ -38,11 +52,12 @@ void Animate(Ctrl& c, const Rect& target, int type)
r.bottom = r.top + target.GetHeight();
if(r == target)
break;
#endif
c.SetRect(r);
}
else
if(type == GUIEFFECT_FADE)
c.SetAlpha((byte)(255 * t / 200));
c.SetAlpha((byte)(255 * t / 120));
else
break;
c.Sync();