aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Marshall <jmarshall@never.you.mind>2011-06-30 14:15:47 +1200
committerJonathan Marshall <jmarshall@never.you.mind>2011-06-30 14:15:47 +1200
commit9de276ecc99c33738fbf346de597bb04f4620d8e (patch)
tree9209b34889fc66cd9ceaeccb9800b19ab6c2ddb4
parent1c2d0e17ab2cf0a50b33540bc5f403e9fd6d5ca4 (diff)
process fadelabel control so that it's not marked dirty when not scrolling
-rw-r--r--xbmc/guilib/GUIFadeLabelControl.cpp134
-rw-r--r--xbmc/guilib/GUIFadeLabelControl.h2
2 files changed, 71 insertions, 65 deletions
diff --git a/xbmc/guilib/GUIFadeLabelControl.cpp b/xbmc/guilib/GUIFadeLabelControl.cpp
index c3bca4d9a3..27d7eda4ba 100644
--- a/xbmc/guilib/GUIFadeLabelControl.cpp
+++ b/xbmc/guilib/GUIFadeLabelControl.cpp
@@ -34,7 +34,6 @@ CGUIFadeLabelControl::CGUIFadeLabelControl(int parentID, int controlID, float po
m_scrollOut = scrollOut;
m_fadeAnim = CAnimation::CreateFader(100, 0, timeToDelayAtEnd, 200);
m_fadeAnim.ApplyAnimation();
- m_renderTime = 0;
m_lastLabel = -1;
m_scrollSpeed = labelInfo.scrollSpeed; // save it for later
m_resetOnLabelChange = resetOnLabelChange;
@@ -52,7 +51,6 @@ CGUIFadeLabelControl::CGUIFadeLabelControl(const CGUIFadeLabelControl &from)
m_fadeAnim = from.m_fadeAnim;
m_fadeAnim.ApplyAnimation();
m_currentLabel = 0;
- m_renderTime = 0;
m_lastLabel = -1;
ControlType = GUICONTROL_FADELABEL;
}
@@ -74,28 +72,10 @@ void CGUIFadeLabelControl::AddLabel(const string &label)
void CGUIFadeLabelControl::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
{
- // TODO Proper processing which marks when its actually changed. Just mark always for now.
- MarkDirtyRegion();
-
- m_renderTime = currentTime;
-
- CGUIControl::Process(currentTime, dirtyregions);
-}
-
-bool CGUIFadeLabelControl::UpdateColors()
-{
- bool changed = CGUIControl::UpdateColors();
- changed |= m_label.UpdateColors();
-
- return changed;
-}
-
-void CGUIFadeLabelControl::Render()
-{
if (m_infoLabels.size() == 0 || !m_label.font)
- { // nothing to render
- CGUIControl::Render();
- return ;
+ {
+ CGUIControl::Process(currentTime, dirtyregions);
+ return;
}
if (m_currentLabel >= m_infoLabels.size() )
@@ -103,6 +83,7 @@ void CGUIFadeLabelControl::Render()
if (m_textLayout.Update(GetLabel()))
{ // changed label - update our suffix based on length of available text
+ MarkDirtyRegion();
float width, height;
m_textLayout.GetTextExtent(width, height);
float spaceWidth = m_label.font->GetCharWidth(L' ');
@@ -124,6 +105,70 @@ void CGUIFadeLabelControl::Render()
m_lastLabel = m_currentLabel;
}
+ if (m_infoLabels.size() > 1 || !m_shortText)
+ { // have scrolling text
+ MarkDirtyRegion();
+
+ bool moveToNextLabel = false;
+ if (!m_scrollOut)
+ {
+ vecText text;
+ m_textLayout.GetFirstText(text);
+ if (m_scrollInfo.characterPos && m_scrollInfo.characterPos < text.size())
+ text.erase(text.begin(), text.begin() + min((int)m_scrollInfo.characterPos - 1, (int)text.size()));
+ if (m_label.font->GetTextWidth(text) < m_width)
+ {
+ if (m_fadeAnim.GetProcess() != ANIM_PROCESS_NORMAL)
+ m_fadeAnim.QueueAnimation(ANIM_PROCESS_NORMAL);
+ moveToNextLabel = true;
+ }
+ }
+ else if (m_scrollInfo.characterPos > m_textLayout.GetTextLength())
+ moveToNextLabel = true;
+
+ // apply the fading animation
+ TransformMatrix matrix;
+ m_fadeAnim.Animate(currentTime, true);
+ m_fadeAnim.RenderAnimation(matrix);
+ m_fadeMatrix = g_graphicsContext.AddTransform(matrix);
+
+ if (m_fadeAnim.GetState() == ANIM_STATE_APPLIED)
+ m_fadeAnim.ResetAnimation();
+
+ m_scrollInfo.SetSpeed((m_fadeAnim.GetProcess() == ANIM_PROCESS_NONE) ? m_scrollSpeed : 0);
+
+ if (moveToNextLabel)
+ { // increment the label and reset scrolling
+ if (m_fadeAnim.GetProcess() != ANIM_PROCESS_NORMAL)
+ {
+ if (++m_currentLabel >= m_infoLabels.size())
+ m_currentLabel = 0;
+ m_scrollInfo.Reset();
+ m_fadeAnim.QueueAnimation(ANIM_PROCESS_REVERSE);
+ }
+ }
+ g_graphicsContext.RemoveTransform();
+ }
+
+ CGUIControl::Process(currentTime, dirtyregions);
+}
+
+bool CGUIFadeLabelControl::UpdateColors()
+{
+ bool changed = CGUIControl::UpdateColors();
+ changed |= m_label.UpdateColors();
+
+ return changed;
+}
+
+void CGUIFadeLabelControl::Render()
+{
+ if (!m_label.font)
+ { // nothing to render
+ CGUIControl::Render();
+ return ;
+ }
+
float posY = m_posY;
if (m_label.align & XBFONT_CENTER_Y)
posY += m_height * 0.5f;
@@ -139,34 +184,8 @@ void CGUIFadeLabelControl::Render()
return;
}
- bool moveToNextLabel = false;
- if (!m_scrollOut)
- {
- vecText text;
- m_textLayout.GetFirstText(text);
- if (m_scrollInfo.characterPos && m_scrollInfo.characterPos < text.size())
- text.erase(text.begin(), text.begin() + min((int)m_scrollInfo.characterPos - 1, (int)text.size()));
- if (m_label.font->GetTextWidth(text) < m_width)
- {
- if (m_fadeAnim.GetProcess() != ANIM_PROCESS_NORMAL)
- m_fadeAnim.QueueAnimation(ANIM_PROCESS_NORMAL);
- moveToNextLabel = true;
- }
- }
- else if (m_scrollInfo.characterPos > m_textLayout.GetTextLength())
- moveToNextLabel = true;
-
- // apply the fading animation
- TransformMatrix matrix;
- m_fadeAnim.Animate(m_renderTime, true);
- m_fadeAnim.RenderAnimation(matrix);
- g_graphicsContext.AddTransform(matrix);
-
- if (m_fadeAnim.GetState() == ANIM_STATE_APPLIED)
- m_fadeAnim.ResetAnimation();
-
- m_scrollInfo.SetSpeed((m_fadeAnim.GetProcess() == ANIM_PROCESS_NONE) ? m_scrollSpeed : 0);
-
+ // render the scrolling text
+ g_graphicsContext.SetTransform(m_fadeMatrix);
if (!m_scrollOut && m_shortText)
{
float posX = m_posX + m_label.offsetX;
@@ -178,20 +197,7 @@ void CGUIFadeLabelControl::Render()
}
else
m_textLayout.RenderScrolling(m_posX, posY, 0, m_label.textColor, m_label.shadowColor, (m_label.align & ~3), m_width, m_scrollInfo);
-
- if (moveToNextLabel)
- { // increment the label and reset scrolling
- if (m_fadeAnim.GetProcess() != ANIM_PROCESS_NORMAL)
- {
- if (++m_currentLabel >= m_infoLabels.size())
- m_currentLabel = 0;
- m_scrollInfo.Reset();
- m_fadeAnim.QueueAnimation(ANIM_PROCESS_REVERSE);
- }
- }
-
g_graphicsContext.RemoveTransform();
-
CGUIControl::Render();
}
diff --git a/xbmc/guilib/GUIFadeLabelControl.h b/xbmc/guilib/GUIFadeLabelControl.h
index 6d7c7f2949..6d4d759201 100644
--- a/xbmc/guilib/GUIFadeLabelControl.h
+++ b/xbmc/guilib/GUIFadeLabelControl.h
@@ -78,7 +78,7 @@ protected:
CScrollInfo m_scrollInfo;
CGUITextLayout m_textLayout;
CAnimation m_fadeAnim;
- unsigned int m_renderTime;
+ TransformMatrix m_fadeMatrix;
unsigned int m_scrollSpeed;
bool m_resetOnLabelChange;
};