Permalink
Browse files

cleanup GUITextBox processing so that everything happens in Process

  • Loading branch information...
1 parent 4abfbd7 commit c6827bada7cde6f19660f3bb4a8b8a76712676ca Jonathan Marshall committed Jun 29, 2011
Showing with 33 additions and 47 deletions.
  1. +33 −45 xbmc/guilib/GUITextBox.cpp
  2. +0 −2 xbmc/guilib/GUITextBox.h
View
@@ -39,7 +39,6 @@ CGUITextBox::CGUITextBox(int parentID, int controlID, float posX, float posY, fl
m_itemHeight = 10;
ControlType = GUICONTROL_TEXTBOX;
m_pageControl = 0;
- m_renderTime = 0;
m_lastRenderTime = 0;
m_scrollTime = scrollTime;
m_autoScrollCondition = 0;
@@ -69,7 +68,6 @@ CGUITextBox::CGUITextBox(const CGUITextBox &from)
m_scrollSpeed = 0;
m_itemsPerPage = 10;
m_itemHeight = 10;
- m_renderTime = 0;
m_lastRenderTime = 0;
m_autoScrollDelayTime = 0;
ControlType = GUICONTROL_TEXTBOX;
@@ -108,17 +106,6 @@ void CGUITextBox::UpdateInfo(const CGUIListItem *item)
void CGUITextBox::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions)
{
- m_renderTime = currentTime;
-
- // render the repeat anim as appropriate
- if (m_autoScrollRepeatAnim)
- {
- m_autoScrollRepeatAnim->Animate(m_renderTime, true);
- TransformMatrix matrix;
- m_autoScrollRepeatAnim->RenderAnimation(matrix);
- m_cachedTextMatrix = g_graphicsContext.AddTransform(matrix);
- }
-
CGUIControl::DoProcess(currentTime, dirtyregions);
// if not visible, we reset the autoscroll timer and positioning
@@ -130,39 +117,17 @@ void CGUITextBox::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyreg
m_scrollOffset = 0;
m_scrollSpeed = 0;
}
- if (m_autoScrollRepeatAnim)
- g_graphicsContext.RemoveTransform();
}
void CGUITextBox::Process(unsigned int currentTime, CDirtyRegionList &dirtyregions)
{
- // TODO Proper processing which marks when its actually changed. Just mark always for now.
- MarkDirtyRegion();
-
- CGUIControl::Process(currentTime, dirtyregions);
-}
-
-void CGUITextBox::DoRender()
-{
- // render the repeat anim as appropriate
- if (m_autoScrollRepeatAnim)
- g_graphicsContext.SetTransform(m_cachedTextMatrix);
-
- CGUIControl::DoRender();
-
- if (m_autoScrollRepeatAnim)
- g_graphicsContext.RemoveTransform();
-}
-
-void CGUITextBox::Render()
-{
// update our auto-scrolling as necessary
if (m_autoScrollTime && m_lines.size() > m_itemsPerPage)
{
if (!m_autoScrollCondition || g_infoManager.GetBool(m_autoScrollCondition, m_parentID))
{
if (m_lastRenderTime)
- m_autoScrollDelayTime += m_renderTime - m_lastRenderTime;
+ m_autoScrollDelayTime += currentTime - m_lastRenderTime;
if (m_autoScrollDelayTime > (unsigned int)m_autoScrollDelay && m_scrollSpeed == 0)
{ // delay is finished - start scrolling
if (m_offset < (int)m_lines.size() - m_itemsPerPage)
@@ -187,23 +152,50 @@ void CGUITextBox::Render()
ResetAutoScrolling(); // conditional is false, so reset the autoscrolling
}
+ // render the repeat anim as appropriate
+ if (m_autoScrollRepeatAnim)
+ {
+ m_autoScrollRepeatAnim->Animate(currentTime, true);
+ TransformMatrix matrix;
+ m_autoScrollRepeatAnim->RenderAnimation(matrix);
+ m_cachedTextMatrix = g_graphicsContext.AddTransform(matrix);
+ }
+
// update our scroll position as necessary
if (m_lastRenderTime)
- m_scrollOffset += m_scrollSpeed * (m_renderTime - m_lastRenderTime);
+ m_scrollOffset += m_scrollSpeed * (currentTime - m_lastRenderTime);
if ((m_scrollSpeed < 0 && m_scrollOffset < m_offset * m_itemHeight) ||
(m_scrollSpeed > 0 && m_scrollOffset > m_offset * m_itemHeight))
{
m_scrollOffset = m_offset * m_itemHeight;
m_scrollSpeed = 0;
}
- m_lastRenderTime = m_renderTime;
+ m_lastRenderTime = currentTime;
+
+ if (m_pageControl)
+ {
+ CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), m_pageControl, MathUtils::round_int(m_scrollOffset / m_itemHeight));
+ SendWindowMessage(msg);
+ }
+ MarkDirtyRegion();
- int offset = (int)(m_scrollOffset / m_itemHeight);
+ CGUIControl::Process(currentTime, dirtyregions);
+
+ if (m_autoScrollRepeatAnim)
+ g_graphicsContext.RemoveTransform();
+}
+
+void CGUITextBox::Render()
+{
+ // render the repeat anim as appropriate
+ if (m_autoScrollRepeatAnim)
+ g_graphicsContext.SetTransform(m_cachedTextMatrix);
if (g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height))
{
// we offset our draw position to take into account scrolling and whether or not our focused
// item is offscreen "above" the list.
+ int offset = (int)(m_scrollOffset / m_itemHeight);
float posX = m_posX;
float posY = m_posY + offset * m_itemHeight - m_scrollOffset;
@@ -231,12 +223,8 @@ void CGUITextBox::Render()
g_graphicsContext.RestoreClipRegion();
}
-
- if (m_pageControl)
- {
- CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), m_pageControl, MathUtils::round_int(m_scrollOffset / m_itemHeight));
- SendWindowMessage(msg);
- }
+ if (m_autoScrollRepeatAnim)
+ g_graphicsContext.RemoveTransform();
CGUIControl::Render();
}
View
@@ -51,7 +51,6 @@ class CGUITextBox : public CGUIControl, public CGUITextLayout
virtual void DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregions);
virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
- virtual void DoRender();
virtual void Render();
virtual bool OnMessage(CGUIMessage& message);
@@ -81,7 +80,6 @@ class CGUITextBox : public CGUIControl, public CGUITextLayout
int m_scrollTime;
unsigned int m_itemsPerPage;
float m_itemHeight;
- unsigned int m_renderTime;
unsigned int m_lastRenderTime;
CLabelInfo m_label;

0 comments on commit c6827ba

Please sign in to comment.