aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--XBMC.xcodeproj/project.pbxproj8
-rw-r--r--guilib/GUIButtonControl.cpp80
-rw-r--r--guilib/GUIButtonControl.h11
-rw-r--r--guilib/GUIButtonScroller.h1
-rw-r--r--guilib/GUICheckMarkControl.cpp42
-rw-r--r--guilib/GUICheckMarkControl.h9
-rw-r--r--guilib/GUIControl.h36
-rw-r--r--guilib/GUIControlGroupList.cpp1
-rw-r--r--guilib/GUIDialog.cpp1
-rw-r--r--guilib/GUIEditControl.cpp90
-rw-r--r--guilib/GUIEditControl.h1
-rw-r--r--guilib/GUIFadeLabelControl.h2
-rw-r--r--guilib/GUIFontTTF.cpp2
-rw-r--r--guilib/GUILabel.cpp155
-rw-r--r--guilib/GUILabel.h194
-rw-r--r--guilib/GUILabelControl.cpp84
-rw-r--r--guilib/GUILabelControl.h12
-rw-r--r--guilib/GUIListItemLayout.h1
-rw-r--r--guilib/GUIListLabel.cpp69
-rw-r--r--guilib/GUIListLabel.h22
-rw-r--r--guilib/GUIRSSControl.h1
-rw-r--r--guilib/GUISelectButtonControl.cpp17
-rw-r--r--guilib/GUISettingsSliderControl.cpp15
-rw-r--r--guilib/GUISettingsSliderControl.h5
-rw-r--r--guilib/GUISpinControl.cpp58
-rw-r--r--guilib/GUISpinControl.h8
-rw-r--r--guilib/GUISpinControlEx.cpp11
-rw-r--r--guilib/GUITextBox.h1
-rw-r--r--guilib/GUITextLayout.h12
-rw-r--r--project/VS2008Express/guilib.vcproj8
-rw-r--r--xbmc/GUISettings.cpp1
-rw-r--r--xbmc/cores/DummyVideoPlayer.cpp1
-rw-r--r--xbmc/karaoke/karaokelyricstext.cpp1
-rw-r--r--xbmc/lib/libPython/xbmcmodule/controllist.cpp1
34 files changed, 593 insertions, 368 deletions
diff --git a/XBMC.xcodeproj/project.pbxproj b/XBMC.xcodeproj/project.pbxproj
index 300d73f289..5327f924ba 100644
--- a/XBMC.xcodeproj/project.pbxproj
+++ b/XBMC.xcodeproj/project.pbxproj
@@ -175,6 +175,8 @@
7C62F24310505BC7002AD2C1 /* Bookmark.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C62F24010505BC7002AD2C1 /* Bookmark.cpp */; };
7C62F45E1057A62D002AD2C1 /* DirectoryNodeSingles.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C62F45C1057A62D002AD2C1 /* DirectoryNodeSingles.cpp */; };
7C62F45F1057A62D002AD2C1 /* DirectoryNodeSingles.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C62F45C1057A62D002AD2C1 /* DirectoryNodeSingles.cpp */; };
+ 7C644FC7112367A60012D34D /* GUILabel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C644FC5112367A60012D34D /* GUILabel.cpp */; };
+ 7C644FC8112367A60012D34D /* GUILabel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C644FC5112367A60012D34D /* GUILabel.cpp */; };
7C779DA6104A4B2E00F444C4 /* GUIControlFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C779D95104A4B2E00F444C4 /* GUIControlFactory.cpp */; };
7C779DA8104A4B2E00F444C4 /* GUIFontTTFGL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C779D99104A4B2E00F444C4 /* GUIFontTTFGL.cpp */; };
7C779DA9104A4B2E00F444C4 /* GUIImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C779D9B104A4B2E00F444C4 /* GUIImage.cpp */; };
@@ -2011,6 +2013,8 @@
7C62F24110505BC7002AD2C1 /* Bookmark.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bookmark.h; sourceTree = "<group>"; };
7C62F45C1057A62D002AD2C1 /* DirectoryNodeSingles.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DirectoryNodeSingles.cpp; sourceTree = "<group>"; };
7C62F45D1057A62D002AD2C1 /* DirectoryNodeSingles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DirectoryNodeSingles.h; sourceTree = "<group>"; };
+ 7C644FC5112367A60012D34D /* GUILabel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUILabel.cpp; sourceTree = "<group>"; };
+ 7C644FC6112367A60012D34D /* GUILabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUILabel.h; sourceTree = "<group>"; };
7C779D94104A4B2E00F444C4 /* GUIActionDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIActionDescriptor.h; sourceTree = "<group>"; };
7C779D95104A4B2E00F444C4 /* GUIControlFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GUIControlFactory.cpp; sourceTree = "<group>"; };
7C779D96104A4B2E00F444C4 /* GUIControlFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GUIControlFactory.h; sourceTree = "<group>"; };
@@ -4216,6 +4220,8 @@
7CCF7DF11066212700992676 /* Strings */ = {
isa = PBXGroup;
children = (
+ 7C644FC5112367A60012D34D /* GUILabel.cpp */,
+ 7C644FC6112367A60012D34D /* GUILabel.h */,
E38E143F0D25F9F900618676 /* LocalizeStrings.cpp */,
E38E14400D25F9F900618676 /* LocalizeStrings.h */,
E38E144A0D25F9F900618676 /* StdString.h */,
@@ -8062,6 +8068,7 @@
18CCEAEE1112F5B800615FC6 /* PCMRemap.cpp in Sources */,
F5F24D4A1120994F009126C6 /* PCMLimiter.cpp in Sources */,
F5F24E8611232488009126C6 /* DVDAudioEncoderFFmpeg.cpp in Sources */,
+ 7C644FC7112367A60012D34D /* GUILabel.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -8916,6 +8923,7 @@
18CCEAEF1112F5B800615FC6 /* PCMRemap.cpp in Sources */,
F5F24D4B1120994F009126C6 /* PCMLimiter.cpp in Sources */,
F5F24E8711232488009126C6 /* DVDAudioEncoderFFmpeg.cpp in Sources */,
+ 7C644FC8112367A60012D34D /* GUILabel.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/guilib/GUIButtonControl.cpp b/guilib/GUIButtonControl.cpp
index 2ab710472b..7eb1b2c2a1 100644
--- a/guilib/GUIButtonControl.cpp
+++ b/guilib/GUIButtonControl.cpp
@@ -31,12 +31,13 @@ CGUIButtonControl::CGUIButtonControl(int parentID, int controlID, float posX, fl
: CGUIControl(parentID, controlID, posX, posY, width, height)
, m_imgFocus(posX, posY, width, height, textureFocus)
, m_imgNoFocus(posX, posY, width, height, textureNoFocus)
- , m_textLayout(labelInfo.font, false), m_textLayout2(labelInfo.font, false)
+ , m_label(posX, posY, width, height, labelInfo)
+ , m_label2(posX, posY, width, height, labelInfo)
{
m_bSelected = false;
m_alpha = 255;
m_focusCounter = 0;
- m_label = labelInfo;
+ m_label2.SetAlign(XBFONT_RIGHT | (labelInfo.align & XBFONT_CENTER_Y) | XBFONT_TRUNCATED);
ControlType = GUICONTROL_BUTTON;
}
@@ -87,49 +88,36 @@ void CGUIButtonControl::Render()
CGUIControl::Render();
}
-void CGUIButtonControl::RenderText()
+CGUILabel::COLOR CGUIButtonControl::GetTextColor() const
{
- m_textLayout.Update(m_info.GetLabel(m_parentID));
-
- float fPosX = m_posX + m_label.offsetX;
- float fPosY = m_posY + m_label.offsetY;
-
- if (m_label.align & XBFONT_RIGHT)
- fPosX = m_posX + m_width - m_label.offsetX;
-
- if (m_label.align & XBFONT_CENTER_X)
- fPosX = m_posX + m_width / 2;
-
- if (m_label.align & XBFONT_CENTER_Y)
- fPosY = m_posY + m_height / 2;
-
if (IsDisabled())
- m_textLayout.Render( fPosX, fPosY, m_label.angle, m_label.disabledColor, m_label.shadowColor, m_label.align, m_label.width, true);
- else if (HasFocus() && m_label.focusedColor)
- m_textLayout.Render( fPosX, fPosY, m_label.angle, m_label.focusedColor, m_label.shadowColor, m_label.align, m_label.width);
- else
- m_textLayout.Render( fPosX, fPosY, m_label.angle, m_label.textColor, m_label.shadowColor, m_label.align, m_label.width);
+ return CGUILabel::COLOR_DISABLED;
+ if (HasFocus())
+ return CGUILabel::COLOR_FOCUSED;
+ return CGUILabel::COLOR_TEXT;
+}
+
+void CGUIButtonControl::RenderText()
+{
+ m_label.SetMaxRect(m_posX, m_posY, m_width, m_height);
+ m_label.SetText(m_info.GetLabel(m_parentID));
// render the second label if it exists
CStdString label2(m_info2.GetLabel(m_parentID));
if (!label2.IsEmpty())
{
- float textWidth, textHeight;
- m_textLayout.GetTextExtent(textWidth, textHeight);
- m_textLayout2.Update(label2);
-
- float width = m_width - 2 * m_label.offsetX - textWidth - 5;
- if (width < 0) width = 0;
- fPosX = m_posX + m_width - m_label.offsetX;
- uint32_t dwAlign = XBFONT_RIGHT | (m_label.align & XBFONT_CENTER_Y) | XBFONT_TRUNCATED;
-
- if (IsDisabled() )
- m_textLayout2.Render( fPosX, fPosY, m_label.angle, m_label.disabledColor, m_label.shadowColor, dwAlign, width, true);
- else if (HasFocus() && m_label.focusedColor)
- m_textLayout2.Render( fPosX, fPosY, m_label.angle, m_label.focusedColor, m_label.shadowColor, dwAlign, width);
- else
- m_textLayout2.Render( fPosX, fPosY, m_label.angle, m_label.textColor, m_label.shadowColor, dwAlign, width);
+ m_label2.SetMaxRect(m_posX, m_posY, m_width, m_height);
+ m_label2.SetText(label2);
+
+ // TODO: call a function to compute the "best" render rect from these two
+ CRect leftLabel(m_label.GetRenderRect());
+ CRect rightLabel(m_label2.GetRenderRect());
+
+ m_label2.SetColor(GetTextColor());
+ m_label2.Render();
}
+ m_label.SetColor(GetTextColor());
+ m_label.Render();
}
bool CGUIButtonControl::OnAction(const CAction &action)
@@ -217,7 +205,6 @@ void CGUIButtonControl::SetLabel2(const string &label2)
void CGUIButtonControl::SetPosition(float posX, float posY)
{
CGUIControl::SetPosition(posX, posY);
-
m_imgFocus.SetPosition(posX, posY);
m_imgNoFocus.SetPosition(posX, posY);
}
@@ -263,26 +250,21 @@ CStdString CGUIButtonControl::GetLabel2() const
void CGUIButtonControl::PythonSetLabel(const CStdString &strFont, const string &strText, color_t textColor, color_t shadowColor, color_t focusedColor)
{
- m_label.font = g_fontManager.GetFont(strFont);
- m_label.textColor = textColor;
- m_label.focusedColor = focusedColor;
- m_label.shadowColor = shadowColor;
+ m_label.GetLabelInfo().font = g_fontManager.GetFont(strFont);
+ m_label.GetLabelInfo().textColor = textColor;
+ m_label.GetLabelInfo().focusedColor = focusedColor;
+ m_label.GetLabelInfo().shadowColor = shadowColor;
SetLabel(strText);
}
void CGUIButtonControl::PythonSetDisabledColor(color_t disabledColor)
{
- m_label.disabledColor = disabledColor;
-}
-
-void CGUIButtonControl::RAMSetTextColor(color_t textColor)
-{
- m_label.textColor = textColor;
+ m_label.GetLabelInfo().disabledColor = disabledColor;
}
void CGUIButtonControl::SettingsCategorySetTextAlign(uint32_t align)
{
- m_label.align = align;
+ m_label.SetAlign(align);
}
void CGUIButtonControl::OnClick()
diff --git a/guilib/GUIButtonControl.h b/guilib/GUIButtonControl.h
index 3e0ca5a72a..a05982ad03 100644
--- a/guilib/GUIButtonControl.h
+++ b/guilib/GUIButtonControl.h
@@ -30,7 +30,7 @@
*/
#include "GUITexture.h"
-#include "GUITextLayout.h"
+#include "GUILabel.h"
#include "GUIControl.h"
/*!
@@ -62,7 +62,7 @@ public:
const std::vector<CGUIActionDescriptor> &GetClickActions() const { return m_clickActions; };
void SetFocusActions(const std::vector<CGUIActionDescriptor>& focusActions) { m_focusActions = focusActions; };
void SetUnFocusActions(const std::vector<CGUIActionDescriptor>& unfocusActions) { m_unfocusActions = unfocusActions; };
- const CLabelInfo& GetLabelInfo() const { return m_label; };
+ const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo(); };
virtual CStdString GetLabel() const { return GetDescription(); };
virtual CStdString GetLabel2() const;
void SetSelected(bool bSelected);
@@ -72,7 +72,6 @@ public:
void PythonSetLabel(const CStdString &strFont, const std::string &strText, color_t textColor, color_t shadowColor, color_t focusedColor);
void PythonSetDisabledColor(color_t disabledColor);
- void RAMSetTextColor(color_t textColor);
void SettingsCategorySetTextAlign(uint32_t align);
virtual void OnClick();
@@ -84,6 +83,7 @@ protected:
void OnFocus();
void OnUnFocus();
virtual void RenderText();
+ CGUILabel::COLOR GetTextColor() const;
CGUITexture m_imgFocus;
CGUITexture m_imgNoFocus;
@@ -92,9 +92,8 @@ protected:
CGUIInfoLabel m_info;
CGUIInfoLabel m_info2;
- CLabelInfo m_label;
- CGUITextLayout m_textLayout;
- CGUITextLayout m_textLayout2;
+ CGUILabel m_label;
+ CGUILabel m_label2;
std::vector<CGUIActionDescriptor> m_clickActions;
std::vector<CGUIActionDescriptor> m_focusActions;
diff --git a/guilib/GUIButtonScroller.h b/guilib/GUIButtonScroller.h
index 4cb1d9cbfa..39c4c279b7 100644
--- a/guilib/GUIButtonScroller.h
+++ b/guilib/GUIButtonScroller.h
@@ -24,6 +24,7 @@
#include "GUIControl.h"
#include "GUITexture.h"
#include "GUIActionDescriptor.h"
+#include "GUILabel.h"
class TiXmlNode;
diff --git a/guilib/GUICheckMarkControl.cpp b/guilib/GUICheckMarkControl.cpp
index b76aaef366..3c3b0acace 100644
--- a/guilib/GUICheckMarkControl.cpp
+++ b/guilib/GUICheckMarkControl.cpp
@@ -30,11 +30,11 @@ CGUICheckMarkControl::CGUICheckMarkControl(int parentID, int controlID, float po
: CGUIControl(parentID, controlID, posX, posY, width, height)
, m_imgCheckMark(posX, posY, checkWidth, checkHeight, textureCheckMark)
, m_imgCheckMarkNoFocus(posX, posY, checkWidth, checkHeight, textureCheckMarkNF)
- , m_textLayout(labelInfo.font, false)
+ , m_label(posX, posY, width, height, labelInfo)
{
m_strLabel = "";
- m_label = labelInfo;
m_bSelected = false;
+ m_label.GetLabelInfo().align |= XBFONT_CENTER_Y;
ControlType = GUICONTROL_CHECKMARK;
}
@@ -43,28 +43,23 @@ CGUICheckMarkControl::~CGUICheckMarkControl(void)
void CGUICheckMarkControl::Render()
{
- m_textLayout.Update(m_strLabel);
+ m_label.SetText(m_strLabel);
- float fTextHeight, fTextWidth;
- m_textLayout.GetTextExtent(fTextWidth, fTextHeight);
- m_width = fTextWidth + 5 + m_imgCheckMark.GetWidth();
+ float textWidth = m_label.GetTextWidth();
+ m_width = textWidth + 5 + m_imgCheckMark.GetWidth();
m_height = m_imgCheckMark.GetHeight();
float textPosX = m_posX;
- float textPosY = m_posY + m_height * 0.5f;
float checkMarkPosX = m_posX;
- if (m_label.align & (XBFONT_RIGHT | XBFONT_CENTER_X))
+ if (m_label.GetLabelInfo().align & (XBFONT_RIGHT | XBFONT_CENTER_X))
textPosX += m_imgCheckMark.GetWidth() + 5;
else
- checkMarkPosX += fTextWidth + 5;
+ checkMarkPosX += textWidth + 5;
- if (IsDisabled() )
- m_textLayout.Render(textPosX, textPosY, 0, m_label.disabledColor, m_label.shadowColor, XBFONT_CENTER_Y, 0, true);
- else if (HasFocus() && m_label.focusedColor)
- m_textLayout.Render(textPosX, textPosY, 0, m_label.focusedColor, m_label.shadowColor, XBFONT_CENTER_Y, 0);
- else
- m_textLayout.Render(textPosX, textPosY, 0, m_label.textColor, m_label.shadowColor, XBFONT_CENTER_Y, 0);
+ m_label.SetMaxRect(textPosX, m_posY, textWidth, m_height);
+ m_label.SetColor(GetTextColor());
+ m_label.Render();
if (m_bSelected)
{
@@ -79,6 +74,15 @@ void CGUICheckMarkControl::Render()
CGUIControl::Render();
}
+CGUILabel::COLOR CGUICheckMarkControl::GetTextColor() const
+{
+ if (IsDisabled())
+ return CGUILabel::COLOR_DISABLED;
+ else if (HasFocus())
+ return CGUILabel::COLOR_FOCUSED;
+ return CGUILabel::COLOR_TEXT;
+}
+
bool CGUICheckMarkControl::OnAction(const CAction &action)
{
if (action.actionId == ACTION_SELECT_ITEM)
@@ -162,15 +166,15 @@ void CGUICheckMarkControl::SetLabel(const string &label)
void CGUICheckMarkControl::PythonSetLabel(const CStdString &strFont, const string &strText, color_t textColor)
{
- m_label.font = g_fontManager.GetFont(strFont);
- m_label.textColor = textColor;
- m_label.focusedColor = textColor;
+ m_label.GetLabelInfo().font = g_fontManager.GetFont(strFont);
+ m_label.GetLabelInfo().textColor = textColor;
+ m_label.GetLabelInfo().focusedColor = textColor;
m_strLabel = strText;
}
void CGUICheckMarkControl::PythonSetDisabledColor(color_t disabledColor)
{
- m_label.disabledColor = disabledColor;
+ m_label.GetLabelInfo().disabledColor = disabledColor;
}
void CGUICheckMarkControl::UpdateColors()
diff --git a/guilib/GUICheckMarkControl.h b/guilib/GUICheckMarkControl.h
index 37c740d939..62a5ab975a 100644
--- a/guilib/GUICheckMarkControl.h
+++ b/guilib/GUICheckMarkControl.h
@@ -30,7 +30,7 @@
*/
#include "GUITexture.h"
-#include "GUITextLayout.h"
+#include "GUILabel.h"
#include "GUIControl.h"
/*!
@@ -54,7 +54,7 @@ public:
void SetLabel(const std::string& strLabel);
const std::string GetLabel() const { return m_strLabel; };
- const CLabelInfo& GetLabelInfo() const { return m_label; };
+ const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo(); };
void SetSelected(bool bOnOff);
bool GetSelected() const;
@@ -64,11 +64,12 @@ public:
protected:
virtual bool OnMouseEvent(const CPoint &point, const CMouseEvent &event);
virtual void UpdateColors();
+ CGUILabel::COLOR GetTextColor() const;
+
CGUITexture m_imgCheckMark;
CGUITexture m_imgCheckMarkNoFocus;
- CLabelInfo m_label;
- CGUITextLayout m_textLayout;
+ CGUILabel m_label;
std::string m_strLabel;
bool m_bSelected;
};
diff --git a/guilib/GUIControl.h b/guilib/GUIControl.h
index d6fe758bbd..f7408e6784 100644
--- a/guilib/GUIControl.h
+++ b/guilib/GUIControl.h
@@ -30,9 +30,8 @@
#include "GraphicContext.h" // needed by any rendering operation (all controls)
#include "GUIMessage.h" // needed by practically all controls
-#include "GUIFont.h" // needed for the CAngle member (CLabelInfo) among other stuff
#include "VisibleEffect.h" // needed for the CAnimation members
-#include "GUIInfoTypes.h" // needed for CGuiInfoColor to handle infolabel'ed colors
+#include "GUIInfoTypes.h" // needed for CGUIInfoColor to handle infolabel'ed colors
#include "GUIActionDescriptor.h"
class CGUIListItem; // forward
@@ -41,39 +40,6 @@ class CMouseEvent;
enum ORIENTATION { HORIZONTAL = 0, VERTICAL };
-class CLabelInfo
-{
-public:
- CLabelInfo()
- {
- font = NULL;
- align = XBFONT_LEFT;
- offsetX = offsetY = 0;
- width = 0;
- angle = 0;
- };
- void UpdateColors()
- {
- textColor.Update();
- shadowColor.Update();
- selectedColor.Update();
- disabledColor.Update();
- focusedColor.Update();
- };
-
- CGUIInfoColor textColor;
- CGUIInfoColor shadowColor;
- CGUIInfoColor selectedColor;
- CGUIInfoColor disabledColor;
- CGUIInfoColor focusedColor;
- uint32_t align;
- float offsetX;
- float offsetY;
- float width;
- float angle;
- CGUIFont *font;
-};
-
class CControlState
{
public:
diff --git a/guilib/GUIControlGroupList.cpp b/guilib/GUIControlGroupList.cpp
index fc6e222e9e..738ab86390 100644
--- a/guilib/GUIControlGroupList.cpp
+++ b/guilib/GUIControlGroupList.cpp
@@ -23,6 +23,7 @@
#include "Key.h"
#include "utils/GUIInfoManager.h"
#include "GUIControlProfiler.h"
+#include "GUIFont.h" // for XBFONT_* definitions
CGUIControlGroupList::CGUIControlGroupList(int parentID, int controlID, float posX, float posY, float width, float height, float itemGap, int pageControl, ORIENTATION orientation, bool useControlPositions, uint32_t alignment, unsigned int scrollTime)
: CGUIControlGroup(parentID, controlID, posX, posY, width, height)
diff --git a/guilib/GUIDialog.cpp b/guilib/GUIDialog.cpp
index eb70a21f27..076ae4a27e 100644
--- a/guilib/GUIDialog.cpp
+++ b/guilib/GUIDialog.cpp
@@ -59,7 +59,6 @@ void CGUIDialog::OnWindowLoaded()
{
float spacing = (pLabel->GetXPosition() - pBase->GetXPosition()) * 2;
pLabel->SetWidth(pBase->GetWidth() - spacing);
- pLabel->SetTruncate(true);
}
}
}
diff --git a/guilib/GUIEditControl.cpp b/guilib/GUIEditControl.cpp
index 9a3615bd47..6c8fb9c19b 100644
--- a/guilib/GUIEditControl.cpp
+++ b/guilib/GUIEditControl.cpp
@@ -45,28 +45,29 @@ CGUIEditControl::CGUIEditControl(int parentID, int controlID, float posX, float
const CLabelInfo& labelInfo, const std::string &text)
: CGUIButtonControl(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo)
{
+ DefaultConstructor();
+ SetLabel(text);
+}
+
+void CGUIEditControl::DefaultConstructor()
+{
ControlType = GUICONTROL_EDIT;
m_textOffset = 0;
- m_textWidth = width;
+ m_textWidth = GetWidth();
m_cursorPos = 0;
m_cursorBlink = 0;
m_inputHeading = 0;
m_inputType = INPUT_TYPE_TEXT;
m_smsLastKey = 0;
m_smsKeyIndex = 0;
- SetLabel(text);
+ m_label.SetAlign(m_label.GetLabelInfo().align & XBFONT_CENTER_Y); // left align
+ m_label2.GetLabelInfo().offsetX = 0;
}
CGUIEditControl::CGUIEditControl(const CGUIButtonControl &button)
: CGUIButtonControl(button)
{
- ControlType = GUICONTROL_EDIT;
- m_textOffset = 0;
- m_textWidth = GetWidth();
- m_cursorPos = 0;
- m_cursorBlink = 0;
- m_smsLastKey = 0;
- m_smsKeyIndex = 0;
+ DefaultConstructor();
}
CGUIEditControl::~CGUIEditControl(void)
@@ -311,23 +312,21 @@ void CGUIEditControl::SetInputType(CGUIEditControl::INPUT_TYPE type, int heading
void CGUIEditControl::RecalcLabelPosition()
{
- if (!m_label.font) return;
-
// ensure that our cursor is within our width
ValidateCursor();
CStdStringW text = GetDisplayedText();
- m_textWidth = m_textLayout2.GetTextWidth(text + L'|');
- float beforeCursorWidth = m_textLayout2.GetTextWidth(text.Left(m_cursorPos));
- float afterCursorWidth = m_textLayout2.GetTextWidth(text.Left(m_cursorPos) + L'|');
- float leftTextWidth = m_textLayout.GetTextWidth();
- float maxTextWidth = m_width - m_label.offsetX*2;
+ m_textWidth = m_label.CalcTextWidth(text + L'|');
+ float beforeCursorWidth = m_label.CalcTextWidth(text.Left(m_cursorPos));
+ float afterCursorWidth = m_label.CalcTextWidth(text.Left(m_cursorPos) + L'|');
+ float leftTextWidth = m_label.GetRenderRect().Width();
+ float maxTextWidth = m_label.GetMaxRect().Width();
if (leftTextWidth > 0)
maxTextWidth -= leftTextWidth + spaceWidth;
// if skinner forgot to set height :p
- if (m_height == 0)
- m_height = 2*m_label.font->GetTextHeight(1);
+ if (m_height == 0 && m_label.GetLabelInfo().font)
+ m_height = m_label.GetLabelInfo().font->GetTextHeight(1);
if (m_textWidth > maxTextWidth)
{ // we render taking up the full width, so make sure our cursor position is
@@ -358,58 +357,45 @@ void CGUIEditControl::RenderText()
if (m_bInvalidated)
{
- m_textLayout.Update(m_info.GetLabel(GetParentID()));
+ m_label.SetMaxRect(m_posX, m_posY, m_width, m_height);
+ m_label.SetText(m_info.GetLabel(GetParentID()));
RecalcLabelPosition();
}
- float leftTextWidth = m_textLayout.GetTextWidth();
- float maxTextWidth = m_width - m_label.offsetX * 2;
-
- // start by rendering the normal text
- float posX = m_posX + m_label.offsetX;
- float posY = m_posY;
- uint32_t align = m_label.align & XBFONT_CENTER_Y;
- if (m_label.align & XBFONT_CENTER_Y)
- posY += m_height*0.5f;
+ float posX = m_label.GetMaxRect().x1;
+ float maxTextWidth = m_label.GetMaxRect().Width();
+ // start by rendering the normal text
+ float leftTextWidth = m_label.GetRenderRect().Width();
if (leftTextWidth > 0)
{
// render the text on the left
- if (IsDisabled())
- m_textLayout.Render(posX, posY, m_label.angle, m_label.disabledColor, m_label.shadowColor, align, leftTextWidth, true);
- else if (HasFocus() && m_label.focusedColor)
- m_textLayout.Render(posX, posY, m_label.angle, m_label.focusedColor, m_label.shadowColor, align, leftTextWidth);
- else
- m_textLayout.Render(posX, posY, m_label.angle, m_label.textColor, m_label.shadowColor, align, leftTextWidth);
-
+ m_label.SetColor(GetTextColor());
+ m_label.Render();
+
posX += leftTextWidth + spaceWidth;
maxTextWidth -= leftTextWidth + spaceWidth;
}
if (g_graphicsContext.SetClipRegion(posX, m_posY, maxTextWidth, m_height))
{
- if (m_textWidth < maxTextWidth)
+ uint32_t align = m_label.GetLabelInfo().align & XBFONT_CENTER_Y; // start aligned left
+ if (m_label2.GetTextWidth() < maxTextWidth)
{ // align text as our text fits
if (leftTextWidth > 0)
{ // right align as we have 2 labels
- posX = m_posX + m_width - m_label.offsetX;
align |= XBFONT_RIGHT;
}
else
{ // align by whatever the skinner requests
- if (m_label.align & XBFONT_CENTER_X)
- posX += 0.5f*maxTextWidth;
- if (m_label.align & XBFONT_RIGHT)
- posX += maxTextWidth;
- align |= (m_label.align & 3);
+ align |= (m_label.GetLabelInfo().align & 3);
}
}
CStdStringW text = GetDisplayedText();
- // let's render it ourselves
+ // add the cursor if we're focused
if (HasFocus())
- { // cursor location assumes utf16 text, so deal with that (inefficient, but it's not as if it's a high-use area
- // virtual keyboard only)
+ {
CStdStringW col;
if ((m_focusCounter % 64) > 32)
col = L"|";
@@ -418,15 +404,11 @@ void CGUIEditControl::RenderText()
text.Insert(m_cursorPos, col);
}
- m_textLayout2.SetText(text);
-
- if (IsDisabled())
- m_textLayout2.Render(posX + m_textOffset, posY, m_label.angle, m_label.disabledColor, m_label.shadowColor, align, m_textWidth, true);
- else if (HasFocus() && m_label.focusedColor)
- m_textLayout2.Render(posX + m_textOffset, posY, m_label.angle, m_label.focusedColor, m_label.shadowColor, align, m_textWidth);
- else
- m_textLayout2.Render(posX + m_textOffset, posY, m_label.angle, m_label.textColor, m_label.shadowColor, align, m_textWidth);
-
+ m_label2.SetMaxRect(posX + m_textOffset, m_posY, maxTextWidth - m_textOffset, m_height);
+ m_label2.SetTextW(text);
+ m_label2.SetAlign(align);
+ m_label2.SetColor(GetTextColor());
+ m_label2.Render();
g_graphicsContext.RestoreClipRegion();
}
}
diff --git a/guilib/GUIEditControl.h b/guilib/GUIEditControl.h
index 59e1368e02..7176ddc3d1 100644
--- a/guilib/GUIEditControl.h
+++ b/guilib/GUIEditControl.h
@@ -84,6 +84,7 @@ protected:
void UpdateText(bool sendUpdate = true);
void OnPasteClipboard();
void OnSMSCharacter(unsigned int key);
+ void DefaultConstructor();
CStdStringW m_text2;
CStdString m_text;
diff --git a/guilib/GUIFadeLabelControl.h b/guilib/GUIFadeLabelControl.h
index 062bfd6523..dca7dae0fb 100644
--- a/guilib/GUIFadeLabelControl.h
+++ b/guilib/GUIFadeLabelControl.h
@@ -30,7 +30,7 @@
*/
#include "GUIControl.h"
-#include "GUITextLayout.h"
+#include "GUILabel.h"
/*!
\ingroup controls
diff --git a/guilib/GUIFontTTF.cpp b/guilib/GUIFontTTF.cpp
index a88c75b1e3..177ae8f368 100644
--- a/guilib/GUIFontTTF.cpp
+++ b/guilib/GUIFontTTF.cpp
@@ -297,7 +297,7 @@ void CGUIFontTTFBase::DrawTextInternal(float x, float y, const vecColors &colors
// Get the extent of this line
float w = GetTextWidthInternal( text.begin(), text.end() );
- if ( alignment & XBFONT_TRUNCATED && w > maxPixelWidth )
+ if ( alignment & XBFONT_TRUNCATED && w > maxPixelWidth + 0.5f ) // + 0.5f due to rounding issues
w = maxPixelWidth;
if ( alignment & XBFONT_CENTER_X)
diff --git a/guilib/GUILabel.cpp b/guilib/GUILabel.cpp
new file mode 100644
index 0000000000..f9fc9d3caa
--- /dev/null
+++ b/guilib/GUILabel.cpp
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2005-2010 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "GUILabel.h"
+#include "utils/CharsetConverter.h"
+#include <limits>
+
+CGUILabel::CGUILabel(float posX, float posY, float width, float height, const CLabelInfo& labelInfo, CGUILabel::OVER_FLOW overflow, int scrollSpeed)
+ : m_maxRect(posX, posY, posX + width, posY + height)
+ , m_textLayout(labelInfo.font, overflow == OVER_FLOW_WRAP, height)
+ , m_scrollInfo(50, 0, scrollSpeed)
+ , m_renderRect()
+{
+ m_selected = false;
+ m_overflowType = overflow;
+ m_scrolling = (overflow == OVER_FLOW_SCROLL);
+ m_label = labelInfo;
+ m_invalid = true;
+}
+
+CGUILabel::~CGUILabel(void)
+{
+}
+
+void CGUILabel::SetScrolling(bool scrolling, int scrollSpeed)
+{
+ m_scrolling = scrolling;
+ if (scrollSpeed)
+ m_scrollInfo.SetSpeed(scrollSpeed);
+ if (!m_scrolling)
+ m_scrollInfo.Reset();
+}
+
+void CGUILabel::SetColor(CGUILabel::COLOR color)
+{
+ m_color = color;
+}
+
+color_t CGUILabel::GetColor() const
+{
+ switch (m_color)
+ {
+ case COLOR_SELECTED:
+ return m_label.selectedColor;
+ case COLOR_DISABLED:
+ return m_label.disabledColor;
+ case COLOR_FOCUSED:
+ return m_label.focusedColor ? m_label.focusedColor : m_label.textColor;
+ }
+ return m_label.textColor;
+}
+
+void CGUILabel::Render()
+{
+ color_t color = GetColor();
+ bool renderSolid = (m_color == COLOR_DISABLED);
+ bool overFlows = (m_renderRect.Width() + 0.5f < m_textLayout.GetTextWidth()); // 0.5f to deal with floating point rounding issues
+ if (overFlows && m_scrolling && !renderSolid)
+ m_textLayout.RenderScrolling(m_renderRect.x1, m_renderRect.y1, m_label.angle, color, m_label.shadowColor, 0, m_renderRect.Width(), m_scrollInfo);
+ else
+ {
+ float posX = m_renderRect.x1;
+ uint32_t align = 0;
+ if (!overFlows)
+ { // hack for right and centered multiline text, as GUITextLayout::Render() treats posX as the right hand
+ // or center edge of the text (see GUIFontTTF::DrawTextInternal), and this has already been taken care of
+ // in UpdateRenderRect(), but we wish to still pass the horizontal alignment info through (so that multiline text
+ // is aligned correctly), so we must undo the UpdateRenderRect() changes for horizontal alignment.
+ if (m_label.align & XBFONT_RIGHT)
+ posX += m_renderRect.Width();
+ else if (m_label.align & XBFONT_CENTER_X)
+ posX += m_renderRect.Width() * 0.5f;
+ align = m_label.align & ~XBFONT_CENTER_Y; // ignore vertical alignment
+ }
+ m_textLayout.Render(posX, m_renderRect.y1, m_label.angle, color, m_label.shadowColor, align, m_renderRect.Width(), renderSolid);
+ }
+}
+
+void CGUILabel::SetInvalid()
+{
+ m_invalid = true;
+}
+
+void CGUILabel::UpdateColors()
+{
+ m_label.UpdateColors();
+}
+
+void CGUILabel::SetMaxRect(float x, float y, float w, float h)
+{
+ m_maxRect.SetRect(x + m_label.offsetX, y + m_label.offsetY, x + w - m_label.offsetX, y + h - m_label.offsetY);
+ UpdateRenderRect();
+}
+
+void CGUILabel::SetAlign(uint32_t align)
+{
+ m_label.align = align;
+ UpdateRenderRect();
+}
+
+void CGUILabel::SetText(const CStdString &label)
+{
+ if (m_textLayout.Update(label, m_maxRect.Width(), m_invalid))
+ { // needed an update - reset scrolling and update our text layout
+ m_scrollInfo.Reset();
+ UpdateRenderRect();
+ m_invalid = false;
+ }
+}
+
+void CGUILabel::SetTextW(const CStdStringW &label)
+{
+ m_textLayout.SetText(label);
+ m_scrollInfo.Reset();
+ UpdateRenderRect();
+ m_invalid = false;
+}
+
+void CGUILabel::UpdateRenderRect()
+{
+ // recalculate our text layout
+ float width, height;
+ m_textLayout.GetTextExtent(width, height);
+ width = std::min(width, m_maxRect.Width());
+ if (m_label.align & XBFONT_CENTER_Y)
+ m_renderRect.y1 = m_maxRect.y1 + (m_maxRect.Height() - height) * 0.5f;
+ else
+ m_renderRect.y1 = m_maxRect.y1;
+ if (m_label.align & XBFONT_RIGHT)
+ m_renderRect.x1 = m_maxRect.x2 - width;
+ else if (m_label.align & XBFONT_CENTER_X)
+ m_renderRect.x1 = m_maxRect.x1 + (m_maxRect.Width() - width) * 0.5f;
+ else
+ m_renderRect.x1 = m_maxRect.x1;
+ m_renderRect.x2 = m_renderRect.x1 + width;
+ m_renderRect.y2 = m_renderRect.y1 + height;
+}
diff --git a/guilib/GUILabel.h b/guilib/GUILabel.h
new file mode 100644
index 0000000000..78d8a00789
--- /dev/null
+++ b/guilib/GUILabel.h
@@ -0,0 +1,194 @@
+/*!
+\file GUILabel.h
+\brief
+*/
+
+#pragma once
+
+/*
+ * Copyright (C) 2005-2010 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "GUITextLayout.h"
+#include "GUIInfoTypes.h"
+#include "GUIFont.h"
+#include "Geometry.h"
+
+class CLabelInfo
+{
+public:
+ CLabelInfo()
+ {
+ font = NULL;
+ align = XBFONT_LEFT;
+ offsetX = offsetY = 0;
+ width = 0;
+ angle = 0;
+ };
+ void UpdateColors()
+ {
+ textColor.Update();
+ shadowColor.Update();
+ selectedColor.Update();
+ disabledColor.Update();
+ focusedColor.Update();
+ };
+
+ CGUIInfoColor textColor;
+ CGUIInfoColor shadowColor;
+ CGUIInfoColor selectedColor;
+ CGUIInfoColor disabledColor;
+ CGUIInfoColor focusedColor;
+ uint32_t align;
+ float offsetX;
+ float offsetY;
+ float width;
+ float angle;
+ CGUIFont *font;
+};
+
+/*!
+ \ingroup controls, labels
+ \brief Class for rendering text labels. Handles alignment and rendering of text within a control.
+ */
+class CGUILabel
+{
+public:
+ /*! \brief allowed color categories for labels, as defined by the skin
+ */
+ enum COLOR { COLOR_TEXT = 0,
+ COLOR_SELECTED,
+ COLOR_FOCUSED,
+ COLOR_DISABLED };
+
+ /*! \brief allowed overflow handling techniques for labels, as defined by the skin
+ */
+ enum OVER_FLOW { OVER_FLOW_TRUNCATE = 0,
+ OVER_FLOW_SCROLL,
+ OVER_FLOW_WRAP };
+
+ CGUILabel(float posX, float posY, float width, float height, const CLabelInfo& labelInfo, OVER_FLOW overflow = OVER_FLOW_TRUNCATE, int scrollSpeed = 0);
+ virtual ~CGUILabel(void);
+
+ /*! \brief Render the label on screen
+ */
+ void Render();
+
+ /*! \brief Set the maximal extent of the label
+ Sets the maximal size and positioning that the label may render in. Note that any offsets will be computed and applied immediately
+ so that subsequent calls to GetMaxRect() may not return the same values.
+ \sa GetMaxRect
+ */
+ void SetMaxRect(float x, float y, float w, float h);
+
+ void SetAlign(uint32_t align);
+
+ /*! \brief Set the text to be displayed in the label
+ Updates the label control and recomputes final position and size
+ \param text CStdString to set as this labels text
+ \sa SetTextW
+ */
+ void SetText(const CStdString &label);
+
+ /*! \brief Set the text to be displayed in the label
+ Updates the label control and recomputes final position and size
+ \param text CStdStringW to set as this labels text
+ \sa SetText
+ */
+ void SetTextW(const CStdStringW &label);
+
+ /*! \brief Set the color to use for the label
+ Sets the color to be used for this label. Takes effect at the next render
+ \param color color to be used for the label
+ */
+ void SetColor(COLOR color);
+
+ /*! \brief Set the final layout of the current text
+ Overrides the calculated layout of the current text, forcing a particular size and position
+ \param rect CRect containing the extents of the current text
+ \sa GetRenderRect, UpdateRenderRect
+ */
+ void SetRenderRect(const CRect &rect) { m_renderRect = rect; };
+
+ /*! \brief Set whether or not this label control should scroll
+ \param scrolling true if this label should scroll.
+ \param scrollSpeed speed (in pixels per second) at which the label should scroll
+ */
+ void SetScrolling(bool scrolling, int scrollSpeed = 0);
+
+ /*! \brief Set this label invalid. Forces an update of the control
+ */
+ void SetInvalid();
+
+ /*! \brief Update this labels colors
+ */
+ void UpdateColors();
+
+ /*! \brief Returns the precalculated final layout of the current text
+ \return CRect containing the extents of the current text
+ \sa SetRenderRect, UpdateRenderRect
+ */
+ const CRect &GetRenderRect() const { return m_renderRect; };
+
+ /*! \brief Returns the precalculated full width of the current text, regardless of layout
+ \return full width of the current text
+ \sa CalcTextWidth
+ */
+ float GetTextWidth() const { return m_textLayout.GetTextWidth(); };
+
+ /*! \brief Returns the maximal text rect that this label can render into
+ \return CRect containing the maximal rectangle that this label can render into. May differ from
+ the sizing given in SetMaxRect as offsets have been applied.
+ \sa SetMaxRect
+ */
+ const CRect &GetMaxRect() const { return m_maxRect; };
+
+ /*! \brief Calculates the width of some text
+ \param text CStdStringW of text whose width we want
+ \return width of the given text
+ \sa GetTextWidth
+ */
+ float CalcTextWidth(const CStdStringW &text) const { return m_textLayout.GetTextWidth(text); };
+
+ const CLabelInfo& GetLabelInfo() const { return m_label; };
+ CLabelInfo &GetLabelInfo() { return m_label; };
+protected:
+ color_t GetColor() const;
+
+ /*! \brief Computes the final layout of the text
+ Uses the maximal position and width of the text, as well as the text length
+ and alignment to compute the final render rect of the text.
+ \sa GetRenderRect, SetRenderRect
+ */
+ void UpdateRenderRect();
+
+private:
+ CLabelInfo m_label;
+ CGUITextLayout m_textLayout;
+
+ bool m_scrolling;
+ OVER_FLOW m_overflowType;
+ bool m_selected;
+ CScrollInfo m_scrollInfo;
+ CRect m_renderRect; ///< actual sizing of text
+ CRect m_maxRect; ///< maximum sizing of text
+ bool m_invalid; ///< if true, the label needs recomputing
+ COLOR m_color; ///< color to render text \sa SetColor, GetColor
+};
diff --git a/guilib/GUILabelControl.cpp b/guilib/GUILabelControl.cpp
index 51d03f7740..7dfa8af69d 100644
--- a/guilib/GUILabelControl.cpp
+++ b/guilib/GUILabelControl.cpp
@@ -25,17 +25,18 @@
using namespace std;
CGUILabelControl::CGUILabelControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, bool wrapMultiLine, bool bHasPath)
- : CGUIControl(parentID, controlID, posX, posY, width, height), m_textLayout(labelInfo.font, wrapMultiLine, height)
+ : CGUIControl(parentID, controlID, posX, posY, width, height)
+ , m_label(posX, posY, width, height, labelInfo, wrapMultiLine ? CGUILabel::OVER_FLOW_WRAP : CGUILabel::OVER_FLOW_TRUNCATE)
{
m_bHasPath = bHasPath;
m_iCursorPos = 0;
- m_label = labelInfo;
m_bShowCursor = false;
m_dwCounter = 0;
ControlType = GUICONTROL_LABEL;
- m_ScrollInsteadOfTruncate = false;
m_startHighlight = m_endHighlight = 0;
m_minWidth = 0;
+ if ((labelInfo.align & XBFONT_RIGHT) && m_width)
+ m_posX -= m_width;
}
CGUILabelControl::~CGUILabelControl(void)
@@ -86,53 +87,20 @@ void CGUILabelControl::UpdateInfo(const CGUIListItem *item)
else if (m_startHighlight || m_endHighlight)
{ // this is only used for times/dates, so working in ascii (utf8) is fine
CStdString colorLabel;
- colorLabel.Format("[COLOR %x]%s[/COLOR]%s[COLOR %x]%s[/COLOR]", (color_t)m_label.disabledColor, label.Left(m_startHighlight),
- label.Mid(m_startHighlight, m_endHighlight - m_startHighlight), (color_t)m_label.disabledColor, label.Mid(m_endHighlight));
+ colorLabel.Format("[COLOR %x]%s[/COLOR]%s[COLOR %x]%s[/COLOR]", (color_t)m_label.GetLabelInfo().disabledColor, label.Left(m_startHighlight),
+ label.Mid(m_startHighlight, m_endHighlight - m_startHighlight), (color_t)m_label.GetLabelInfo().disabledColor, label.Mid(m_endHighlight));
label = colorLabel;
}
- if (m_textLayout.Update(label, m_width))
- { // reset the scrolling as we have a new label
- m_ScrollInfo.Reset();
- }
+ m_label.SetMaxRect(m_posX, m_posY, m_width, m_height);
+ m_label.SetText(label);
}
void CGUILabelControl::Render()
{
- // check for scrolling
- bool bNormalDraw = true;
- if (m_ScrollInsteadOfTruncate && m_width > 0 && !IsDisabled())
- { // ignore align center - just use align left/right
- float width, height;
- m_textLayout.GetTextExtent(width, height);
- if (width > m_width)
- { // need to scroll - set the viewport. Should be set just using the height of the text
- bNormalDraw = false;
- float fPosX = m_posX;
- if (m_label.align & XBFONT_RIGHT)
- fPosX -= m_width;
- float fPosY = m_posY;
- if (m_label.align & XBFONT_CENTER_Y)
- fPosY += m_height * 0.5f;
-
- m_textLayout.RenderScrolling(fPosX, fPosY, m_label.angle, m_label.textColor, m_label.shadowColor, (m_label.align & ~3), m_width, m_ScrollInfo);
- }
- }
- if (bNormalDraw)
- {
- float fPosX = m_posX;
- if (m_label.align & XBFONT_CENTER_X)
- fPosX += m_width * 0.5f;
-
- float fPosY = m_posY;
- if (m_label.align & XBFONT_CENTER_Y)
- fPosY += m_height * 0.5f;
-
- if (IsDisabled())
- m_textLayout.Render(fPosX, fPosY, m_label.angle, m_label.disabledColor, m_label.shadowColor, m_label.align | XBFONT_TRUNCATED, m_width, true);
- else
- m_textLayout.Render(fPosX, fPosY, m_label.angle, m_label.textColor, m_label.shadowColor, m_label.align | XBFONT_TRUNCATED, m_width);
- }
+ m_label.SetColor(IsDisabled() ? CGUILabel::COLOR_DISABLED : CGUILabel::COLOR_TEXT);
+ m_label.SetMaxRect(m_posX, m_posY, m_width, m_height);
+ m_label.Render();
CGUIControl::Render();
}
@@ -149,7 +117,6 @@ void CGUILabelControl::SetLabel(const string &strLabel)
m_infoLabel.SetLabel(ShortenPath(strLabel), "");
else // parse the label for info tags
m_infoLabel.SetLabel(strLabel, "");
- m_ScrollInfo.Reset();
if (m_iCursorPos > (int)strLabel.size())
m_iCursorPos = strLabel.size();
}
@@ -157,14 +124,12 @@ void CGUILabelControl::SetLabel(const string &strLabel)
void CGUILabelControl::SetWidthControl(float minWidth, bool bScroll, int scrollSpeed)
{
m_minWidth = minWidth;
- m_ScrollInsteadOfTruncate = bScroll;
- m_ScrollInfo.SetSpeed(scrollSpeed);
- m_ScrollInfo.Reset();
+ m_label.SetScrolling(bScroll, scrollSpeed);
}
void CGUILabelControl::SetAlignment(uint32_t align)
{
- m_label.align = align;
+ m_label.GetLabelInfo().align = align;
}
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
@@ -172,7 +137,7 @@ void CGUILabelControl::SetAlignment(uint32_t align)
float CGUILabelControl::GetWidth() const
{
if (m_minWidth && m_minWidth != m_width)
- return CLAMP(m_textLayout.GetTextWidth(), m_minWidth, m_width);
+ return CLAMP(m_label.GetTextWidth(), m_minWidth, m_width);
return m_width;
}
@@ -192,7 +157,7 @@ bool CGUILabelControl::OnMessage(CGUIMessage& message)
CStdString CGUILabelControl::ShortenPath(const CStdString &path)
{
- if (!m_label.font || m_width == 0 || path.IsEmpty())
+ if (m_width == 0 || path.IsEmpty())
return path;
char cDelim = '\0';
@@ -220,11 +185,10 @@ CStdString CGUILabelControl::ShortenPath(const CStdString &path)
nPos = workPath.find_last_of( cDelim );
}
- float fTextHeight, fTextWidth;
- m_textLayout.Update(workPath);
- m_textLayout.GetTextExtent(fTextWidth, fTextHeight);
+ m_label.SetText(workPath);
+ float textWidth = m_label.GetTextWidth();
- while ( fTextWidth > m_width )
+ while ( textWidth > m_width )
{
size_t nGreaterDelim = workPath.find_last_of( cDelim, nPos );
if (nGreaterDelim == std::string::npos)
@@ -236,20 +200,12 @@ CStdString CGUILabelControl::ShortenPath(const CStdString &path)
workPath.replace( nPos + 1, nGreaterDelim - nPos - 1, "..." );
- m_textLayout.Update(workPath);
- m_textLayout.GetTextExtent(fTextWidth, fTextHeight);
+ m_label.SetText(workPath);
+ textWidth = m_label.GetTextWidth();
}
return workPath;
}
-void CGUILabelControl::SetTruncate(bool bTruncate)
-{
- if (bTruncate)
- m_label.align |= XBFONT_TRUNCATED;
- else
- m_label.align &= ~XBFONT_TRUNCATED;
-}
-
void CGUILabelControl::SetHighlight(unsigned int start, unsigned int end)
{
m_startHighlight = start;
diff --git a/guilib/GUILabelControl.h b/guilib/GUILabelControl.h
index 570742882f..7ac25f4c7c 100644
--- a/guilib/GUILabelControl.h
+++ b/guilib/GUILabelControl.h
@@ -30,7 +30,7 @@
*/
#include "GUIControl.h"
-#include "GUITextLayout.h"
+#include "GUILabel.h"
/*!
\ingroup controls
@@ -51,14 +51,13 @@ public:
virtual CStdString GetDescription() const;
virtual float GetWidth() const;
- const CLabelInfo& GetLabelInfo() const { return m_label; };
+ const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo(); };
void SetLabel(const std::string &strLabel);
void ShowCursor(bool bShow = true);
void SetCursorPos(int iPos);
int GetCursorPos() const { return m_iCursorPos;};
void SetInfo(const CGUIInfoLabel&labelInfo);
void SetWidthControl(float minWidth, bool bScroll, int scrollSpeed);
- void SetTruncate(bool bTruncate);
void SetAlignment(uint32_t align);
void SetHighlight(unsigned int start, unsigned int end);
@@ -66,16 +65,13 @@ protected:
void UpdateColors();
CStdString ShortenPath(const CStdString &path);
- CLabelInfo m_label;
- CGUITextLayout m_textLayout;
+ CGUILabel m_label;
bool m_bHasPath;
bool m_bShowCursor;
int m_iCursorPos;
unsigned int m_dwCounter;
- // stuff for scrolling
- bool m_ScrollInsteadOfTruncate;
- CScrollInfo m_ScrollInfo;
+
// stuff for autowidth
bool m_autoWidth;
float m_minWidth;
diff --git a/guilib/GUIListItemLayout.h b/guilib/GUIListItemLayout.h
index 2bea1afb9d..e7eeff6b2d 100644
--- a/guilib/GUIListItemLayout.h
+++ b/guilib/GUIListItemLayout.h
@@ -26,6 +26,7 @@
class CGUIListItem;
class CFileItem;
+class CLabelInfo;
class CGUIListItemLayout
{
diff --git a/guilib/GUIListLabel.cpp b/guilib/GUIListLabel.cpp
index b08d473549..9a571a01b8 100644
--- a/guilib/GUIListLabel.cpp
+++ b/guilib/GUIListLabel.cpp
@@ -25,15 +25,15 @@
CGUIListLabel::CGUIListLabel(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoLabel &info, bool alwaysScroll, int scrollSpeed)
: CGUIControl(parentID, controlID, posX, posY, width, height)
- , m_textLayout(labelInfo.font, false)
- , m_scrollInfo(50, 0, scrollSpeed)
- , m_renderRect()
+ , m_label(posX, posY, width, height, labelInfo, alwaysScroll ? CGUILabel::OVER_FLOW_SCROLL : CGUILabel::OVER_FLOW_TRUNCATE, scrollSpeed)
{
- m_selected = false;
- m_scrolling = m_alwaysScroll = alwaysScroll;
- m_label = labelInfo;
m_info = info;
- m_textWidth = width;
+ m_alwaysScroll = alwaysScroll;
+ // TODO: Remove this "correction"
+ if (labelInfo.align & XBFONT_RIGHT)
+ m_label.SetMaxRect(m_posX - m_width, m_posY, m_width, m_height);
+ else if (labelInfo.align & XBFONT_CENTER_X)
+ m_label.SetMaxRect(m_posX - m_width*0.5f, m_posY, m_width, m_height);
if (m_info.IsConstant())
SetLabel(m_info.GetLabel(m_parentID, true));
ControlType = GUICONTROL_LISTLABEL;
@@ -45,14 +45,12 @@ CGUIListLabel::~CGUIListLabel(void)
void CGUIListLabel::SetScrolling(bool scrolling)
{
- m_scrolling = m_alwaysScroll ? true : scrolling;
- if (!m_scrolling)
- m_scrollInfo.Reset();
+ m_label.SetScrolling(scrolling || m_alwaysScroll);
}
void CGUIListLabel::SetSelected(bool selected)
{
- m_selected = selected;
+ m_label.SetColor(selected ? CGUILabel::COLOR_SELECTED : CGUILabel::COLOR_TEXT);
}
void CGUIListLabel::SetFocus(bool focus)
@@ -70,27 +68,7 @@ void CGUIListLabel::UpdateColors()
void CGUIListLabel::Render()
{
- color_t color = m_selected ? m_label.selectedColor : m_label.textColor;
- bool needsToScroll = (m_renderRect.Width() + 0.5f < m_textWidth); // 0.5f to deal with floating point rounding issues
- if (m_scrolling && needsToScroll)
- m_textLayout.RenderScrolling(m_renderRect.x1, m_renderRect.y1, m_label.angle, color, m_label.shadowColor, 0, m_renderRect.Width(), m_scrollInfo);
- else
- {
- float posX = m_renderRect.x1;
- uint32_t align = 0;
- if (!needsToScroll)
- { // hack for right and centered multiline text, as GUITextLayout::Render() treats posX as the right hand
- // or center edge of the text (see GUIFontTTF::DrawTextInternal), and this has already been taken care of
- // in SetLabel(), but we wish to still pass the horizontal alignment info through (so that multiline text
- // is aligned correctly), so we must undo the SetLabel() changes for horizontal alignment.
- if (m_label.align & XBFONT_RIGHT)
- posX += m_renderRect.Width();
- else if (m_label.align & XBFONT_CENTER_X)
- posX += m_renderRect.Width() * 0.5f;
- align = m_label.align & ~XBFONT_CENTER_Y; // ignore vertical alignment
- }
- m_textLayout.Render(posX, m_renderRect.y1, m_label.angle, color, m_label.shadowColor, align, m_renderRect.Width());
- }
+ m_label.Render();
CGUIControl::Render();
}
@@ -105,26 +83,13 @@ void CGUIListLabel::UpdateInfo(const CGUIListItem *item)
SetLabel(m_info.GetLabel(m_parentID, true));
}
+void CGUIListLabel::SetInvalid()
+{
+ m_label.SetInvalid();
+ CGUIControl::SetInvalid();
+}
+
void CGUIListLabel::SetLabel(const CStdString &label)
{
- if (m_textLayout.Update(label, 0, m_bInvalidated))
- { // needed an update - reset scrolling
- m_scrollInfo.Reset();
- // recalculate our text layout
- float width, height;
- m_textLayout.GetTextExtent(m_textWidth, height);
- width = std::min(m_textWidth, m_width);
- if (m_label.align & XBFONT_CENTER_Y)
- m_renderRect.y1 = m_posY + (m_height - height) * 0.5f;
- else
- m_renderRect.y1 = m_posY;
- if (m_label.align & XBFONT_RIGHT)
- m_renderRect.x1 = m_posX - width;
- else if (m_label.align & XBFONT_CENTER_X)
- m_renderRect.x1 = m_posX - width * 0.5f;
- else
- m_renderRect.x1 = m_posX;
- m_renderRect.x2 = m_renderRect.x1 + width;
- m_renderRect.y2 = m_renderRect.y1 + height;
- }
+ m_label.SetText(label);
}
diff --git a/guilib/GUIListLabel.h b/guilib/GUIListLabel.h
index 43e18fb1cd..b513b1da1c 100644
--- a/guilib/GUIListLabel.h
+++ b/guilib/GUIListLabel.h
@@ -27,7 +27,7 @@
*/
#include "GUIControl.h"
-#include "GUITextLayout.h"
+#include "GUILabel.h"
/*!
\ingroup controls
@@ -45,26 +45,20 @@ public:
virtual bool CanFocus() const { return false; };
virtual void UpdateInfo(const CGUIListItem *item = NULL);
virtual void SetFocus(bool focus);
+ virtual void SetInvalid();
- const CRect &GetRenderRect() const { return m_renderRect; };
- void SetRenderRect(const CRect &rect) { m_renderRect = rect; };
+ const CRect &GetRenderRect() const { return m_label.GetRenderRect(); };
+ void SetRenderRect(const CRect &rect) { m_label.SetRenderRect(rect); };
void SetLabel(const CStdString &label);
void SetSelected(bool selected);
void SetScrolling(bool scrolling);
- const CLabelInfo& GetLabelInfo() const { return m_label; };
+ const CLabelInfo& GetLabelInfo() const { return m_label.GetLabelInfo(); };
protected:
virtual void UpdateColors();
- CLabelInfo m_label;
- CGUITextLayout m_textLayout;
- CGUIInfoLabel m_info;
- float m_textWidth;
-
- bool m_scrolling;
- bool m_alwaysScroll;
- bool m_selected;
- CScrollInfo m_scrollInfo;
- CRect m_renderRect; // render location
+ CGUILabel m_label;
+ CGUIInfoLabel m_info;
+ bool m_alwaysScroll;
};
diff --git a/guilib/GUIRSSControl.h b/guilib/GUIRSSControl.h
index ff604cfe8c..3d09d3bc58 100644
--- a/guilib/GUIRSSControl.h
+++ b/guilib/GUIRSSControl.h
@@ -30,6 +30,7 @@
*/
#include "GUIControl.h"
+#include "GUILabel.h"
typedef uint32_t character_t;
typedef uint32_t color_t;
diff --git a/guilib/GUISelectButtonControl.cpp b/guilib/GUISelectButtonControl.cpp
index 689ebcde55..30c220af37 100644
--- a/guilib/GUISelectButtonControl.cpp
+++ b/guilib/GUISelectButtonControl.cpp
@@ -53,6 +53,7 @@ CGUISelectButtonControl::CGUISelectButtonControl(int parentID, int controlID,
m_bMovedLeft = false;
m_bMovedRight = false;
m_ticks = 0;
+ m_label.SetAlign(m_label.GetLabelInfo().align | XBFONT_CENTER_X);
ControlType = GUICONTROL_SELECTBUTTON;
}
@@ -72,7 +73,7 @@ void CGUISelectButtonControl::Render()
// render background, left and right arrow
m_imgBackground.Render();
- color_t textColor = m_label.textColor;
+ CGUILabel::COLOR color = CGUILabel::COLOR_TEXT;
// User has moved left...
if (m_bMovedLeft)
@@ -85,7 +86,7 @@ void CGUISelectButtonControl::Render()
}
// If we are moving left
// render item text as disabled
- textColor = m_label.disabledColor;
+ color = CGUILabel::COLOR_DISABLED;
}
// Render arrow
@@ -105,7 +106,7 @@ void CGUISelectButtonControl::Render()
}
// If we are moving right
// render item text as disabled
- textColor = m_label.disabledColor;
+ color = CGUILabel::COLOR_DISABLED;
}
// Render arrow
@@ -117,12 +118,10 @@ void CGUISelectButtonControl::Render()
// Render text if a current item is available
if (m_iCurrentItem >= 0 && (unsigned)m_iCurrentItem < m_vecItems.size())
{
- m_textLayout.Update(m_vecItems[m_iCurrentItem]);
- uint32_t align = m_label.align | XBFONT_CENTER_X;
- float fPosY = m_posY + m_label.offsetY;
- if (m_label.align & XBFONT_CENTER_Y)
- fPosY = m_posY + m_imgBackground.GetHeight()*0.5f;
- m_textLayout.Render(m_posX + GetWidth()*0.5f, fPosY, 0, textColor, m_label.shadowColor, align, m_label.width);
+ m_label.SetMaxRect(m_posX, m_posY, m_width, m_height);
+ m_label.SetText(m_vecItems[m_iCurrentItem]);
+ m_label.SetColor(color);
+ m_label.Render();
}
// Select current item, if user doesn't
diff --git a/guilib/GUISettingsSliderControl.cpp b/guilib/GUISettingsSliderControl.cpp
index 673e029ad1..cb3fd15da6 100644
--- a/guilib/GUISettingsSliderControl.cpp
+++ b/guilib/GUISettingsSliderControl.cpp
@@ -24,8 +24,9 @@
CGUISettingsSliderControl::CGUISettingsSliderControl(int parentID, int controlID, float posX, float posY, float width, float height, float sliderWidth, float sliderHeight, const CTextureInfo &textureFocus, const CTextureInfo &textureNoFocus, const CTextureInfo& backGroundTexture, const CTextureInfo& nibTexture, const CTextureInfo& nibTextureFocus, const CLabelInfo &labelInfo, int iType)
: CGUISliderControl(parentID, controlID, posX, posY, sliderWidth, sliderHeight, backGroundTexture, nibTexture,nibTextureFocus, iType)
, m_buttonControl(parentID, controlID, posX, posY, width, height, textureFocus, textureNoFocus, labelInfo)
- , m_textLayout(labelInfo.font, false)
+ , m_label(posX, posY, width, height, labelInfo)
{
+ m_label.SetAlign(XBFONT_CENTER_Y | XBFONT_RIGHT);
ControlType = GUICONTROL_SETTINGS_SLIDER;
}
@@ -45,14 +46,10 @@ void CGUISettingsSliderControl::Render()
CGUISliderControl::Render();
// now render our text
- m_textLayout.Update(CGUISliderControl::GetDescription());
-
- float posX = m_posX - m_buttonControl.GetLabelInfo().offsetX;
- float posY = GetYPosition() + GetHeight() * 0.5f;
- if (HasFocus() && m_buttonControl.GetLabelInfo().focusedColor)
- m_textLayout.Render(posX, posY, 0, m_buttonControl.GetLabelInfo().focusedColor, m_buttonControl.GetLabelInfo().shadowColor, XBFONT_CENTER_Y | XBFONT_RIGHT, 0);
- else
- m_textLayout.Render(posX, posY, 0, m_buttonControl.GetLabelInfo().textColor, m_buttonControl.GetLabelInfo().shadowColor, XBFONT_CENTER_Y | XBFONT_RIGHT, 0);
+ m_label.SetMaxRect(m_buttonControl.GetXPosition(), m_posY, m_posX - m_buttonControl.GetXPosition(), m_height);
+ m_label.SetText(CGUISliderControl::GetDescription());
+ m_label.SetColor(HasFocus() ? CGUILabel::COLOR_FOCUSED : CGUILabel::COLOR_TEXT);
+ m_label.Render();
}
bool CGUISettingsSliderControl::OnAction(const CAction &action)
diff --git a/guilib/GUISettingsSliderControl.h b/guilib/GUISettingsSliderControl.h
index 9434e300cd..951851ffb2 100644
--- a/guilib/GUISettingsSliderControl.h
+++ b/guilib/GUISettingsSliderControl.h
@@ -66,9 +66,12 @@ public:
virtual float GetYPosition() const { return m_buttonControl.GetYPosition();};
virtual CStdString GetDescription() const;
virtual bool HitTest(const CPoint &point) const { return m_buttonControl.HitTest(point); };
+
protected:
virtual void UpdateColors();
+
+private:
CGUIButtonControl m_buttonControl;
- CGUITextLayout m_textLayout;
+ CGUILabel m_label;
};
#endif
diff --git a/guilib/GUISpinControl.cpp b/guilib/GUISpinControl.cpp
index 151fde86b6..c15b6909ac 100644
--- a/guilib/GUISpinControl.cpp
+++ b/guilib/GUISpinControl.cpp
@@ -34,7 +34,7 @@ CGUISpinControl::CGUISpinControl(int parentID, int controlID, float posX, float
, m_imgspinDown(posX, posY, width, height, textureDown)
, m_imgspinUpFocus(posX, posY, width, height, textureUpFocus)
, m_imgspinDownFocus(posX, posY, width, height, textureDownFocus)
- , m_textLayout(labelInfo.font, false)
+ , m_label(posX, posY, width, height, labelInfo)
{
m_bReverse = false;
m_iStart = 0;
@@ -43,8 +43,7 @@ CGUISpinControl::CGUISpinControl(int parentID, int controlID, float posX, float
m_fEnd = 1.0f;
m_fInterval = 0.1f;
m_iValue = 0;
- m_label = labelInfo;
- m_label.align |= XBFONT_CENTER_Y;
+ m_label.GetLabelInfo().align |= XBFONT_CENTER_Y;
m_fValue = 0.0;
m_iType = iType;
m_iSelect = SPIN_BUTTON_DOWN;
@@ -356,7 +355,6 @@ void CGUISpinControl::Render()
strcpy(m_szTyped, "");
}
- float posX = m_posX;
CStdString text;
if (m_iType == SPIN_CONTROL_TYPE_INT)
@@ -407,18 +405,18 @@ void CGUISpinControl::Render()
}
- m_textLayout.Update(text);
- // Calculate the size of our text (for use in HitTest)
- float fTextWidth = 0;
- float fTextHeight = 0;
- m_textLayout.GetTextExtent(fTextWidth, fTextHeight);
+ m_label.SetText(text);
+
+ const float space = 5;
+ float textWidth = m_label.GetTextWidth() + 2 * m_label.GetLabelInfo().offsetX;
// Position the arrows
- if ( !(m_label.align & (XBFONT_RIGHT | XBFONT_CENTER_X)) )
+ bool arrowsOnRight = m_label.GetLabelInfo().align & (XBFONT_RIGHT | XBFONT_CENTER_X);
+ if (!arrowsOnRight)
{
- m_imgspinUpFocus.SetPosition(fTextWidth + 5 + posX + m_imgspinDown.GetWidth(), m_posY);
- m_imgspinUp.SetPosition(fTextWidth + 5 + posX + m_imgspinDown.GetWidth(), m_posY);
- m_imgspinDownFocus.SetPosition(fTextWidth + 5 + posX, m_posY);
- m_imgspinDown.SetPosition(fTextWidth + 5 + posX, m_posY);
+ m_imgspinDownFocus.SetPosition(m_posX + textWidth + space, m_posY);
+ m_imgspinDown.SetPosition(m_posX + textWidth + space, m_posY);
+ m_imgspinUpFocus.SetPosition(m_posX + textWidth + space + m_imgspinDown.GetWidth(), m_posY);
+ m_imgspinUp.SetPosition(m_posX + textWidth + space + m_imgspinDown.GetWidth(), m_posY);
}
if ( HasFocus() )
@@ -439,31 +437,31 @@ void CGUISpinControl::Render()
m_imgspinDown.Render();
}
- if (m_label.font)
+ if (m_label.GetLabelInfo().font)
{
- float fPosY;
- if (m_label.align & XBFONT_CENTER_Y)
- fPosY = m_posY + m_height * 0.5f;
+ if (arrowsOnRight)
+ m_label.SetMaxRect(m_posX - space - textWidth, m_posY, textWidth, m_height);
else
- fPosY = m_posY + m_label.offsetY;
+ m_label.SetMaxRect(m_posX + m_imgspinDown.GetWidth() + m_imgspinUp.GetWidth() + space, m_posY, textWidth, m_height);
- float fPosX = m_posX + m_label.offsetX - 3;
- if (IsDisabled())
- m_textLayout.Render(fPosX, fPosY, 0, m_label.disabledColor, m_label.shadowColor, m_label.align, 0, true);
- else if (HasFocus() && m_label.focusedColor)
- m_textLayout.Render(fPosX, fPosY, 0, m_label.focusedColor, m_label.shadowColor, m_label.align, 0);
- else
- m_textLayout.Render(fPosX, fPosY, 0, m_label.textColor, m_label.shadowColor, m_label.align, 0);
+ m_label.SetColor(GetTextColor());
+ m_label.Render();
// set our hit rectangle for MouseOver events
- if (!(m_label.align & (XBFONT_RIGHT | XBFONT_CENTER_X)))
- m_hitRect.SetRect(fPosX, fPosY, fPosX + fTextWidth, fPosY + fTextHeight);
- else
- m_hitRect.SetRect(fPosX - fTextWidth, fPosY, fPosX, fPosY + fTextHeight);
+ m_hitRect = m_label.GetRenderRect();
}
CGUIControl::Render();
}
+CGUILabel::COLOR CGUISpinControl::GetTextColor() const
+{
+ if (IsDisabled())
+ return CGUILabel::COLOR_DISABLED;
+ else if (HasFocus())
+ return CGUILabel::COLOR_FOCUSED;
+ return CGUILabel::COLOR_TEXT;
+}
+
void CGUISpinControl::SetRange(int iStart, int iEnd)
{
m_iStart = iStart;
diff --git a/guilib/GUISpinControl.h b/guilib/GUISpinControl.h
index ce440aa8cd..bd537dd5d9 100644
--- a/guilib/GUISpinControl.h
+++ b/guilib/GUISpinControl.h
@@ -31,7 +31,7 @@
#include "GUIControl.h"
#include "GUITexture.h"
-#include "GUITextLayout.h"
+#include "GUILabel.h"
#define SPIN_CONTROL_TYPE_INT 1
#define SPIN_CONTROL_TYPE_FLOAT 2
@@ -74,7 +74,7 @@ public:
void SetReverse(bool bOnOff);
int GetMaximum() const;
int GetMinimum() const;
- void SetSpinAlign(uint32_t align, float offsetX) { m_label.align = align; m_label.offsetX = offsetX; };
+ void SetSpinAlign(uint32_t align, float offsetX) { m_label.GetLabelInfo().align = align; m_label.GetLabelInfo().offsetX = offsetX; };
void SetType(int iType) { m_iType = iType; };
float GetSpinWidth() const { return m_imgspinUp.GetWidth(); };
float GetSpinHeight() const { return m_imgspinUp.GetHeight(); };
@@ -90,6 +90,7 @@ public:
protected:
virtual bool OnMouseEvent(const CPoint &point, const CMouseEvent &event);
virtual void UpdateColors();
+ CGUILabel::COLOR GetTextColor() const;
void PageUp();
void PageDown();
bool CanMoveDown(bool bTestReverse = true);
@@ -113,8 +114,7 @@ protected:
CGUITexture m_imgspinDown;
CGUITexture m_imgspinUpFocus;
CGUITexture m_imgspinDownFocus;
- CGUITextLayout m_textLayout;
- CLabelInfo m_label;
+ CGUILabel m_label;
bool m_bShowRange;
char m_szTyped[10];
int m_iTypedPos;
diff --git a/guilib/GUISpinControlEx.cpp b/guilib/GUISpinControlEx.cpp
index ae8a0b6bf8..68c36a549c 100644
--- a/guilib/GUISpinControlEx.cpp
+++ b/guilib/GUISpinControlEx.cpp
@@ -35,11 +35,8 @@ CGUISpinControlEx::~CGUISpinControlEx(void)
void CGUISpinControlEx::AllocResources()
{
- // Correct alignment - we always align the spincontrol on the right,
- // and we always use a negative offsetX
- m_label.align = (m_label.align & 4) | XBFONT_RIGHT;
- if (m_label.offsetX > 0)
- m_label.offsetX = -m_label.offsetX;
+ // Correct alignment - we always align the spincontrol on the right
+ m_label.GetLabelInfo().align = (m_label.GetLabelInfo().align & XBFONT_CENTER_Y) | XBFONT_RIGHT;
CGUISpinControl::AllocResources();
m_buttonControl.AllocResources();
if (m_height == 0)
@@ -130,8 +127,8 @@ CStdString CGUISpinControlEx::GetDescription() const
void CGUISpinControlEx::SettingsCategorySetSpinTextColor(const CGUIInfoColor &color)
{
- m_label.textColor = color;
- m_label.focusedColor = color;
+ m_label.GetLabelInfo().textColor = color;
+ m_label.GetLabelInfo().focusedColor = color;
}
void CGUISpinControlEx::SetSpinPosition(float spinPosX)
diff --git a/guilib/GUITextBox.h b/guilib/GUITextBox.h
index 28ea5950d8..e8a5150747 100644
--- a/guilib/GUITextBox.h
+++ b/guilib/GUITextBox.h
@@ -31,6 +31,7 @@
#include "GUITextLayout.h"
#include "GUIControl.h"
+#include "GUILabel.h"
/*!
\ingroup controls
diff --git a/guilib/GUITextLayout.h b/guilib/GUITextLayout.h
index 9fa101d03d..165c5a39cb 100644
--- a/guilib/GUITextLayout.h
+++ b/guilib/GUITextLayout.h
@@ -71,8 +71,20 @@ public:
void Render(float x, float y, float angle, color_t color, color_t shadowColor, uint32_t alignment, float maxWidth, bool solid = false);
void RenderScrolling(float x, float y, float angle, color_t color, color_t shadowColor, uint32_t alignment, float maxWidth, CScrollInfo &scrollInfo);
void RenderOutline(float x, float y, color_t color, color_t outlineColor, uint32_t outlineWidth, uint32_t alignment, float maxWidth);
+
+ /*! \brief Returns the precalculated width and height of the text to be rendered (in constant time).
+ \param width [out] width of text
+ \param height [out] height of text
+ \sa GetTextWidth, CalcTextExtent
+ */
void GetTextExtent(float &width, float &height) const;
+
+ /*! \brief Returns the precalculated width of the text to be rendered (in constant time).
+ \return width of text
+ \sa GetTextExtent, CalcTextExtent
+ */
float GetTextWidth() const { return m_textWidth; };
+
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);
diff --git a/project/VS2008Express/guilib.vcproj b/project/VS2008Express/guilib.vcproj
index 542ae6d6fe..dbf73022a6 100644
--- a/project/VS2008Express/guilib.vcproj
+++ b/project/VS2008Express/guilib.vcproj
@@ -430,6 +430,10 @@
>
</File>
<File
+ RelativePath="..\..\guilib\GUILabel.cpp"
+ >
+ </File>
+ <File
RelativePath="..\..\guilib\GUILabelControl.cpp"
>
</File>
@@ -832,6 +836,10 @@
>
</File>
<File
+ RelativePath="..\..\guilib\GUILabel.h"
+ >
+ </File>
+ <File
RelativePath="..\..\guilib\GUILabelControl.h"
>
</File>
diff --git a/xbmc/GUISettings.cpp b/xbmc/GUISettings.cpp
index adbb1595a3..af000690dd 100644
--- a/xbmc/GUISettings.cpp
+++ b/xbmc/GUISettings.cpp
@@ -42,6 +42,7 @@
#include "PowerManager.h"
#include "cores/dvdplayer/DVDCodecs/Video/CrystalHD/CrystalHD.h"
#include "utils/PCMRemap.h"
+#include "GUIFont.h" // for FONT_STYLE_* definitions
using namespace std;
diff --git a/xbmc/cores/DummyVideoPlayer.cpp b/xbmc/cores/DummyVideoPlayer.cpp
index 50f31b235b..8cead224fb 100644
--- a/xbmc/cores/DummyVideoPlayer.cpp
+++ b/xbmc/cores/DummyVideoPlayer.cpp
@@ -23,6 +23,7 @@
#include "DummyVideoPlayer.h"
#include "GUIFontManager.h"
#include "GUITextLayout.h"
+#include "GUIFont.h" // for XBFONT_* defines
#include "Application.h"
#include "AdvancedSettings.h"
#include "WindowingFactory.h"
diff --git a/xbmc/karaoke/karaokelyricstext.cpp b/xbmc/karaoke/karaokelyricstext.cpp
index 8fb2e45b80..501dd16f01 100644
--- a/xbmc/karaoke/karaokelyricstext.cpp
+++ b/xbmc/karaoke/karaokelyricstext.cpp
@@ -16,6 +16,7 @@
#include "Settings.h"
#include "GUISettings.h"
#include "GUITextLayout.h"
+#include "GUIFont.h"
#include "karaokelyricstext.h"
#include "Util.h"
#include "FileSystem/File.h"
diff --git a/xbmc/lib/libPython/xbmcmodule/controllist.cpp b/xbmc/lib/libPython/xbmcmodule/controllist.cpp
index f334b4f7eb..722abeb1e0 100644
--- a/xbmc/lib/libPython/xbmcmodule/controllist.cpp
+++ b/xbmc/lib/libPython/xbmcmodule/controllist.cpp
@@ -38,6 +38,7 @@
#include "../XBPythonDll.h"
#include "GUIListContainer.h"
#include "GUIFontManager.h"
+#include "GUILabel.h"
#include "control.h"
#include "pyutil.h"