aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Marshall <jmarshall@never.you.mind>2012-07-01 22:32:09 +1200
committerJonathan Marshall <jmarshall@never.you.mind>2012-07-01 22:32:09 +1200
commit3b7d4b279a8e425c35111f615019b796c656233d (patch)
tree2b1c1721f704856fdcf6e73ec047112baba3baab
parent0b51902e6bfec570c7357699314cd58bb2374516 (diff)
[guilib] fix edit labels not being clipped
-rw-r--r--xbmc/guilib/GUIButtonControl.cpp8
-rw-r--r--xbmc/guilib/GUIButtonControl.h1
-rw-r--r--xbmc/guilib/GUIEditControl.cpp29
-rw-r--r--xbmc/guilib/GUIEditControl.h2
4 files changed, 30 insertions, 10 deletions
diff --git a/xbmc/guilib/GUIButtonControl.cpp b/xbmc/guilib/GUIButtonControl.cpp
index 5b7a33a2f6..04bd373c7f 100644
--- a/xbmc/guilib/GUIButtonControl.cpp
+++ b/xbmc/guilib/GUIButtonControl.cpp
@@ -94,10 +94,14 @@ void CGUIButtonControl::Render()
m_imgFocus.Render();
m_imgNoFocus.Render();
+ RenderText();
+ CGUIControl::Render();
+}
+
+void CGUIButtonControl::RenderText()
+{
m_label.Render();
m_label2.Render();
-
- CGUIControl::Render();
}
CGUILabel::COLOR CGUIButtonControl::GetTextColor() const
diff --git a/xbmc/guilib/GUIButtonControl.h b/xbmc/guilib/GUIButtonControl.h
index b5e2323c71..186b4d2f82 100644
--- a/xbmc/guilib/GUIButtonControl.h
+++ b/xbmc/guilib/GUIButtonControl.h
@@ -88,6 +88,7 @@ protected:
void OnFocus();
void OnUnFocus();
virtual void ProcessText(unsigned int currentTime);
+ virtual void RenderText();
CGUILabel::COLOR GetTextColor() const;
CGUITexture m_imgFocus;
diff --git a/xbmc/guilib/GUIEditControl.cpp b/xbmc/guilib/GUIEditControl.cpp
index 83ae483190..4dab233d1f 100644
--- a/xbmc/guilib/GUIEditControl.cpp
+++ b/xbmc/guilib/GUIEditControl.cpp
@@ -372,8 +372,10 @@ void CGUIEditControl::ProcessText(unsigned int currentTime)
bool changed = false;
- float posX = m_label.GetRenderRect().x1;
- float maxTextWidth = m_label.GetMaxWidth();
+ m_clipRect.x1 = m_label.GetRenderRect().x1;
+ m_clipRect.x2 = m_clipRect.x1 + m_label.GetMaxWidth();
+ m_clipRect.y1 = m_posY;
+ m_clipRect.y2 = m_posY + m_height;
// start by rendering the normal text
float leftTextWidth = m_label.GetRenderRect().Width();
@@ -382,15 +384,14 @@ void CGUIEditControl::ProcessText(unsigned int currentTime)
// render the text on the left
changed |= m_label.SetColor(GetTextColor());
changed |= m_label.Process(currentTime);
-
- posX += leftTextWidth + spaceWidth;
- maxTextWidth -= leftTextWidth + spaceWidth;
+
+ m_clipRect.x1 += leftTextWidth + spaceWidth;
}
- if (g_graphicsContext.SetClipRegion(posX, m_posY, maxTextWidth, m_height))
+ if (g_graphicsContext.SetClipRegion(m_clipRect.x1, m_clipRect.y1, m_clipRect.Width(), m_clipRect.Height()))
{
uint32_t align = m_label.GetLabelInfo().align & XBFONT_CENTER_Y; // start aligned left
- if (m_label2.GetTextWidth() < maxTextWidth)
+ if (m_label2.GetTextWidth() < m_clipRect.Width())
{ // align text as our text fits
if (leftTextWidth > 0)
{ // right align as we have 2 labels
@@ -413,13 +414,14 @@ void CGUIEditControl::ProcessText(unsigned int currentTime)
text.Insert(m_cursorPos, col);
}
- changed |= m_label2.SetMaxRect(posX + m_textOffset, m_posY, maxTextWidth - m_textOffset, m_height);
+ changed |= m_label2.SetMaxRect(m_clipRect.x1 + m_textOffset, m_posY, m_clipRect.Width() - m_textOffset, m_height);
if (text.IsEmpty())
changed |= m_label2.SetText(m_hintInfo.GetLabel(GetParentID()));
else
changed |= m_label2.SetTextW(text);
changed |= m_label2.SetAlign(align);
changed |= m_label2.SetColor(GetTextColor());
+ changed |= m_label2.SetOverflow(CGUILabel::OVER_FLOW_CLIP);
changed |= m_label2.Process(currentTime);
g_graphicsContext.RestoreClipRegion();
}
@@ -427,6 +429,17 @@ void CGUIEditControl::ProcessText(unsigned int currentTime)
MarkDirtyRegion();
}
+void CGUIEditControl::RenderText()
+{
+ m_label.Render();
+
+ if (g_graphicsContext.SetClipRegion(m_clipRect.x1, m_clipRect.y1, m_clipRect.Width(), m_clipRect.Height()))
+ {
+ m_label2.Render();
+ g_graphicsContext.RestoreClipRegion();
+ }
+}
+
void CGUIEditControl::SetHint(const CGUIInfoLabel& hint)
{
m_hintInfo = hint;
diff --git a/xbmc/guilib/GUIEditControl.h b/xbmc/guilib/GUIEditControl.h
index 90d3395137..ab5448d877 100644
--- a/xbmc/guilib/GUIEditControl.h
+++ b/xbmc/guilib/GUIEditControl.h
@@ -80,6 +80,7 @@ public:
protected:
virtual void ProcessText(unsigned int currentTime);
+ virtual void RenderText();
CStdStringW GetDisplayedText() const;
void RecalcLabelPosition();
void ValidateCursor();
@@ -98,6 +99,7 @@ protected:
CGUIInfoLabel m_hintInfo;
float m_textOffset;
float m_textWidth;
+ CRect m_clipRect; ///< clipping rect for the second label
static const int spaceWidth = 5;