From 2f4b309d3e5259b2449453bbe7e4876188c3b5fb Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 10 Sep 2010 13:40:02 +0000 Subject: [PATCH] CtrlLib: Improved Animate (thanks Frank De prins) git-svn-id: svn://ultimatepp.org/upp/trunk@2681 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlLib/CtrlUtil.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/uppsrc/CtrlLib/CtrlUtil.cpp b/uppsrc/CtrlLib/CtrlUtil.cpp index 1013dc943..fc9e3c7d1 100644 --- a/uppsrc/CtrlLib/CtrlUtil.cpp +++ b/uppsrc/CtrlLib/CtrlUtil.cpp @@ -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();