aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xbmc/dialogs/GUIDialogBoxBase.cpp7
-rw-r--r--xbmc/guilib/GUIControlFactory.cpp1
-rw-r--r--xbmc/guilib/GUITextBox.cpp28
-rw-r--r--xbmc/guilib/GUITextBox.h6
4 files changed, 34 insertions, 8 deletions
diff --git a/xbmc/dialogs/GUIDialogBoxBase.cpp b/xbmc/dialogs/GUIDialogBoxBase.cpp
index efb5316df5..4e6f36fb9c 100644
--- a/xbmc/dialogs/GUIDialogBoxBase.cpp
+++ b/xbmc/dialogs/GUIDialogBoxBase.cpp
@@ -83,17 +83,14 @@ void CGUIDialogBoxBase::SetLine(unsigned int iLine, const CVariant& line)
lines.resize(iLine+1);
lines[iLine] = label;
std::string text = StringUtils::Join(lines, "\n");
- if (text != m_text)
- {
- m_text = text;
- SetInvalid();
- }
+ SetText(text);
}
void CGUIDialogBoxBase::SetText(const CVariant& text)
{
std::string label = GetLocalized(text);
CSingleLock lock(m_section);
+ StringUtils::Trim(label, "\n");
if (label != m_text)
{
m_text = label;
diff --git a/xbmc/guilib/GUIControlFactory.cpp b/xbmc/guilib/GUIControlFactory.cpp
index 39c51b9511..dd81c838e0 100644
--- a/xbmc/guilib/GUIControlFactory.cpp
+++ b/xbmc/guilib/GUIControlFactory.cpp
@@ -1386,6 +1386,7 @@ CGUIControl* CGUIControlFactory::Create(int parentID, const CRect &rect, TiXmlEl
if (infoLabels.size())
((CGUITextBox *)control)->SetInfo(infoLabels[0]);
((CGUITextBox *)control)->SetAutoScrolling(pControlNode);
+ ((CGUITextBox *)control)->SetMinHeight(minHeight);
}
else if (type == CGUIControl::GUICONTROL_SELECTBUTTON)
{
diff --git a/xbmc/guilib/GUITextBox.cpp b/xbmc/guilib/GUITextBox.cpp
index 4483474f96..de3b2755e1 100644
--- a/xbmc/guilib/GUITextBox.cpp
+++ b/xbmc/guilib/GUITextBox.cpp
@@ -45,6 +45,8 @@ CGUITextBox::CGUITextBox(int parentID, int controlID, float posX, float posY, fl
m_autoScrollDelay = 3000;
m_autoScrollDelayTime = 0;
m_autoScrollRepeatAnim = NULL;
+ m_minHeight = 0;
+ m_renderHeight = height;
}
CGUITextBox::CGUITextBox(const CGUITextBox &from)
@@ -55,6 +57,8 @@ CGUITextBox::CGUITextBox(const CGUITextBox &from)
m_autoScrollCondition = from.m_autoScrollCondition;
m_autoScrollTime = from.m_autoScrollTime;
m_autoScrollDelay = from.m_autoScrollDelay;
+ m_minHeight = from.m_minHeight;
+ m_renderHeight = from.m_renderHeight;
m_autoScrollRepeatAnim = NULL;
if (from.m_autoScrollRepeatAnim)
m_autoScrollRepeatAnim = new CAnimation(*from.m_autoScrollRepeatAnim);
@@ -85,6 +89,8 @@ bool CGUITextBox::UpdateColors()
return changed;
}
+#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
+
void CGUITextBox::UpdateInfo(const CGUIListItem *item)
{
m_textColor = m_label.textColor;
@@ -98,7 +104,10 @@ void CGUITextBox::UpdateInfo(const CGUIListItem *item)
ResetAutoScrolling();
m_itemHeight = m_font ? m_font->GetLineHeight() : 10;
- m_itemsPerPage = (unsigned int)(m_height / m_itemHeight);
+ float textHeight = m_itemHeight * m_lines.size();
+ float maxHeight = m_height ? m_height : textHeight;
+ m_renderHeight = m_minHeight ? CLAMP(textHeight, m_minHeight, maxHeight) : m_height;
+ m_itemsPerPage = (unsigned int)(m_renderHeight / m_itemHeight);
UpdatePageControl();
}
@@ -195,7 +204,7 @@ void CGUITextBox::Render()
if (m_autoScrollRepeatAnim)
g_graphicsContext.SetTransform(m_cachedTextMatrix);
- if (g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_height))
+ if (g_graphicsContext.SetClipRegion(m_posX, m_posY, m_width, m_renderHeight))
{
// we offset our draw position to take into account scrolling and whether or not our focused
// item is offscreen "above" the list.
@@ -213,7 +222,7 @@ void CGUITextBox::Render()
{
m_font->Begin();
int current = offset;
- while (posY < m_posY + m_height && current < (int)m_lines.size())
+ while (posY < m_posY + m_renderHeight && current < (int)m_lines.size())
{
uint32_t align = m_label.align;
if (m_lines[current].m_text.size() && m_lines[current].m_carriageReturn)
@@ -271,6 +280,19 @@ bool CGUITextBox::OnMessage(CGUIMessage& message)
return CGUIControl::OnMessage(message);
}
+float CGUITextBox::GetHeight() const
+{
+ return m_renderHeight;
+}
+
+void CGUITextBox::SetMinHeight(float minHeight)
+{
+ if (m_minHeight != minHeight)
+ SetInvalid();
+
+ m_minHeight = minHeight;
+}
+
void CGUITextBox::UpdatePageControl()
{
if (m_pageControl)
diff --git a/xbmc/guilib/GUITextBox.h b/xbmc/guilib/GUITextBox.h
index 40edfb4822..7e683ece08 100644
--- a/xbmc/guilib/GUITextBox.h
+++ b/xbmc/guilib/GUITextBox.h
@@ -52,6 +52,8 @@ public:
virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
virtual void Render();
virtual bool OnMessage(CGUIMessage& message);
+ virtual float GetHeight() const;
+ void SetMinHeight(float minHeight);
void SetPageControl(int pageControl);
@@ -72,6 +74,10 @@ protected:
unsigned int GetRows() const;
int GetCurrentPage() const;
+ // auto-height
+ float m_minHeight;
+ float m_renderHeight;
+
// offset of text in the control for scrolling
unsigned int m_offset;
float m_scrollOffset;