aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpieh <misiek.piechowiak@gmail.com>2011-06-27 01:09:51 -0700
committerpieh <misiek.piechowiak@gmail.com>2011-06-27 01:09:51 -0700
commit2d3686afa82c1d4e0a57d3fde288c3e35825ca43 (patch)
tree68d9d89aad721d735ee9939813f1a4d4e0d7f4f0
parent10878ccdc6963629f2e087b84b63657d5376ce53 (diff)
parent9cc26cdf6ee4d8794fc90f87898250bb5b00f03d (diff)
Merge pull request #224 from pieh/textlayout_update
Refactoring text change test in CGUIEditControl
-rw-r--r--xbmc/guilib/GUIEditControl.cpp7
-rw-r--r--xbmc/guilib/GUIEditControl.h1
-rw-r--r--xbmc/guilib/GUILabel.cpp14
-rw-r--r--xbmc/guilib/GUITextLayout.cpp17
-rw-r--r--xbmc/guilib/GUITextLayout.h4
5 files changed, 20 insertions, 23 deletions
diff --git a/xbmc/guilib/GUIEditControl.cpp b/xbmc/guilib/GUIEditControl.cpp
index 4049d877ce..8c4b215fda 100644
--- a/xbmc/guilib/GUIEditControl.cpp
+++ b/xbmc/guilib/GUIEditControl.cpp
@@ -419,12 +419,7 @@ void CGUIEditControl::ProcessText(unsigned int currentTime)
}
changed |= m_label2.SetMaxRect(posX + m_textOffset, m_posY, maxTextWidth - m_textOffset, m_height);
- if (text != m_lastRenderedText)
- {
- m_label2.SetTextW(text);
- m_lastRenderedText = text;
- changed = true;
- }
+ changed |= m_label2.SetTextW(text);
changed |= m_label2.SetAlign(align);
changed |= m_label2.SetColor(GetTextColor());
changed |= m_label2.Process(currentTime);
diff --git a/xbmc/guilib/GUIEditControl.h b/xbmc/guilib/GUIEditControl.h
index 606dad03b6..89eb7cc30c 100644
--- a/xbmc/guilib/GUIEditControl.h
+++ b/xbmc/guilib/GUIEditControl.h
@@ -115,6 +115,5 @@ protected:
static const char* smsLetters[10];
static const unsigned int smsDelay;
- CStdStringW m_lastRenderedText; ///< last rendered text
};
#endif
diff --git a/xbmc/guilib/GUILabel.cpp b/xbmc/guilib/GUILabel.cpp
index 3195aab6c3..6d9230a19f 100644
--- a/xbmc/guilib/GUILabel.cpp
+++ b/xbmc/guilib/GUILabel.cpp
@@ -159,11 +159,15 @@ bool CGUILabel::SetText(const CStdString &label)
bool CGUILabel::SetTextW(const CStdStringW &label)
{
- m_textLayout.SetText(label);
- m_scrollInfo.Reset();
- UpdateRenderRect();
- m_invalid = false;
- return true;
+ if (m_textLayout.UpdateW(label, m_maxRect.Width(), m_invalid))
+ {
+ m_scrollInfo.Reset();
+ UpdateRenderRect();
+ m_invalid = false;
+ return true;
+ }
+ else
+ return false;
}
void CGUILabel::UpdateRenderRect()
diff --git a/xbmc/guilib/GUITextLayout.cpp b/xbmc/guilib/GUITextLayout.cpp
index e9f0c437c2..6a86b5cc05 100644
--- a/xbmc/guilib/GUITextLayout.cpp
+++ b/xbmc/guilib/GUITextLayout.cpp
@@ -195,23 +195,19 @@ void CGUITextLayout::RenderOutline(float x, float y, color_t color, color_t outl
bool CGUITextLayout::Update(const CStdString &text, float maxWidth, bool forceUpdate /*= false*/, bool forceLTRReadingOrder /*= false*/)
{
- if (text == m_lastText && !forceUpdate)
- return false;
-
// convert to utf16
CStdStringW utf16;
utf8ToW(text, utf16);
// update
- SetText(utf16, maxWidth, forceLTRReadingOrder);
-
- // and set our parameters to indicate no further update is required
- m_lastText = text;
- return true;
+ return UpdateW(utf16, maxWidth, forceUpdate, forceLTRReadingOrder);
}
-void CGUITextLayout::SetText(const CStdStringW &text, float maxWidth, bool forceLTRReadingOrder /*= false*/)
+bool CGUITextLayout::UpdateW(const CStdStringW &text, float maxWidth /*= 0*/, bool forceUpdate /*= false*/, bool forceLTRReadingOrder /*= false*/)
{
+ if (text.Equals(m_lastText) && !forceUpdate)
+ return false;
+
vecText parsedText;
// empty out our previous string
@@ -239,6 +235,9 @@ void CGUITextLayout::SetText(const CStdStringW &text, float maxWidth, bool force
// and cache the width and height for later reading
CalcTextExtent();
+
+ m_lastText = text;
+ return true;
}
// BidiTransform is used to handle RTL text flipping in the string
diff --git a/xbmc/guilib/GUITextLayout.h b/xbmc/guilib/GUITextLayout.h
index ae6b9ff1ad..364928a5b2 100644
--- a/xbmc/guilib/GUITextLayout.h
+++ b/xbmc/guilib/GUITextLayout.h
@@ -87,7 +87,7 @@ public:
float GetTextWidth(const CStdStringW &text) const;
bool Update(const CStdString &text, float maxWidth = 0, bool forceUpdate = false, bool forceLTRReadingOrder = false);
- void SetText(const CStdStringW &text, float maxWidth = 0, bool forceLTRReadingOrder = false);
+ bool UpdateW(const CStdStringW &text, float maxWidth = 0, bool forceUpdate = false, bool forceLTRReadingOrder = false);
unsigned int GetTextLength() const;
void GetFirstText(vecText &text) const;
@@ -122,7 +122,7 @@ protected:
// the default color (may differ from the font objects defaults)
color_t m_textColor;
- CStdString m_lastText;
+ CStdStringW m_lastText;
float m_textWidth;
float m_textHeight;
private: