aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmarshallnz <jcmarsha@gmail.com>2014-04-20 08:54:43 +1200
committerJonathan Marshall <jmarshall@xbmc.org>2014-04-26 09:09:12 +1200
commit927dda2dd19bb43d069fdca42ee1aa967e4ce68e (patch)
treeb2197873953ceb6434c0b5153def2bf54761189a
parent473b1682fdb5e69149b9b76267e9a2ef83cffa89 (diff)
Merge pull request #4580 from jmarshallnz/anim_length_fix
[guilib] animation length was calculated incorrectly from effects
-rw-r--r--xbmc/guilib/VisibleEffect.cpp27
-rw-r--r--xbmc/guilib/VisibleEffect.h1
2 files changed, 13 insertions, 15 deletions
diff --git a/xbmc/guilib/VisibleEffect.cpp b/xbmc/guilib/VisibleEffect.cpp
index 170d44591e..035c99887d 100644
--- a/xbmc/guilib/VisibleEffect.cpp
+++ b/xbmc/guilib/VisibleEffect.cpp
@@ -574,7 +574,9 @@ CAnimation CAnimation::CreateFader(float start, float end, unsigned int delay, u
{
CAnimation anim;
anim.m_type = type;
- anim.AddEffect(new CFadeEffect(start, end, delay, length));
+ anim.m_delay = delay;
+ anim.m_length = length;
+ anim.m_effects.push_back(new CFadeEffect(start, end, delay, length));
return anim;
}
@@ -653,7 +655,6 @@ void CAnimation::Create(const TiXmlElement *node, const CRect &rect, int context
m_repeatAnim = ANIM_REPEAT_LOOP;
}
- m_delay = 0xffffffff;
if (!effect)
{ // old layout:
// <animation effect="fade" start="0" end="100" delay="10" time="2000" condition="blahdiblah" reversible="false">focus</animation>
@@ -670,6 +671,15 @@ void CAnimation::Create(const TiXmlElement *node, const CRect &rect, int context
AddEffect(type, effect, rect);
effect = effect->NextSiblingElement("effect");
}
+ // compute the minimum delay and maximum length
+ m_delay = 0xffffffff;
+ unsigned int total = 0;
+ for (vector<CAnimEffect*>::const_iterator i = m_effects.begin(); i != m_effects.end(); ++i)
+ {
+ m_delay = min(m_delay, (*i)->GetDelay());
+ total = max(total, (*i)->GetLength());
+ }
+ m_length = total - m_delay;
}
void CAnimation::AddEffect(const CStdString &type, const TiXmlElement *node, const CRect &rect)
@@ -689,18 +699,7 @@ void CAnimation::AddEffect(const CStdString &type, const TiXmlElement *node, con
effect = new CZoomEffect(node, rect);
if (effect)
- AddEffect(effect);
-}
-
-void CAnimation::AddEffect(CAnimEffect *effect)
-{
- m_effects.push_back(effect);
- // our delay is the minimum of all the effect delays
- if (effect->GetDelay() < m_delay)
- m_delay = effect->GetDelay();
- // our length is the maximum of all the effect lengths
- if (effect->GetLength() > m_delay + m_length)
- m_length = effect->GetLength() - m_delay;
+ m_effects.push_back(effect);
}
CScroller::CScroller(unsigned int duration /* = 200 */, boost::shared_ptr<Tweener> tweener /* = NULL */)
diff --git a/xbmc/guilib/VisibleEffect.h b/xbmc/guilib/VisibleEffect.h
index c065b43552..5efac319cd 100644
--- a/xbmc/guilib/VisibleEffect.h
+++ b/xbmc/guilib/VisibleEffect.h
@@ -178,7 +178,6 @@ public:
private:
void Calculate(const CPoint &point);
void AddEffect(const CStdString &type, const TiXmlElement *node, const CRect &rect);
- void AddEffect(CAnimEffect *effect);
enum ANIM_REPEAT { ANIM_REPEAT_NONE = 0, ANIM_REPEAT_PULSE, ANIM_REPEAT_LOOP };